try not to place windows behind always on top windows in smart

placement code. Fix found by Cristian Tibirna

svn path=/trunk/kdebase/kwin/; revision=75050
This commit is contained in:
Dirk Mueller 2000-12-17 03:23:34 +00:00
parent c1eac4d5d0
commit bd3140b6b7

View file

@ -279,7 +279,7 @@ Workspace::Workspace( bool restore )
if ( info->sessionId.isEmpty() && !info->wmCommand.isEmpty() ) { if ( info->sessionId.isEmpty() && !info->wmCommand.isEmpty() ) {
KShellProcess proc; KShellProcess proc;
proc << QString::fromLatin1( info->wmCommand ); proc << QString::fromLatin1( info->wmCommand );
proc.start(KShellProcess::DontCare); proc.start(KShellProcess::DontCare);
} }
} }
} }
@ -300,7 +300,7 @@ void Workspace::init()
NET::WorkArea | NET::WorkArea |
NET::CloseWindow | NET::CloseWindow |
NET::DesktopNames | NET::DesktopNames |
NET::WMName | NET::WMName |
NET::WMDesktop | NET::WMDesktop |
NET::WMWindowType | NET::WMWindowType |
@ -311,7 +311,7 @@ void Workspace::init()
NET::WMPid | NET::WMPid |
NET::WMKDESystemTrayWinFor NET::WMKDESystemTrayWinFor
; ;
rootInfo = new RootInfo( this, qt_xdisplay(), supportWindow->winId(), "KWin", protocols, qt_xscreen() ); rootInfo = new RootInfo( this, qt_xdisplay(), supportWindow->winId(), "KWin", protocols, qt_xscreen() );
loadDesktopSettings(); loadDesktopSettings();
@ -432,16 +432,16 @@ bool Workspace::workspaceEvent( XEvent * e )
return TRUE; return TRUE;
return ( e->xunmap.event != e->xunmap.window ); // hide wm typical event from Qt return ( e->xunmap.event != e->xunmap.window ); // hide wm typical event from Qt
case MapNotify: case MapNotify:
return ( e->xmap.event != e->xmap.window ); // hide wm typical event from Qt return ( e->xmap.event != e->xmap.window ); // hide wm typical event from Qt
case ReparentNotify: case ReparentNotify:
c = findClient( e->xreparent.window ); c = findClient( e->xreparent.window );
if ( c ) if ( c )
(void) c->windowEvent( e ); (void) c->windowEvent( e );
//do not confuse Qt with these events. After all, _we_ are the //do not confuse Qt with these events. After all, _we_ are the
//window manager who does the reparenting. //window manager who does the reparenting.
return TRUE; return TRUE;
@ -1337,7 +1337,10 @@ void Workspace::smartPlacement(Client* c){
(cyt < yb) && (cyb > yt)) { (cyt < yb) && (cyb > yt)) {
xl = QMAX(cxl, xl); xr = QMIN(cxr, xr); xl = QMAX(cxl, xl); xr = QMIN(cxr, xr);
yt = QMAX(cyt, yt); yb = QMIN(cyb, yb); yt = QMAX(cyt, yt); yb = QMIN(cyb, yb);
overlap += (xr - xl) * (yb - yt); if((*l)->staysOnTop())
overlap += 16 * (xr - xl) * (yb - yt);
else
overlap += (xr - xl) * (yb - yt);
} }
} }
} }
@ -1842,7 +1845,7 @@ void Workspace::setCurrentDesktop( int new_desktop ){
} }
current_desktop = new_desktop; current_desktop = new_desktop;
rootInfo->setCurrentDesktop( current_desktop ); // propagate befor the shows below rootInfo->setCurrentDesktop( current_desktop ); // propagate befor the shows below
for ( ClientList::ConstIterator it = stacking_order.fromLast(); it != stacking_order.end(); --it) { for ( ClientList::ConstIterator it = stacking_order.fromLast(); it != stacking_order.end(); --it) {
if ( (*it)->isOnDesktop( new_desktop ) && !(*it)->isIconified() ) { if ( (*it)->isOnDesktop( new_desktop ) && !(*it)->isIconified() ) {
(*it)->show(); (*it)->show();
@ -1860,26 +1863,26 @@ void Workspace::setCurrentDesktop( int new_desktop ){
if ( options->focusPolicyIsReasonable()) { if ( options->focusPolicyIsReasonable()) {
// Search in focus chain // Search in focus chain
if ( focus_chain.contains( old_active_client ) && old_active_client->isVisible() ) { if ( focus_chain.contains( old_active_client ) && old_active_client->isVisible() ) {
c = old_active_client; c = old_active_client;
active_client = c; // the requestFocus below will fail, as the client is already active active_client = c; // the requestFocus below will fail, as the client is already active
} }
if ( !c ) { if ( !c ) {
for( ClientList::ConstIterator it = focus_chain.fromLast(); it != focus_chain.end(); --it) { for( ClientList::ConstIterator it = focus_chain.fromLast(); it != focus_chain.end(); --it) {
if ( (*it)->isVisible() && !(*it)->isSticky() ) { if ( (*it)->isVisible() && !(*it)->isSticky() ) {
c = *it; c = *it;
break; break;
} }
} }
} }
if ( !c ) { if ( !c ) {
for( ClientList::ConstIterator it = focus_chain.fromLast(); it != focus_chain.end(); --it) { for( ClientList::ConstIterator it = focus_chain.fromLast(); it != focus_chain.end(); --it) {
if ( (*it)->isVisible() ) { if ( (*it)->isVisible() ) {
c = *it; c = *it;
break; break;
} }
} }
} }
@ -2593,7 +2596,7 @@ unsigned int Workspace::sendFakedMouseEvent( QPoint pos, WId w, MouseEmulation t
e.state = state; e.state = state;
e.button = button; e.button = button;
XSendEvent( qt_xdisplay(), w, TRUE, ButtonPressMask, (XEvent*)&e ); XSendEvent( qt_xdisplay(), w, TRUE, ButtonPressMask, (XEvent*)&e );
if ( type == EmuPress ) { if ( type == EmuPress ) {
switch ( button ) { switch ( button ) {
case 2: case 2:
@ -2661,25 +2664,25 @@ bool Workspace::keyPressMouseEmulation( XKeyEvent key )
if ( !mouse_emulation_state ) if ( !mouse_emulation_state )
mouse_emulation_window = getMouseEmulationWindow(); mouse_emulation_window = getMouseEmulationWindow();
if ( (mouse_emulation_state & Button1Mask) == 0 ) if ( (mouse_emulation_state & Button1Mask) == 0 )
mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuPress, Button1, mouse_emulation_state ); mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuPress, Button1, mouse_emulation_state );
if ( !is_shift ) if ( !is_shift )
mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button1, mouse_emulation_state ); mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button1, mouse_emulation_state );
break; break;
case XK_F2: case XK_F2:
if ( !mouse_emulation_state ) if ( !mouse_emulation_state )
mouse_emulation_window = getMouseEmulationWindow(); mouse_emulation_window = getMouseEmulationWindow();
if ( (mouse_emulation_state & Button2Mask) == 0 ) if ( (mouse_emulation_state & Button2Mask) == 0 )
mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuPress, Button2, mouse_emulation_state ); mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuPress, Button2, mouse_emulation_state );
if ( !is_shift ) if ( !is_shift )
mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button2, mouse_emulation_state ); mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button2, mouse_emulation_state );
break; break;
case XK_F3: case XK_F3:
if ( !mouse_emulation_state ) if ( !mouse_emulation_state )
mouse_emulation_window = getMouseEmulationWindow(); mouse_emulation_window = getMouseEmulationWindow();
if ( (mouse_emulation_state & Button3Mask) == 0 ) if ( (mouse_emulation_state & Button3Mask) == 0 )
mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuPress, Button3, mouse_emulation_state ); mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuPress, Button3, mouse_emulation_state );
if ( !is_shift ) if ( !is_shift )
mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button3, mouse_emulation_state ); mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button3, mouse_emulation_state );
break; break;
case XK_Return: case XK_Return:
case XK_space: case XK_space:
@ -2689,8 +2692,8 @@ bool Workspace::keyPressMouseEmulation( XKeyEvent key )
if ( !mouse_emulation_state ) { if ( !mouse_emulation_state ) {
// nothing was pressed, fake a LMB click // nothing was pressed, fake a LMB click
mouse_emulation_window = getMouseEmulationWindow(); mouse_emulation_window = getMouseEmulationWindow();
mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuPress, Button1, mouse_emulation_state ); mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuPress, Button1, mouse_emulation_state );
mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button1, mouse_emulation_state ); mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button1, mouse_emulation_state );
} else { // release all } else { // release all
if ( mouse_emulation_state & Button1Mask ) if ( mouse_emulation_state & Button1Mask )
mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button1, mouse_emulation_state ); mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button1, mouse_emulation_state );
@ -2711,7 +2714,7 @@ bool Workspace::keyPressMouseEmulation( XKeyEvent key )
QCursor::setPos( pos ); QCursor::setPos( pos );
if ( mouse_emulation_state ) if ( mouse_emulation_state )
mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuMove, 0, mouse_emulation_state ); mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuMove, 0, mouse_emulation_state );
return TRUE; return TRUE;
} }
@ -2842,13 +2845,13 @@ SessionInfo* Workspace::takeSessionInfo( Client* c )
QCString wmCommand = c->wmCommand(); QCString wmCommand = c->wmCommand();
for (SessionInfo* info = session.first(); info; info = session.next() ) { for (SessionInfo* info = session.first(); info; info = session.next() ) {
// a real session managed client // a real session managed client
if ( info->sessionId == sessionId && if ( info->sessionId == sessionId &&
( ( info->windowRole.isEmpty() && windowRole.isEmpty() ) ( ( info->windowRole.isEmpty() && windowRole.isEmpty() )
|| (info->windowRole == windowRole ) ) ) || (info->windowRole == windowRole ) ) )
return session.take(); return session.take();
// pseudo session management // pseudo session management
if ( info->sessionId.isEmpty() && !info->wmCommand.isEmpty() && if ( info->sessionId.isEmpty() && !info->wmCommand.isEmpty() &&
info->wmCommand == wmCommand && info->wmCommand == wmCommand &&
@ -2889,7 +2892,7 @@ void Workspace::updateClientArea()
r.size.height = area.height(); r.size.height = area.height();
for( int i = 1; i <= numberOfDesktops(); i++) for( int i = 1; i <= numberOfDesktops(); i++)
rootInfo->setWorkArea( i, r ); rootInfo->setWorkArea( i, r );
for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it) { for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it) {
if ( (*it)->isMaximized() ) if ( (*it)->isMaximized() )
(*it)->maximize( Client::MaximizeAdjust ); (*it)->maximize( Client::MaximizeAdjust );
@ -2937,7 +2940,7 @@ void Workspace::saveDesktopSettings()
s = defaultvalue; s = defaultvalue;
rootInfo->setDesktopName( i, s.utf8().data() ); rootInfo->setDesktopName( i, s.utf8().data() );
} }
if (s != defaultvalue) { if (s != defaultvalue) {
c.writeEntry( QString("Name_%1").arg(i), s ); c.writeEntry( QString("Name_%1").arg(i), s );
} else { } else {