2003-09-16 23:28:03 +04:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2000-05-08 00:38:11 +04:00
|
|
|
|
|
|
|
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
2003-09-16 23:28:03 +04:00
|
|
|
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
2000-05-08 00:38:11 +04:00
|
|
|
******************************************************************/
|
|
|
|
|
2003-09-16 23:28:03 +04:00
|
|
|
/*
|
|
|
|
|
|
|
|
This file contains things relevant to handling incoming events.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "client.h"
|
|
|
|
#include "workspace.h"
|
|
|
|
#include "atoms.h"
|
|
|
|
#include "tabbox.h"
|
2004-02-25 12:51:47 +03:00
|
|
|
#include "group.h"
|
2004-05-28 17:51:11 +04:00
|
|
|
#include "rules.h"
|
2006-07-05 00:02:07 +04:00
|
|
|
#include "unmanaged.h"
|
2003-09-16 23:28:03 +04:00
|
|
|
|
2006-05-13 20:33:18 +04:00
|
|
|
#include <QWhatsThis>
|
|
|
|
#include <QApplication>
|
2003-09-16 23:28:03 +04:00
|
|
|
|
2006-04-10 15:57:13 +04:00
|
|
|
#include <kkeyserver.h>
|
|
|
|
|
2003-09-16 23:28:03 +04:00
|
|
|
#include <X11/extensions/shape.h>
|
2003-11-24 17:38:03 +03:00
|
|
|
#include <X11/Xatom.h>
|
2005-07-28 18:59:42 +04:00
|
|
|
#include <QX11Info>
|
2003-09-16 23:28:03 +04:00
|
|
|
|
|
|
|
namespace KWinInternal
|
2000-05-08 00:38:11 +04:00
|
|
|
{
|
2003-09-16 23:28:03 +04:00
|
|
|
|
|
|
|
// ****************************************
|
|
|
|
// WinInfo
|
|
|
|
// ****************************************
|
|
|
|
|
|
|
|
WinInfo::WinInfo( Client * c, Display * display, Window window,
|
|
|
|
Window rwin, const unsigned long pr[], int pr_size )
|
|
|
|
: NETWinInfo( display, window, rwin, pr, pr_size, NET::WindowManager ), m_client( c )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void WinInfo::changeDesktop(int desktop)
|
|
|
|
{
|
|
|
|
m_client->workspace()->sendClientToDesktop( m_client, desktop, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
void WinInfo::changeState( unsigned long state, unsigned long mask )
|
|
|
|
{
|
|
|
|
mask &= ~NET::Sticky; // KWin doesn't support large desktops, ignore
|
|
|
|
mask &= ~NET::Hidden; // clients are not allowed to change this directly
|
|
|
|
state &= mask; // for safety, clear all other bits
|
|
|
|
|
|
|
|
if(( mask & NET::FullScreen ) != 0 && ( state & NET::FullScreen ) == 0 )
|
|
|
|
m_client->setFullScreen( false, false );
|
|
|
|
if ( (mask & NET::Max) == NET::Max )
|
|
|
|
m_client->setMaximize( state & NET::MaxVert, state & NET::MaxHoriz );
|
|
|
|
else if ( mask & NET::MaxVert )
|
|
|
|
m_client->setMaximize( state & NET::MaxVert, m_client->maximizeMode() & Client::MaximizeHorizontal );
|
|
|
|
else if ( mask & NET::MaxHoriz )
|
|
|
|
m_client->setMaximize( m_client->maximizeMode() & Client::MaximizeVertical, state & NET::MaxHoriz );
|
|
|
|
|
|
|
|
if ( mask & NET::Shaded )
|
2004-06-18 12:57:42 +04:00
|
|
|
m_client->setShade( state & NET::Shaded ? ShadeNormal : ShadeNone );
|
2003-09-16 23:28:03 +04:00
|
|
|
if ( mask & NET::KeepAbove)
|
|
|
|
m_client->setKeepAbove( (state & NET::KeepAbove) != 0 );
|
|
|
|
if ( mask & NET::KeepBelow)
|
|
|
|
m_client->setKeepBelow( (state & NET::KeepBelow) != 0 );
|
|
|
|
if( mask & NET::SkipTaskbar )
|
|
|
|
m_client->setSkipTaskbar( ( state & NET::SkipTaskbar ) != 0, true );
|
|
|
|
if( mask & NET::SkipPager )
|
|
|
|
m_client->setSkipPager( ( state & NET::SkipPager ) != 0 );
|
|
|
|
if( mask & NET::DemandsAttention )
|
|
|
|
m_client->demandAttention(( state & NET::DemandsAttention ) != 0 );
|
|
|
|
if( mask & NET::Modal )
|
|
|
|
m_client->setModal( ( state & NET::Modal ) != 0 );
|
|
|
|
// unsetting fullscreen first, setting it last (because e.g. maximize works only for !isFullScreen() )
|
|
|
|
if(( mask & NET::FullScreen ) != 0 && ( state & NET::FullScreen ) != 0 )
|
|
|
|
m_client->setFullScreen( true, false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ****************************************
|
|
|
|
// RootInfo
|
|
|
|
// ****************************************
|
|
|
|
|
|
|
|
RootInfo::RootInfo( Workspace* ws, Display *dpy, Window w, const char *name, unsigned long pr[], int pr_num, int scr )
|
2005-05-13 12:57:21 +04:00
|
|
|
: NETRootInfo4( dpy, w, name, pr, pr_num, scr )
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
|
|
|
workspace = ws;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RootInfo::changeNumberOfDesktops(int n)
|
|
|
|
{
|
|
|
|
workspace->setNumberOfDesktops( n );
|
|
|
|
}
|
|
|
|
|
|
|
|
void RootInfo::changeCurrentDesktop(int d)
|
|
|
|
{
|
|
|
|
workspace->setCurrentDesktop( d );
|
|
|
|
}
|
|
|
|
|
2003-12-18 15:16:30 +03:00
|
|
|
void RootInfo::changeActiveWindow( Window w, NET::RequestSource src, Time timestamp, Window active_window )
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
|
|
|
if( Client* c = workspace->findClient( WindowMatchPredicate( w )))
|
|
|
|
{
|
2004-03-02 19:43:29 +03:00
|
|
|
if( timestamp == CurrentTime )
|
|
|
|
timestamp = c->userTime();
|
2004-04-22 16:30:57 +04:00
|
|
|
if( src != NET::FromApplication && src != FromTool )
|
2004-04-16 14:23:42 +04:00
|
|
|
src = NET::FromTool;
|
2003-09-16 23:28:03 +04:00
|
|
|
if( src == NET::FromTool )
|
2004-10-05 19:46:43 +04:00
|
|
|
workspace->activateClient( c, true ); // force
|
2003-09-16 23:28:03 +04:00
|
|
|
else // NET::FromApplication
|
|
|
|
{
|
2003-12-18 15:16:30 +03:00
|
|
|
Client* c2;
|
2003-09-16 23:28:03 +04:00
|
|
|
if( workspace->allowClientActivation( c, timestamp ))
|
|
|
|
workspace->activateClient( c );
|
2003-12-18 15:16:30 +03:00
|
|
|
// if activation of the requestor's window would be allowed, allow activation too
|
|
|
|
else if( active_window != None
|
|
|
|
&& ( c2 = workspace->findClient( WindowMatchPredicate( active_window ))) != NULL
|
2004-03-02 19:43:29 +03:00
|
|
|
&& workspace->allowClientActivation( c2,
|
|
|
|
timestampCompare( timestamp, c2->userTime() > 0 ? timestamp : c2->userTime())))
|
2003-12-18 15:16:30 +03:00
|
|
|
workspace->activateClient( c );
|
2003-09-16 23:28:03 +04:00
|
|
|
else
|
|
|
|
c->demandAttention();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-16 14:23:42 +04:00
|
|
|
void RootInfo::restackWindow( Window w, RequestSource src, Window above, int detail, Time timestamp )
|
|
|
|
{
|
|
|
|
if( Client* c = workspace->findClient( WindowMatchPredicate( w )))
|
|
|
|
{
|
|
|
|
if( timestamp == CurrentTime )
|
|
|
|
timestamp = c->userTime();
|
2004-04-22 16:30:57 +04:00
|
|
|
if( src != NET::FromApplication && src != FromTool )
|
2004-04-16 14:23:42 +04:00
|
|
|
src = NET::FromTool;
|
2004-04-22 16:30:57 +04:00
|
|
|
c->restackWindow( above, detail, src, timestamp, true );
|
2004-04-16 14:23:42 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-22 16:30:57 +04:00
|
|
|
void RootInfo::gotTakeActivity( Window w, Time timestamp, long flags )
|
|
|
|
{
|
|
|
|
if( Client* c = workspace->findClient( WindowMatchPredicate( w )))
|
|
|
|
workspace->handleTakeActivity( c, timestamp, flags );
|
|
|
|
}
|
|
|
|
|
2003-09-16 23:28:03 +04:00
|
|
|
void RootInfo::closeWindow(Window w)
|
|
|
|
{
|
|
|
|
Client* c = workspace->findClient( WindowMatchPredicate( w ));
|
|
|
|
if ( c )
|
|
|
|
c->closeWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RootInfo::moveResize(Window w, int x_root, int y_root, unsigned long direction)
|
|
|
|
{
|
|
|
|
Client* c = workspace->findClient( WindowMatchPredicate( w ));
|
|
|
|
if ( c )
|
|
|
|
{
|
2003-10-10 16:48:09 +04:00
|
|
|
updateXTime(); // otherwise grabbing may have old timestamp - this message should include timestamp
|
2003-09-16 23:28:03 +04:00
|
|
|
c->NETMoveResize( x_root, y_root, (Direction)direction);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-01 16:08:53 +04:00
|
|
|
void RootInfo::moveResizeWindow(Window w, int flags, int x, int y, int width, int height )
|
|
|
|
{
|
|
|
|
Client* c = workspace->findClient( WindowMatchPredicate( w ));
|
|
|
|
if ( c )
|
|
|
|
c->NETMoveResizeWindow( flags, x, y, width, height );
|
|
|
|
}
|
|
|
|
|
2003-09-16 23:28:03 +04:00
|
|
|
void RootInfo::gotPing( Window w, Time timestamp )
|
|
|
|
{
|
|
|
|
if( Client* c = workspace->findClient( WindowMatchPredicate( w )))
|
|
|
|
c->gotPing( timestamp );
|
|
|
|
}
|
|
|
|
|
2005-05-13 12:57:21 +04:00
|
|
|
void RootInfo::changeShowingDesktop( bool showing )
|
|
|
|
{
|
|
|
|
workspace->setShowingDesktop( showing );
|
|
|
|
}
|
|
|
|
|
2003-09-16 23:28:03 +04:00
|
|
|
// ****************************************
|
|
|
|
// Workspace
|
|
|
|
// ****************************************
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles workspace specific XEvents
|
|
|
|
*/
|
|
|
|
bool Workspace::workspaceEvent( XEvent * e )
|
|
|
|
{
|
|
|
|
if ( mouse_emulation && (e->type == ButtonPress || e->type == ButtonRelease ) )
|
|
|
|
{
|
2006-02-19 04:33:48 +03:00
|
|
|
mouse_emulation = false;
|
2006-07-04 23:36:19 +04:00
|
|
|
XUngrabKeyboard( display(), xTime() );
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( e->type == PropertyNotify || e->type == ClientMessage )
|
|
|
|
{
|
|
|
|
if ( netCheck( e ) )
|
2006-02-19 04:33:48 +03:00
|
|
|
return true;
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// events that should be handled before Clients can get them
|
|
|
|
switch (e->type)
|
|
|
|
{
|
|
|
|
case ButtonPress:
|
|
|
|
case ButtonRelease:
|
|
|
|
was_user_interaction = true;
|
|
|
|
// fallthrough
|
|
|
|
case MotionNotify:
|
|
|
|
if ( tab_grab || control_grab )
|
2003-09-19 15:08:37 +04:00
|
|
|
{
|
|
|
|
tab_box->handleMouseEvent( e );
|
2006-02-19 04:33:48 +03:00
|
|
|
return true;
|
2003-09-19 15:08:37 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case KeyPress:
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
|
|
|
was_user_interaction = true;
|
2006-04-10 15:57:13 +04:00
|
|
|
int keyQt;
|
|
|
|
KKeyServer::xEventToQt(e, keyQt);
|
|
|
|
kDebug(125) << "Workspace::keyPress( " << keyQt << " )" << endl;
|
2003-09-16 23:28:03 +04:00
|
|
|
if (movingClient)
|
|
|
|
{
|
|
|
|
movingClient->keyPressEvent(keyQt);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if( tab_grab || control_grab )
|
|
|
|
{
|
2006-04-10 15:57:13 +04:00
|
|
|
tabBoxKeyPress( keyQt );
|
2003-09-16 23:28:03 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case KeyRelease:
|
|
|
|
was_user_interaction = true;
|
|
|
|
if( tab_grab || control_grab )
|
2003-09-19 15:08:37 +04:00
|
|
|
{
|
|
|
|
tabBoxKeyRelease( e->xkey );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
if( Client* c = findClient( WindowMatchPredicate( e->xany.window )))
|
|
|
|
{
|
2003-12-18 15:20:22 +03:00
|
|
|
if( c->windowEvent( e ))
|
|
|
|
return true;
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
2003-12-18 15:20:22 +03:00
|
|
|
else if( Client* c = findClient( WrapperIdMatchPredicate( e->xany.window )))
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
2003-12-18 15:20:22 +03:00
|
|
|
if( c->windowEvent( e ))
|
|
|
|
return true;
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
2003-12-18 15:20:22 +03:00
|
|
|
else if( Client* c = findClient( FrameIdMatchPredicate( e->xany.window )))
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
2003-12-18 15:20:22 +03:00
|
|
|
if( c->windowEvent( e ))
|
2003-10-02 16:33:51 +04:00
|
|
|
return true;
|
2003-12-18 15:20:22 +03:00
|
|
|
}
|
2006-07-05 00:02:07 +04:00
|
|
|
else if( Unmanaged* c = findUnmanaged( HandleMatchPredicate( e->xany.window )))
|
|
|
|
{
|
|
|
|
if( c->windowEvent( e ))
|
|
|
|
return true;
|
|
|
|
}
|
2003-12-18 15:20:22 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Window special = findSpecialEventWindow( e );
|
|
|
|
if( special != None )
|
|
|
|
if( Client* c = findClient( WindowMatchPredicate( special )))
|
|
|
|
{
|
|
|
|
if( c->windowEvent( e ))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2004-03-05 16:39:27 +03:00
|
|
|
if( movingClient != NULL && movingClient->moveResizeGrabWindow() == e->xany.window
|
|
|
|
&& ( e->type == MotionNotify || e->type == ButtonPress || e->type == ButtonRelease ))
|
|
|
|
{
|
|
|
|
if( movingClient->windowEvent( e ))
|
|
|
|
return true;
|
|
|
|
}
|
2003-09-16 23:28:03 +04:00
|
|
|
|
|
|
|
switch (e->type)
|
|
|
|
{
|
|
|
|
case CreateNotify:
|
|
|
|
if ( e->xcreatewindow.parent == root &&
|
|
|
|
!QWidget::find( e->xcreatewindow.window) &&
|
|
|
|
!e->xcreatewindow.override_redirect )
|
|
|
|
{
|
|
|
|
// see comments for allowClientActivation()
|
2006-07-04 23:36:19 +04:00
|
|
|
Time t = xTime();
|
|
|
|
XChangeProperty(display(), e->xcreatewindow.window,
|
2003-09-16 23:28:03 +04:00
|
|
|
atoms->kde_net_wm_user_creation_time, XA_CARDINAL,
|
2005-07-28 18:59:42 +04:00
|
|
|
32, PropModeReplace, (unsigned char *)&t, 1);
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UnmapNotify:
|
|
|
|
{
|
|
|
|
// check for system tray windows
|
2003-10-30 13:10:54 +03:00
|
|
|
if ( removeSystemTrayWin( e->xunmap.window, true ) )
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
|
|
|
// If the system tray gets destroyed, the system tray
|
|
|
|
// icons automatically get unmapped, reparented and mapped
|
|
|
|
// again to the closest non-client ancestor due to
|
2006-05-31 20:23:36 +04:00
|
|
|
// QXEmbed's SaveSet feature. Unfortunately with kicker
|
2003-09-16 23:28:03 +04:00
|
|
|
// this closest ancestor is not the root window, but our
|
2006-05-31 20:23:36 +04:00
|
|
|
// decoration, so we reparent explicitly back to the root
|
2003-09-16 23:28:03 +04:00
|
|
|
// window.
|
|
|
|
XEvent ev;
|
|
|
|
WId w = e->xunmap.window;
|
2006-07-04 23:36:19 +04:00
|
|
|
if ( XCheckTypedWindowEvent (display(), w,
|
2003-09-16 23:28:03 +04:00
|
|
|
ReparentNotify, &ev) )
|
|
|
|
{
|
|
|
|
if ( ev.xreparent.parent != root )
|
|
|
|
{
|
2006-07-04 23:36:19 +04:00
|
|
|
XReparentWindow( display(), w, root, 0, 0 );
|
2003-09-16 23:28:03 +04:00
|
|
|
addSystemTrayWin( w );
|
|
|
|
}
|
|
|
|
}
|
2006-02-19 04:33:48 +03:00
|
|
|
return true;
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
return ( e->xunmap.event != e->xunmap.window ); // hide wm typical event from Qt
|
|
|
|
}
|
|
|
|
case ReparentNotify:
|
|
|
|
{
|
|
|
|
//do not confuse Qt with these events. After all, _we_ are the
|
|
|
|
//window manager who does the reparenting.
|
2006-02-19 04:33:48 +03:00
|
|
|
return true;
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
case DestroyNotify:
|
|
|
|
{
|
2003-10-30 13:10:54 +03:00
|
|
|
if ( removeSystemTrayWin( e->xdestroywindow.window, false ) )
|
2006-02-19 04:33:48 +03:00
|
|
|
return true;
|
2003-09-16 23:28:03 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case MapRequest:
|
|
|
|
{
|
|
|
|
updateXTime();
|
|
|
|
|
2003-09-29 18:39:02 +04:00
|
|
|
// e->xmaprequest.window is different from e->xany.window
|
2003-10-02 16:33:51 +04:00
|
|
|
// TODO this shouldn't be necessary now
|
2003-09-16 23:28:03 +04:00
|
|
|
Client* c = findClient( WindowMatchPredicate( e->xmaprequest.window ));
|
|
|
|
if ( !c )
|
|
|
|
{
|
|
|
|
// don't check for the parent being the root window, this breaks when some app unmaps
|
|
|
|
// a window, changes something and immediately maps it back, without giving KWin
|
|
|
|
// a chance to reparent it back to root
|
|
|
|
// since KWin can get MapRequest only for root window children and
|
|
|
|
// children of WindowWrapper (=clients), the check is AFAIK useless anyway
|
2003-12-18 15:25:22 +03:00
|
|
|
// Note: Now the save-set support in Client::mapRequestEvent() actually requires that
|
|
|
|
// this code doesn't check the parent to be root.
|
2003-09-16 23:28:03 +04:00
|
|
|
// if ( e->xmaprequest.parent == root ) { //###TODO store previously destroyed client ids
|
|
|
|
if ( addSystemTrayWin( e->xmaprequest.window ) )
|
2006-02-19 04:33:48 +03:00
|
|
|
return true;
|
2003-11-24 18:05:50 +03:00
|
|
|
c = createClient( e->xmaprequest.window, false );
|
2006-07-04 23:36:19 +04:00
|
|
|
if ( c != NULL && root != rootWindow() )
|
2003-09-16 23:28:03 +04:00
|
|
|
{ // TODO what is this?
|
2003-11-22 02:05:35 +03:00
|
|
|
// TODO may use QWidget::create
|
2006-07-04 23:36:19 +04:00
|
|
|
XReparentWindow( display(), c->frameId(), root, 0, 0 );
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
if( c == NULL ) // refused to manage, simply map it (most probably override redirect)
|
2006-07-04 23:36:19 +04:00
|
|
|
XMapRaised( display(), e->xmaprequest.window );
|
2003-09-16 23:28:03 +04:00
|
|
|
return true;
|
|
|
|
}
|
2006-02-27 13:13:31 +03:00
|
|
|
if( c )
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
|
|
|
c->windowEvent( e );
|
2006-04-11 18:52:27 +04:00
|
|
|
updateFocusChains( c, FocusChainUpdate );
|
2003-09-16 23:28:03 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2006-07-05 00:02:07 +04:00
|
|
|
case MapNotify:
|
|
|
|
{
|
|
|
|
if( e->xmap.override_redirect )
|
|
|
|
{
|
|
|
|
Unmanaged* c = findUnmanaged( HandleMatchPredicate( e->xmap.window ));
|
|
|
|
if( c == NULL )
|
|
|
|
c = createUnmanaged( e->xmap.window );
|
|
|
|
if( c )
|
|
|
|
{
|
|
|
|
c->windowEvent( e );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ( e->xmap.event != e->xmap.window ); // hide wm typical event from Qt
|
|
|
|
}
|
|
|
|
|
2003-09-16 23:28:03 +04:00
|
|
|
case EnterNotify:
|
|
|
|
{
|
2004-12-22 16:00:59 +03:00
|
|
|
if ( QWhatsThis::inWhatsThisMode() )
|
|
|
|
{
|
|
|
|
QWidget* w = QWidget::find( e->xcrossing.window );
|
|
|
|
if ( w )
|
|
|
|
QWhatsThis::leaveWhatsThisMode();
|
|
|
|
}
|
2004-11-09 18:38:33 +03:00
|
|
|
if( electricBorder(e))
|
|
|
|
return true;
|
2004-12-22 16:00:59 +03:00
|
|
|
break;
|
|
|
|
}
|
2003-09-29 18:39:02 +04:00
|
|
|
case LeaveNotify:
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
|
|
|
if ( !QWhatsThis::inWhatsThisMode() )
|
|
|
|
break;
|
2003-09-29 18:39:02 +04:00
|
|
|
// TODO is this cliente ever found, given that client events are searched above?
|
2003-09-16 23:28:03 +04:00
|
|
|
Client* c = findClient( FrameIdMatchPredicate( e->xcrossing.window ));
|
|
|
|
if ( c && e->xcrossing.detail != NotifyInferior )
|
|
|
|
QWhatsThis::leaveWhatsThisMode();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ConfigureRequest:
|
|
|
|
{
|
2003-09-19 15:16:57 +04:00
|
|
|
if ( e->xconfigurerequest.parent == root )
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
|
|
|
XWindowChanges wc;
|
2006-04-11 16:59:59 +04:00
|
|
|
wc.border_width = e->xconfigurerequest.border_width;
|
2003-09-16 23:28:03 +04:00
|
|
|
wc.x = e->xconfigurerequest.x;
|
|
|
|
wc.y = e->xconfigurerequest.y;
|
|
|
|
wc.width = e->xconfigurerequest.width;
|
|
|
|
wc.height = e->xconfigurerequest.height;
|
|
|
|
wc.sibling = None;
|
|
|
|
wc.stack_mode = Above;
|
2006-04-11 16:59:59 +04:00
|
|
|
unsigned int value_mask = e->xconfigurerequest.value_mask
|
|
|
|
& ( CWX | CWY | CWWidth | CWHeight | CWBorderWidth );
|
2006-07-04 23:36:19 +04:00
|
|
|
XConfigureWindow( display(), e->xconfigurerequest.window, value_mask, &wc );
|
2003-10-02 16:33:51 +04:00
|
|
|
return true;
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case KeyPress:
|
|
|
|
if ( mouse_emulation )
|
|
|
|
return keyPressMouseEmulation( e->xkey );
|
|
|
|
break;
|
|
|
|
case KeyRelease:
|
|
|
|
if ( mouse_emulation )
|
2006-02-19 04:33:48 +03:00
|
|
|
return false;
|
2003-09-16 23:28:03 +04:00
|
|
|
break;
|
|
|
|
case FocusIn:
|
2004-05-10 18:06:32 +04:00
|
|
|
if( e->xfocus.window == rootWin()
|
|
|
|
&& ( e->xfocus.detail == NotifyDetailNone || e->xfocus.detail == NotifyPointerRoot ))
|
2004-02-02 17:17:01 +03:00
|
|
|
{
|
2006-07-04 23:36:19 +04:00
|
|
|
updateXTime(); // focusToNull() uses xTime(), which is old now (FocusIn has no timestamp)
|
2004-02-23 20:09:47 +03:00
|
|
|
Window focus;
|
|
|
|
int revert;
|
2006-07-04 23:36:19 +04:00
|
|
|
XGetInputFocus( display(), &focus, &revert );
|
2004-05-10 18:06:32 +04:00
|
|
|
if( focus == None || focus == PointerRoot )
|
2004-02-23 20:09:47 +03:00
|
|
|
{
|
2006-02-06 17:47:18 +03:00
|
|
|
//kWarning( 1212 ) << "X focus set to None/PointerRoot, reseting focus" << endl;
|
2004-11-22 14:34:09 +03:00
|
|
|
Client *c = mostRecentlyActivatedClient();
|
|
|
|
if( c != NULL )
|
|
|
|
requestFocus( c, true );
|
|
|
|
else if( activateNextClient( NULL ))
|
|
|
|
; // ok, activated
|
2004-05-10 18:06:32 +04:00
|
|
|
else
|
|
|
|
focusToNull();
|
2004-02-23 20:09:47 +03:00
|
|
|
}
|
2004-02-02 17:17:01 +03:00
|
|
|
}
|
|
|
|
// fall through
|
2003-09-16 23:28:03 +04:00
|
|
|
case FocusOut:
|
|
|
|
return true; // always eat these, they would tell Qt that KWin is the active app
|
2004-11-09 18:38:33 +03:00
|
|
|
case ClientMessage:
|
|
|
|
if( electricBorder( e ))
|
|
|
|
return true;
|
|
|
|
break;
|
2005-06-22 19:44:24 +04:00
|
|
|
case MappingNotify:
|
|
|
|
XRefreshKeyboardMapping( &e->xmapping );
|
|
|
|
tab_box->updateKeyMapping();
|
|
|
|
break;
|
2006-07-05 03:46:02 +04:00
|
|
|
case Expose:
|
2006-07-05 20:04:11 +04:00
|
|
|
if( e->xexpose.window == rootWindow() && compositing()) // root window needs repainting
|
|
|
|
addDamage( e->xexpose.x, e->xexpose.y, e->xexpose.width, e->xexpose.height );
|
2006-07-05 03:46:02 +04:00
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
default:
|
2003-09-29 18:39:02 +04:00
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
2006-02-19 04:33:48 +03:00
|
|
|
return false;
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
|
2003-10-02 16:33:51 +04:00
|
|
|
// Some events don't have the actual window which caused the event
|
|
|
|
// as e->xany.window (e.g. ConfigureRequest), but as some other
|
|
|
|
// field in the XEvent structure.
|
|
|
|
Window Workspace::findSpecialEventWindow( XEvent* e )
|
|
|
|
{
|
|
|
|
switch( e->type )
|
|
|
|
{
|
|
|
|
case CreateNotify:
|
|
|
|
return e->xcreatewindow.window;
|
|
|
|
case DestroyNotify:
|
|
|
|
return e->xdestroywindow.window;
|
|
|
|
case UnmapNotify:
|
|
|
|
return e->xunmap.window;
|
|
|
|
case MapNotify:
|
|
|
|
return e->xmap.window;
|
|
|
|
case MapRequest:
|
|
|
|
return e->xmaprequest.window;
|
|
|
|
case ReparentNotify:
|
|
|
|
return e->xreparent.window;
|
|
|
|
case ConfigureNotify:
|
|
|
|
return e->xconfigure.window;
|
|
|
|
case GravityNotify:
|
|
|
|
return e->xgravity.window;
|
|
|
|
case ConfigureRequest:
|
|
|
|
return e->xconfigurerequest.window;
|
|
|
|
case CirculateNotify:
|
|
|
|
return e->xcirculate.window;
|
|
|
|
case CirculateRequest:
|
|
|
|
return e->xcirculaterequest.window;
|
|
|
|
default:
|
|
|
|
return None;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2003-09-16 23:28:03 +04:00
|
|
|
/*!
|
|
|
|
Handles client messages sent to the workspace
|
|
|
|
*/
|
|
|
|
bool Workspace::netCheck( XEvent* e )
|
|
|
|
{
|
|
|
|
unsigned int dirty = rootInfo->event( e );
|
|
|
|
|
|
|
|
if ( dirty & NET::DesktopNames )
|
|
|
|
saveDesktopSettings();
|
|
|
|
|
|
|
|
return dirty != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ****************************************
|
|
|
|
// Client
|
|
|
|
// ****************************************
|
|
|
|
|
|
|
|
/*!
|
|
|
|
General handler for XEvents concerning the client window
|
|
|
|
*/
|
2003-12-18 15:20:22 +03:00
|
|
|
bool Client::windowEvent( XEvent* e )
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
|
|
|
if( e->xany.window == window()) // avoid doing stuff on frame or wrapper
|
|
|
|
{
|
|
|
|
unsigned long dirty[ 2 ];
|
|
|
|
info->event( e, dirty, 2 ); // pass through the NET stuff
|
|
|
|
|
|
|
|
if ( ( dirty[ WinInfo::PROTOCOLS ] & NET::WMName ) != 0 )
|
|
|
|
fetchName();
|
|
|
|
if ( ( dirty[ WinInfo::PROTOCOLS ] & NET::WMIconName ) != 0 )
|
|
|
|
fetchIconicName();
|
2004-02-17 20:34:00 +03:00
|
|
|
if ( ( dirty[ WinInfo::PROTOCOLS ] & NET::WMStrut ) != 0
|
|
|
|
|| ( dirty[ WinInfo::PROTOCOLS2 ] & NET::WM2ExtendedStrut ) != 0 )
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
|
|
|
if( isTopMenu()) // the fallback mode of KMenuBar may alter the strut
|
|
|
|
checkWorkspacePosition(); // restore it
|
|
|
|
workspace()->updateClientArea();
|
|
|
|
}
|
|
|
|
if ( ( dirty[ WinInfo::PROTOCOLS ] & NET::WMIcon) != 0 )
|
|
|
|
getIcons();
|
|
|
|
// Note there's a difference between userTime() and info->userTime()
|
|
|
|
// info->userTime() is the value of the property, userTime() also includes
|
|
|
|
// updates of the time done by KWin (ButtonPress on windowrapper etc.).
|
|
|
|
if(( dirty[ WinInfo::PROTOCOLS2 ] & NET::WM2UserTime ) != 0 )
|
|
|
|
{
|
|
|
|
workspace()->setWasUserInteraction();
|
|
|
|
updateUserTime( info->userTime());
|
|
|
|
}
|
|
|
|
if(( dirty[ WinInfo::PROTOCOLS2 ] & NET::WM2StartupId ) != 0 )
|
|
|
|
startupIdChanged();
|
2005-05-30 17:31:33 +04:00
|
|
|
if( dirty[ WinInfo::PROTOCOLS ] & NET::WMIconGeometry )
|
|
|
|
{
|
|
|
|
if( demandAttentionKNotifyTimer != NULL )
|
|
|
|
demandAttentionKNotify();
|
|
|
|
}
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO move all focus handling stuff to separate file?
|
|
|
|
switch (e->type)
|
|
|
|
{
|
|
|
|
case UnmapNotify:
|
2003-12-18 15:20:22 +03:00
|
|
|
unmapNotifyEvent( &e->xunmap );
|
|
|
|
break;
|
2003-09-19 15:16:57 +04:00
|
|
|
case DestroyNotify:
|
2003-12-18 15:20:22 +03:00
|
|
|
destroyNotifyEvent( &e->xdestroywindow );
|
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
case MapRequest:
|
2003-12-18 15:20:22 +03:00
|
|
|
// this one may pass the event to workspace
|
2003-09-19 15:16:57 +04:00
|
|
|
return mapRequestEvent( &e->xmaprequest );
|
2003-09-16 23:28:03 +04:00
|
|
|
case ConfigureRequest:
|
2003-12-18 15:20:22 +03:00
|
|
|
configureRequestEvent( &e->xconfigurerequest );
|
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
case PropertyNotify:
|
2003-12-18 15:20:22 +03:00
|
|
|
propertyNotifyEvent( &e->xproperty );
|
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
case KeyPress:
|
|
|
|
updateUserTime();
|
|
|
|
workspace()->setWasUserInteraction();
|
|
|
|
break;
|
|
|
|
case ButtonPress:
|
|
|
|
updateUserTime();
|
|
|
|
workspace()->setWasUserInteraction();
|
2003-09-19 15:11:07 +04:00
|
|
|
buttonPressEvent( e->xbutton.window, e->xbutton.button, e->xbutton.state,
|
|
|
|
e->xbutton.x, e->xbutton.y, e->xbutton.x_root, e->xbutton.y_root );
|
2005-01-15 20:07:48 +03:00
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
case KeyRelease:
|
|
|
|
// don't update user time on releases
|
|
|
|
// e.g. if the user presses Alt+F2, the Alt release
|
|
|
|
// would appear as user input to the currently active window
|
|
|
|
break;
|
|
|
|
case ButtonRelease:
|
|
|
|
// don't update user time on releases
|
|
|
|
// e.g. if the user presses Alt+F2, the Alt release
|
|
|
|
// would appear as user input to the currently active window
|
2003-09-19 15:11:07 +04:00
|
|
|
buttonReleaseEvent( e->xbutton.window, e->xbutton.button, e->xbutton.state,
|
|
|
|
e->xbutton.x, e->xbutton.y, e->xbutton.x_root, e->xbutton.y_root );
|
2003-12-18 15:20:22 +03:00
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
case MotionNotify:
|
2003-09-25 13:28:56 +04:00
|
|
|
motionNotifyEvent( e->xmotion.window, e->xmotion.state,
|
|
|
|
e->xmotion.x, e->xmotion.y, e->xmotion.x_root, e->xmotion.y_root );
|
2003-12-18 15:20:22 +03:00
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
case EnterNotify:
|
|
|
|
enterNotifyEvent( &e->xcrossing );
|
2003-09-19 15:11:07 +04:00
|
|
|
// MotionNotify is guaranteed to be generated only if the mouse
|
|
|
|
// move start and ends in the window; for cases when it only
|
|
|
|
// starts or only ends there, Enter/LeaveNotify are generated.
|
|
|
|
// Fake a MotionEvent in such cases to make handle of mouse
|
|
|
|
// events simpler (Qt does that too).
|
|
|
|
motionNotifyEvent( e->xcrossing.window, e->xcrossing.state,
|
|
|
|
e->xcrossing.x, e->xcrossing.y, e->xcrossing.x_root, e->xcrossing.y_root );
|
2003-12-18 15:20:22 +03:00
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
case LeaveNotify:
|
2003-09-19 15:11:07 +04:00
|
|
|
motionNotifyEvent( e->xcrossing.window, e->xcrossing.state,
|
|
|
|
e->xcrossing.x, e->xcrossing.y, e->xcrossing.x_root, e->xcrossing.y_root );
|
2003-12-18 15:20:22 +03:00
|
|
|
leaveNotifyEvent( &e->xcrossing );
|
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
case FocusIn:
|
2003-12-18 15:20:22 +03:00
|
|
|
focusInEvent( &e->xfocus );
|
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
case FocusOut:
|
2003-12-18 15:20:22 +03:00
|
|
|
focusOutEvent( &e->xfocus );
|
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
case ReparentNotify:
|
|
|
|
break;
|
|
|
|
case ClientMessage:
|
2003-12-18 15:20:22 +03:00
|
|
|
clientMessageEvent( &e->xclient );
|
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
case ColormapChangeMask:
|
|
|
|
if( e->xany.window == window())
|
|
|
|
{
|
|
|
|
cmap = e->xcolormap.colormap;
|
|
|
|
if ( isActive() )
|
|
|
|
workspace()->updateColormap();
|
|
|
|
}
|
2003-12-18 15:20:22 +03:00
|
|
|
break;
|
|
|
|
case VisibilityNotify:
|
|
|
|
visibilityNotifyEvent( &e->xvisibility );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if( e->xany.window == window())
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
2006-07-05 00:02:07 +04:00
|
|
|
if( e->type == Extensions::shapeNotifyEvent() )
|
|
|
|
{
|
|
|
|
is_shape = hasShape( window()); // workaround for #19644
|
|
|
|
updateShape();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( e->xany.window == frameId())
|
|
|
|
{
|
|
|
|
if( e->type == Extensions::damageNotifyEvent())
|
|
|
|
damageNotifyEvent( reinterpret_cast< XDamageNotifyEvent* >( e ));
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
2003-12-18 15:20:22 +03:00
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
2003-12-18 15:20:22 +03:00
|
|
|
return true; // eat all events
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles map requests of the client window
|
|
|
|
*/
|
2003-12-18 15:20:22 +03:00
|
|
|
bool Client::mapRequestEvent( XMapRequestEvent* e )
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
|
|
|
if( e->window != window())
|
2003-12-18 15:20:22 +03:00
|
|
|
{
|
2003-12-18 15:25:22 +03:00
|
|
|
// Special support for the save-set feature, which is a bit broken.
|
|
|
|
// If there's a window from one client embedded in another one,
|
|
|
|
// e.g. using XEMBED, and the embedder suddenly looses its X connection,
|
|
|
|
// save-set will reparent the embedded window to its closest ancestor
|
|
|
|
// that will remains. Unfortunately, with reparenting window managers,
|
|
|
|
// this is not the root window, but the frame (or in KWin's case,
|
|
|
|
// it's the wrapper for the client window). In this case,
|
|
|
|
// the wrapper will get ReparentNotify for a window it won't know,
|
|
|
|
// which will be ignored, and then it gets MapRequest, as save-set
|
|
|
|
// always maps. Returning true here means that Workspace::workspaceEvent()
|
|
|
|
// will handle this MapRequest and manage this window (i.e. act as if
|
|
|
|
// it was reparented to root window).
|
|
|
|
if( e->parent == wrapperId())
|
|
|
|
return false;
|
2003-12-18 15:20:22 +03:00
|
|
|
return true; // no messing with frame etc.
|
|
|
|
}
|
2003-11-10 21:50:38 +03:00
|
|
|
if( isTopMenu() && workspace()->managingTopMenus())
|
2003-12-18 15:20:22 +03:00
|
|
|
return true; // kwin controls these
|
2003-09-16 23:28:03 +04:00
|
|
|
switch ( mappingState() )
|
|
|
|
{
|
|
|
|
case WithdrawnState:
|
|
|
|
assert( false ); // WMs are not supposed to manage clients in Withdrawn state,
|
|
|
|
// manage(); // after initial mapping manage() is called from createClient()
|
|
|
|
break;
|
|
|
|
case IconicState:
|
|
|
|
// also copied in clientMessage()
|
|
|
|
if( isMinimized())
|
|
|
|
unminimize();
|
2003-10-10 17:00:26 +04:00
|
|
|
if( isShade())
|
2003-09-16 23:28:03 +04:00
|
|
|
setShade( ShadeNone );
|
2003-10-10 17:00:26 +04:00
|
|
|
if( !isOnCurrentDesktop())
|
|
|
|
{
|
|
|
|
if( workspace()->allowClientActivation( this ))
|
|
|
|
workspace()->activateClient( this );
|
|
|
|
else
|
|
|
|
demandAttention();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NormalState:
|
|
|
|
// TODO fake MapNotify?
|
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
2003-12-18 15:20:22 +03:00
|
|
|
return true;
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles unmap notify events of the client window
|
|
|
|
*/
|
|
|
|
void Client::unmapNotifyEvent( XUnmapEvent* e )
|
|
|
|
{
|
|
|
|
if( e->window != window())
|
|
|
|
return;
|
|
|
|
if( e->event != wrapperId())
|
|
|
|
{ // most probably event from root window when initially reparenting
|
|
|
|
bool ignore = true;
|
|
|
|
if( e->event == workspace()->rootWin() && e->send_event )
|
|
|
|
ignore = false; // XWithdrawWindow()
|
|
|
|
if( ignore )
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
switch( mappingState())
|
|
|
|
{
|
|
|
|
case IconicState:
|
|
|
|
releaseWindow();
|
|
|
|
return;
|
|
|
|
case NormalState:
|
|
|
|
// maybe we will be destroyed soon. Check this first.
|
|
|
|
XEvent ev;
|
2006-07-04 23:36:19 +04:00
|
|
|
if( XCheckTypedWindowEvent (display(), window(),
|
2003-09-16 23:28:03 +04:00
|
|
|
DestroyNotify, &ev) ) // TODO I don't like this much
|
2003-11-10 21:50:38 +03:00
|
|
|
{
|
|
|
|
destroyClient(); // deletes this
|
|
|
|
return;
|
|
|
|
}
|
2003-11-21 19:46:57 +03:00
|
|
|
releaseWindow();
|
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
default:
|
|
|
|
assert( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-19 15:16:57 +04:00
|
|
|
void Client::destroyNotifyEvent( XDestroyWindowEvent* e )
|
|
|
|
{
|
|
|
|
if( e->window != window())
|
|
|
|
return;
|
|
|
|
destroyClient();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-19 04:33:48 +03:00
|
|
|
bool blockAnimation = false;
|
2003-09-16 23:28:03 +04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles client messages for the client window
|
|
|
|
*/
|
|
|
|
void Client::clientMessageEvent( XClientMessageEvent* e )
|
|
|
|
{
|
|
|
|
if( e->window != window())
|
|
|
|
return; // ignore frame/wrapper
|
|
|
|
// WM_STATE
|
|
|
|
if ( e->message_type == atoms->kde_wm_change_state )
|
|
|
|
{
|
2003-11-10 21:50:38 +03:00
|
|
|
if( isTopMenu() && workspace()->managingTopMenus())
|
|
|
|
return; // kwin controls these
|
2003-09-16 23:28:03 +04:00
|
|
|
if( e->data.l[ 1 ] )
|
|
|
|
blockAnimation = true;
|
|
|
|
if( e->data.l[ 0 ] == IconicState )
|
|
|
|
minimize();
|
|
|
|
else if( e->data.l[ 0 ] == NormalState )
|
|
|
|
{ // copied from mapRequest()
|
|
|
|
if( isMinimized())
|
|
|
|
unminimize();
|
2003-10-10 17:00:26 +04:00
|
|
|
if( isShade())
|
2003-09-16 23:28:03 +04:00
|
|
|
setShade( ShadeNone );
|
2003-10-10 17:00:26 +04:00
|
|
|
if( !isOnCurrentDesktop())
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
|
|
|
if( workspace()->allowClientActivation( this ))
|
|
|
|
workspace()->activateClient( this );
|
|
|
|
else
|
|
|
|
demandAttention();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
blockAnimation = false;
|
|
|
|
}
|
|
|
|
else if ( e->message_type == atoms->wm_change_state)
|
|
|
|
{
|
2003-11-10 21:50:38 +03:00
|
|
|
if( isTopMenu() && workspace()->managingTopMenus())
|
|
|
|
return; // kwin controls these
|
2003-09-16 23:28:03 +04:00
|
|
|
if ( e->data.l[0] == IconicState )
|
|
|
|
minimize();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles configure requests of the client window
|
|
|
|
*/
|
|
|
|
void Client::configureRequestEvent( XConfigureRequestEvent* e )
|
|
|
|
{
|
|
|
|
if( e->window != window())
|
|
|
|
return; // ignore frame/wrapper
|
2003-12-11 21:00:01 +03:00
|
|
|
if ( isResize() || isMove())
|
2003-09-16 23:28:03 +04:00
|
|
|
return; // we have better things to do right now
|
|
|
|
|
2004-08-03 13:21:18 +04:00
|
|
|
if( fullscreen_mode == FullScreenNormal ) // refuse resizing of fullscreen windows
|
|
|
|
{ // but allow resizing fullscreen hacks in order to let them cancel fullscreen mode
|
|
|
|
sendSyntheticConfigureNotify();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if( isSplash() // no manipulations with splashscreens either
|
2003-09-16 23:28:03 +04:00
|
|
|
|| isTopMenu()) // topmenus neither
|
|
|
|
{
|
|
|
|
sendSyntheticConfigureNotify();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( e->value_mask & CWBorderWidth )
|
|
|
|
{
|
|
|
|
// first, get rid of a window border
|
|
|
|
XWindowChanges wc;
|
|
|
|
unsigned int value_mask = 0;
|
|
|
|
|
|
|
|
wc.border_width = 0;
|
|
|
|
value_mask = CWBorderWidth;
|
2006-07-04 23:36:19 +04:00
|
|
|
XConfigureWindow( display(), window(), value_mask, & wc );
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
|
2003-10-01 16:08:53 +04:00
|
|
|
if( e->value_mask & ( CWX | CWY | CWHeight | CWWidth ))
|
2004-07-16 15:25:07 +04:00
|
|
|
configureRequest( e->value_mask, e->x, e->y, e->width, e->height, 0, false );
|
2003-09-16 23:28:03 +04:00
|
|
|
|
2003-09-30 16:49:23 +04:00
|
|
|
if ( e->value_mask & CWStackMode )
|
2004-04-16 13:43:53 +04:00
|
|
|
restackWindow( e->above, e->detail, NET::FromApplication, userTime(), false );
|
2003-09-16 23:28:03 +04:00
|
|
|
|
|
|
|
// TODO sending a synthetic configure notify always is fine, even in cases where
|
|
|
|
// the ICCCM doesn't require this - it can be though of as 'the WM decided to move
|
2004-02-03 18:18:15 +03:00
|
|
|
// the window later'. The client should not cause that many configure request,
|
|
|
|
// so this should not have any significant impact. With user moving/resizing
|
|
|
|
// the it should be optimized though (see also Client::setGeometry()/plainResize()/move()).
|
2003-09-16 23:28:03 +04:00
|
|
|
sendSyntheticConfigureNotify();
|
|
|
|
|
|
|
|
// SELI TODO accept configure requests for isDesktop windows (because kdesktop
|
|
|
|
// may get XRANDR resize event before kwin), but check it's still at the bottom?
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles property changes of the client window
|
|
|
|
*/
|
|
|
|
void Client::propertyNotifyEvent( XPropertyEvent* e )
|
|
|
|
{
|
|
|
|
if( e->window != window())
|
|
|
|
return; // ignore frame/wrapper
|
|
|
|
switch ( e->atom )
|
|
|
|
{
|
|
|
|
case XA_WM_NORMAL_HINTS:
|
|
|
|
getWmNormalHints();
|
|
|
|
break;
|
|
|
|
case XA_WM_NAME:
|
|
|
|
fetchName();
|
|
|
|
break;
|
|
|
|
case XA_WM_ICON_NAME:
|
|
|
|
fetchIconicName();
|
|
|
|
break;
|
|
|
|
case XA_WM_TRANSIENT_FOR:
|
|
|
|
readTransient();
|
|
|
|
break;
|
|
|
|
case XA_WM_HINTS:
|
|
|
|
getWMHints();
|
|
|
|
getIcons(); // because KWin::icon() uses WMHints as fallback
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if ( e->atom == atoms->wm_protocols )
|
|
|
|
getWindowProtocols();
|
|
|
|
else if (e->atom == atoms->wm_client_leader )
|
|
|
|
getWmClientLeader();
|
2005-07-28 18:59:42 +04:00
|
|
|
else if( e->atom == atoms->wm_window_role )
|
2004-06-28 17:47:02 +04:00
|
|
|
window_role = staticWindowRole( window());
|
2004-07-27 12:35:51 +04:00
|
|
|
else if( e->atom == atoms->motif_wm_hints )
|
|
|
|
getMotifHints();
|
2003-09-16 23:28:03 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Client::enterNotifyEvent( XCrossingEvent* e )
|
|
|
|
{
|
|
|
|
if( e->window != frameId())
|
|
|
|
return; // care only about entering the whole frame
|
|
|
|
if( e->mode == NotifyNormal ||
|
|
|
|
( !options->focusPolicyIsReasonable() &&
|
|
|
|
e->mode == NotifyUngrab ) )
|
|
|
|
{
|
|
|
|
|
|
|
|
if (options->shadeHover && isShade())
|
|
|
|
{
|
|
|
|
delete shadeHoverTimer;
|
|
|
|
shadeHoverTimer = new QTimer( this );
|
|
|
|
connect( shadeHoverTimer, SIGNAL( timeout() ), this, SLOT( shadeHover() ));
|
2006-04-11 21:12:05 +04:00
|
|
|
shadeHoverTimer->setSingleShot( true );
|
|
|
|
shadeHoverTimer->start( options->shadeHoverInterval );
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( options->focusPolicy == Options::ClickToFocus )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( options->autoRaise && !isDesktop() &&
|
|
|
|
!isDock() && !isTopMenu() && workspace()->focusChangeEnabled() &&
|
|
|
|
workspace()->topClientOnDesktop( workspace()->currentDesktop()) != this )
|
|
|
|
{
|
|
|
|
delete autoRaiseTimer;
|
|
|
|
autoRaiseTimer = new QTimer( this );
|
|
|
|
connect( autoRaiseTimer, SIGNAL( timeout() ), this, SLOT( autoRaise() ) );
|
2006-04-11 21:12:05 +04:00
|
|
|
autoRaiseTimer->setSingleShot( true );
|
|
|
|
autoRaiseTimer->start( options->autoRaiseInterval );
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( options->focusPolicy != Options::FocusStrictlyUnderMouse && ( isDesktop() || isDock() || isTopMenu() ) )
|
|
|
|
return;
|
2004-05-28 12:53:44 +04:00
|
|
|
if ( options->delayFocus )
|
|
|
|
workspace()->requestDelayFocus( this );
|
|
|
|
else
|
|
|
|
workspace()->requestFocus( this );
|
2003-09-16 23:28:03 +04:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Client::leaveNotifyEvent( XCrossingEvent* e )
|
|
|
|
{
|
|
|
|
if( e->window != frameId())
|
|
|
|
return; // care only about leaving the whole frame
|
|
|
|
if ( e->mode == NotifyNormal )
|
|
|
|
{
|
|
|
|
if ( !buttonDown )
|
|
|
|
{
|
2003-12-15 18:10:17 +03:00
|
|
|
mode = PositionCenter;
|
2005-10-27 13:07:06 +04:00
|
|
|
setCursor( Qt::ArrowCursor );
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
bool lostMouse = !rect().contains( QPoint( e->x, e->y ) );
|
|
|
|
// 'lostMouse' wouldn't work with e.g. B2 or Keramik, which have non-rectangular decorations
|
|
|
|
// (i.e. the LeaveNotify event comes before leaving the rect and no LeaveNotify event
|
|
|
|
// comes after leaving the rect) - so lets check if the pointer is really outside the window
|
|
|
|
|
|
|
|
// TODO this still sucks if a window appears above this one - it should lose the mouse
|
|
|
|
// if this window is another client, but not if it's a popup ... maybe after KDE3.1 :(
|
|
|
|
// (repeat after me 'AARGHL!')
|
|
|
|
if ( !lostMouse && e->detail != NotifyInferior )
|
|
|
|
{
|
|
|
|
int d1, d2, d3, d4;
|
|
|
|
unsigned int d5;
|
|
|
|
Window w, child;
|
2006-07-04 23:36:19 +04:00
|
|
|
if( XQueryPointer( display(), frameId(), &w, &child, &d1, &d2, &d3, &d4, &d5 ) == False
|
2003-09-16 23:28:03 +04:00
|
|
|
|| child == None )
|
|
|
|
lostMouse = true; // really lost the mouse
|
|
|
|
}
|
|
|
|
if ( lostMouse )
|
|
|
|
{
|
2004-02-10 17:46:03 +03:00
|
|
|
cancelAutoRaise();
|
2004-05-28 12:53:44 +04:00
|
|
|
workspace()->cancelDelayFocus();
|
2005-05-06 19:20:49 +04:00
|
|
|
cancelShadeHover();
|
2003-09-16 23:28:03 +04:00
|
|
|
if ( shade_mode == ShadeHover && !moveResizeMode && !buttonDown )
|
|
|
|
setShade( ShadeNormal );
|
|
|
|
}
|
|
|
|
if ( options->focusPolicy == Options::FocusStrictlyUnderMouse )
|
|
|
|
if ( isActive() && lostMouse )
|
|
|
|
workspace()->requestFocus( 0 ) ;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-10 15:57:13 +04:00
|
|
|
#define XCapL KKeyServer::modXLock()
|
|
|
|
#define XNumL KKeyServer::modXNumLock()
|
|
|
|
#define XScrL KKeyServer::modXScrollLock()
|
2003-09-16 23:28:03 +04:00
|
|
|
void Client::grabButton( int modifier )
|
|
|
|
{
|
|
|
|
unsigned int mods[ 8 ] =
|
|
|
|
{
|
|
|
|
0, XCapL, XNumL, XNumL | XCapL,
|
|
|
|
XScrL, XScrL | XCapL,
|
2004-01-05 16:29:00 +03:00
|
|
|
XScrL | XNumL, XScrL | XNumL | XCapL
|
|
|
|
};
|
|
|
|
for( int i = 0;
|
|
|
|
i < 8;
|
|
|
|
++i )
|
2006-07-04 23:36:19 +04:00
|
|
|
XGrabButton( display(), AnyButton,
|
2004-01-05 16:29:00 +03:00
|
|
|
modifier | mods[ i ],
|
2006-04-10 15:57:13 +04:00
|
|
|
wrapperId(), false, ButtonPressMask,
|
2004-01-05 16:29:00 +03:00
|
|
|
GrabModeSync, GrabModeAsync, None, None );
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Client::ungrabButton( int modifier )
|
|
|
|
{
|
|
|
|
unsigned int mods[ 8 ] =
|
|
|
|
{
|
|
|
|
0, XCapL, XNumL, XNumL | XCapL,
|
|
|
|
XScrL, XScrL | XCapL,
|
2004-01-05 16:29:00 +03:00
|
|
|
XScrL | XNumL, XScrL | XNumL | XCapL
|
|
|
|
};
|
|
|
|
for( int i = 0;
|
|
|
|
i < 8;
|
|
|
|
++i )
|
2006-07-04 23:36:19 +04:00
|
|
|
XUngrabButton( display(), AnyButton,
|
2004-01-05 16:29:00 +03:00
|
|
|
modifier | mods[ i ], wrapperId());
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
#undef XCapL
|
|
|
|
#undef XNumL
|
|
|
|
#undef XScrL
|
|
|
|
|
|
|
|
/*
|
|
|
|
Releases the passive grab for some modifier combinations when a
|
|
|
|
window becomes active. This helps broken X programs that
|
|
|
|
missinterpret LeaveNotify events in grab mode to work properly
|
|
|
|
(Motif, AWT, Tk, ...)
|
|
|
|
*/
|
|
|
|
void Client::updateMouseGrab()
|
2005-08-02 17:25:20 +04:00
|
|
|
{
|
|
|
|
if( workspace()->globalShortcutsDisabled())
|
|
|
|
{
|
2006-07-04 23:36:19 +04:00
|
|
|
XUngrabButton( display(), AnyButton, AnyModifier, wrapperId());
|
2005-08-02 17:25:20 +04:00
|
|
|
// keep grab for the simple click without modifiers if needed
|
|
|
|
if( !( !options->clickRaise || not_obscured ))
|
|
|
|
grabButton( None );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if( isActive() && !workspace()->forcedGlobalMouseGrab()) // see Workspace::establishTabBoxGrab()
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
|
|
|
// remove the grab for no modifiers only if the window
|
|
|
|
// is unobscured or if the user doesn't want click raise
|
|
|
|
if( !options->clickRaise || not_obscured )
|
|
|
|
ungrabButton( None );
|
|
|
|
else
|
|
|
|
grabButton( None );
|
|
|
|
ungrabButton( ShiftMask );
|
|
|
|
ungrabButton( ControlMask );
|
|
|
|
ungrabButton( ControlMask | ShiftMask );
|
|
|
|
}
|
|
|
|
else
|
2004-01-06 12:42:00 +03:00
|
|
|
{
|
2006-07-04 23:36:19 +04:00
|
|
|
XUngrabButton( display(), AnyButton, AnyModifier, wrapperId());
|
2003-09-16 23:28:03 +04:00
|
|
|
// simply grab all modifier combinations
|
2006-07-04 23:36:19 +04:00
|
|
|
XGrabButton(display(), AnyButton, AnyModifier, wrapperId(), false,
|
2003-09-16 23:28:03 +04:00
|
|
|
ButtonPressMask,
|
|
|
|
GrabModeSync, GrabModeAsync,
|
|
|
|
None, None );
|
2004-01-06 12:42:00 +03:00
|
|
|
}
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
|
2003-09-19 15:11:07 +04:00
|
|
|
int qtToX11Button( Qt::ButtonState button )
|
|
|
|
{
|
|
|
|
if( button == Qt::LeftButton )
|
|
|
|
return Button1;
|
|
|
|
else if( button == Qt::MidButton )
|
|
|
|
return Button2;
|
|
|
|
else if( button == Qt::RightButton )
|
|
|
|
return Button3;
|
|
|
|
return AnyButton;
|
|
|
|
}
|
|
|
|
|
2006-04-12 19:13:31 +04:00
|
|
|
int qtToX11State( Qt::ButtonState buttons, Qt::KeyboardModifiers modifiers )
|
2003-09-19 15:11:07 +04:00
|
|
|
{
|
|
|
|
int ret = 0;
|
2006-04-12 19:13:31 +04:00
|
|
|
if( buttons & Qt::LeftButton )
|
2003-09-19 15:11:07 +04:00
|
|
|
ret |= Button1Mask;
|
2006-04-12 19:13:31 +04:00
|
|
|
if( buttons & Qt::MidButton )
|
2003-09-19 15:11:07 +04:00
|
|
|
ret |= Button2Mask;
|
2006-04-12 19:13:31 +04:00
|
|
|
if( buttons & Qt::RightButton )
|
2003-09-19 15:11:07 +04:00
|
|
|
ret |= Button3Mask;
|
2006-04-12 19:13:31 +04:00
|
|
|
if( modifiers & Qt::ShiftModifier )
|
2003-09-19 15:11:07 +04:00
|
|
|
ret |= ShiftMask;
|
2006-04-12 19:13:31 +04:00
|
|
|
if( modifiers & Qt::ControlModifier )
|
2003-09-19 15:11:07 +04:00
|
|
|
ret |= ControlMask;
|
2006-04-12 19:13:31 +04:00
|
|
|
if( modifiers & Qt::AltModifier )
|
2006-04-10 15:57:13 +04:00
|
|
|
ret |= KKeyServer::modXAlt();
|
2006-04-12 19:13:31 +04:00
|
|
|
if( modifiers & Qt::MetaModifier )
|
2006-04-10 15:57:13 +04:00
|
|
|
ret |= KKeyServer::modXMeta();
|
2003-09-19 15:11:07 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Qt propagates mouse events up the widget hierachy, which means events
|
|
|
|
// for the decoration window cannot be (easily) intercepted as X11 events
|
|
|
|
bool Client::eventFilter( QObject* o, QEvent* e )
|
|
|
|
{
|
|
|
|
if( decoration == NULL
|
|
|
|
|| o != decoration->widget())
|
|
|
|
return false;
|
|
|
|
if( e->type() == QEvent::MouseButtonPress )
|
|
|
|
{
|
|
|
|
QMouseEvent* ev = static_cast< QMouseEvent* >( e );
|
2006-04-12 19:13:31 +04:00
|
|
|
return buttonPressEvent( decorationId(), qtToX11Button( ev->button()), qtToX11State( ev->buttons(), ev->modifiers() ),
|
2003-09-19 15:11:07 +04:00
|
|
|
ev->x(), ev->y(), ev->globalX(), ev->globalY() );
|
|
|
|
}
|
|
|
|
if( e->type() == QEvent::MouseButtonRelease )
|
|
|
|
{
|
|
|
|
QMouseEvent* ev = static_cast< QMouseEvent* >( e );
|
2006-04-12 19:13:31 +04:00
|
|
|
return buttonReleaseEvent( decorationId(), qtToX11Button( ev->button()), qtToX11State( ev->buttons(), ev->modifiers() ),
|
2003-09-19 15:11:07 +04:00
|
|
|
ev->x(), ev->y(), ev->globalX(), ev->globalY() );
|
|
|
|
}
|
|
|
|
if( e->type() == QEvent::MouseMove ) // FRAME i fake z enter/leave?
|
|
|
|
{
|
|
|
|
QMouseEvent* ev = static_cast< QMouseEvent* >( e );
|
2006-04-12 19:13:31 +04:00
|
|
|
return motionNotifyEvent( decorationId(), qtToX11State( ev->buttons(), ev->modifiers() ),
|
2003-09-19 15:11:07 +04:00
|
|
|
ev->x(), ev->y(), ev->globalX(), ev->globalY() );
|
|
|
|
}
|
2005-05-06 19:20:49 +04:00
|
|
|
if( e->type() == QEvent::Wheel )
|
|
|
|
{
|
|
|
|
QWheelEvent* ev = static_cast< QWheelEvent* >( e );
|
2006-04-12 19:13:31 +04:00
|
|
|
bool r = buttonPressEvent( decorationId(), ev->delta() > 0 ? Button4 : Button5, qtToX11State( ev->buttons(), ev->modifiers() ),
|
2005-05-06 19:20:49 +04:00
|
|
|
ev->x(), ev->y(), ev->globalX(), ev->globalY() );
|
2006-04-12 19:13:31 +04:00
|
|
|
r = r || buttonReleaseEvent( decorationId(), ev->delta() > 0 ? Button4 : Button5, qtToX11State( ev->buttons(), ev->modifiers() ),
|
2005-05-06 19:20:49 +04:00
|
|
|
ev->x(), ev->y(), ev->globalX(), ev->globalY() );
|
|
|
|
return r;
|
|
|
|
}
|
2003-09-19 15:13:24 +04:00
|
|
|
if( e->type() == QEvent::Resize )
|
|
|
|
{
|
|
|
|
QResizeEvent* ev = static_cast< QResizeEvent* >( e );
|
|
|
|
// Filter out resize events that inform about size different than frame size.
|
|
|
|
// This will ensure that decoration->width() etc. and decoration->widget()->width() will be in sync.
|
|
|
|
// These events only seem to be delayed events from initial resizing before show() was called
|
|
|
|
// on the decoration widget.
|
|
|
|
if( ev->size() != size())
|
|
|
|
return true;
|
|
|
|
}
|
2003-09-19 15:11:07 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// return value matters only when filtering events before decoration gets them
|
|
|
|
bool Client::buttonPressEvent( Window w, int button, int state, int x, int y, int x_root, int y_root )
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
|
|
|
if (buttonDown)
|
|
|
|
{
|
2003-09-19 15:11:07 +04:00
|
|
|
if( w == wrapperId())
|
2006-07-04 23:36:19 +04:00
|
|
|
XAllowEvents(display(), SyncPointer, CurrentTime ); //xTime());
|
2003-09-16 23:28:03 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-09-19 15:11:07 +04:00
|
|
|
if( w == wrapperId() || w == frameId() || w == decorationId())
|
2003-09-16 23:28:03 +04:00
|
|
|
{ // FRAME neco s tohohle by se melo zpracovat, nez to dostane dekorace
|
|
|
|
updateUserTime();
|
|
|
|
workspace()->setWasUserInteraction();
|
|
|
|
uint keyModX = (options->keyCmdAllModKey() == Qt::Key_Meta) ?
|
2006-04-10 15:57:13 +04:00
|
|
|
KKeyServer::modXMeta() :
|
|
|
|
KKeyServer::modXAlt();
|
|
|
|
bool bModKeyHeld = keyModX != 0 && ( state & KKeyServer::accelModMaskX()) == keyModX;
|
2003-09-16 23:28:03 +04:00
|
|
|
|
|
|
|
if( isSplash()
|
2003-09-19 15:11:07 +04:00
|
|
|
&& button == Button1 && !bModKeyHeld )
|
2003-09-16 23:28:03 +04:00
|
|
|
{ // hide splashwindow if the user clicks on it
|
|
|
|
hideClient( true );
|
2003-09-19 15:11:07 +04:00
|
|
|
if( w == wrapperId())
|
2006-07-04 23:36:19 +04:00
|
|
|
XAllowEvents(display(), SyncPointer, CurrentTime ); //xTime());
|
2003-09-16 23:28:03 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Options::MouseCommand com = Options::MouseNothing;
|
|
|
|
bool was_action = false;
|
2004-04-16 14:23:42 +04:00
|
|
|
bool perform_handled = false;
|
2005-05-06 19:20:49 +04:00
|
|
|
if ( bModKeyHeld )
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
|
|
|
was_action = true;
|
2003-09-19 15:11:07 +04:00
|
|
|
switch (button)
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
|
|
|
case Button1:
|
|
|
|
com = options->commandAll1();
|
|
|
|
break;
|
|
|
|
case Button2:
|
|
|
|
com = options->commandAll2();
|
|
|
|
break;
|
|
|
|
case Button3:
|
|
|
|
com = options->commandAll3();
|
|
|
|
break;
|
2005-05-06 19:20:49 +04:00
|
|
|
case Button4:
|
|
|
|
case Button5:
|
|
|
|
com = options->operationWindowMouseWheel( button == Button4 ? 120 : -120 );
|
|
|
|
break;
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // inactive inner window
|
2003-09-19 15:11:07 +04:00
|
|
|
if( !isActive() && w == wrapperId())
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
|
|
|
was_action = true;
|
2004-04-16 14:23:42 +04:00
|
|
|
perform_handled = true;
|
2003-09-19 15:11:07 +04:00
|
|
|
switch (button)
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
|
|
|
case Button1:
|
|
|
|
com = options->commandWindow1();
|
|
|
|
break;
|
|
|
|
case Button2:
|
|
|
|
com = options->commandWindow2();
|
|
|
|
break;
|
|
|
|
case Button3:
|
|
|
|
com = options->commandWindow3();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
com = Options::MouseActivateAndPassClick;
|
|
|
|
}
|
|
|
|
}
|
2004-04-16 14:23:42 +04:00
|
|
|
// active inner window
|
|
|
|
if( isActive() && w == wrapperId()
|
|
|
|
&& options->clickRaise && button < 4 ) // exclude wheel
|
|
|
|
{
|
2004-04-19 18:29:37 +04:00
|
|
|
com = Options::MouseActivateRaiseAndPassClick;
|
2004-04-16 14:23:42 +04:00
|
|
|
was_action = true;
|
|
|
|
perform_handled = true;
|
|
|
|
}
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
if( was_action )
|
|
|
|
{
|
2004-04-16 14:23:42 +04:00
|
|
|
bool replay = performMouseCommand( com, QPoint( x_root, y_root), perform_handled );
|
2003-09-16 23:28:03 +04:00
|
|
|
|
2005-05-11 18:20:54 +04:00
|
|
|
if ( isSpecialWindow())
|
2006-02-19 04:33:48 +03:00
|
|
|
replay = true;
|
2003-09-16 23:28:03 +04:00
|
|
|
|
2005-05-06 19:20:49 +04:00
|
|
|
if( w == wrapperId()) // these can come only from a grab
|
2006-07-04 23:36:19 +04:00
|
|
|
XAllowEvents(display(), replay? ReplayPointer : SyncPointer, CurrentTime ); //xTime());
|
2003-09-16 23:28:03 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-19 15:11:07 +04:00
|
|
|
if( w == wrapperId()) // these can come only from a grab
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
2006-07-04 23:36:19 +04:00
|
|
|
XAllowEvents(display(), ReplayPointer, CurrentTime ); //xTime());
|
2003-09-16 23:28:03 +04:00
|
|
|
return true;
|
|
|
|
}
|
2003-09-19 15:11:07 +04:00
|
|
|
if( w == decorationId())
|
2003-09-16 23:28:03 +04:00
|
|
|
return false; // don't eat decoration events
|
2003-09-19 15:11:07 +04:00
|
|
|
if( w == frameId())
|
|
|
|
processDecorationButtonPress( button, state, x, y, x_root, y_root );
|
2003-09-16 23:28:03 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-09-19 15:11:07 +04:00
|
|
|
// this function processes button press events only after decoration decides not to handle them,
|
|
|
|
// unlike buttonPressEvent(), which (when the window is decoration) filters events before decoration gets them
|
2003-09-16 23:28:03 +04:00
|
|
|
void Client::processDecorationButtonPress( int button, int /*state*/, int x, int y, int x_root, int y_root )
|
|
|
|
{
|
|
|
|
Options::MouseCommand com = Options::MouseNothing;
|
|
|
|
bool active = isActive();
|
|
|
|
if ( !wantsInput() ) // we cannot be active, use it anyway
|
2006-02-19 04:33:48 +03:00
|
|
|
active = true;
|
2003-09-16 23:28:03 +04:00
|
|
|
|
2003-09-19 15:08:37 +04:00
|
|
|
if ( button == Button1 )
|
|
|
|
com = active ? options->commandActiveTitlebar1() : options->commandInactiveTitlebar1();
|
|
|
|
else if ( button == Button2 )
|
|
|
|
com = active ? options->commandActiveTitlebar2() : options->commandInactiveTitlebar2();
|
|
|
|
else if ( button == Button3 )
|
|
|
|
com = active ? options->commandActiveTitlebar3() : options->commandInactiveTitlebar3();
|
2005-04-29 19:14:10 +04:00
|
|
|
if( button == Button1
|
|
|
|
&& com != Options::MouseOperationsMenu // actions where it's not possible to get the matching
|
2003-09-19 15:11:07 +04:00
|
|
|
&& com != Options::MouseMinimize ) // mouse release event
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
2005-05-13 16:32:33 +04:00
|
|
|
mode = mousePosition( QPoint( x, y ));
|
2006-02-19 04:33:48 +03:00
|
|
|
buttonDown = true;
|
2003-09-16 23:28:03 +04:00
|
|
|
moveOffset = QPoint( x, y );
|
|
|
|
invertedMoveOffset = rect().bottomRight() - moveOffset;
|
|
|
|
unrestrictedMoveResize = false;
|
2004-03-05 17:22:11 +03:00
|
|
|
setCursor( mode ); // update to sizeAllCursor if about to move
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
performMouseCommand( com, QPoint( x_root, y_root ));
|
|
|
|
}
|
|
|
|
|
2003-09-19 15:11:07 +04:00
|
|
|
// called from decoration
|
|
|
|
void Client::processMousePressEvent( QMouseEvent* e )
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
2003-09-19 15:11:07 +04:00
|
|
|
if( e->type() != QEvent::MouseButtonPress )
|
|
|
|
{
|
2006-02-06 17:47:18 +03:00
|
|
|
kWarning() << "processMousePressEvent()" << endl;
|
2003-09-19 15:11:07 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
int button;
|
|
|
|
switch( e->button())
|
|
|
|
{
|
2005-07-28 18:59:42 +04:00
|
|
|
case Qt::LeftButton:
|
2003-09-19 15:11:07 +04:00
|
|
|
button = Button1;
|
|
|
|
break;
|
2005-07-28 18:59:42 +04:00
|
|
|
case Qt::MidButton:
|
2003-09-19 15:11:07 +04:00
|
|
|
button = Button2;
|
|
|
|
break;
|
2005-07-28 18:59:42 +04:00
|
|
|
case Qt::RightButton:
|
2003-09-19 15:11:07 +04:00
|
|
|
button = Button3;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2006-04-12 19:13:31 +04:00
|
|
|
processDecorationButtonPress( button, e->buttons(), e->x(), e->y(), e->globalX(), e->globalY());
|
2003-09-19 15:11:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// return value matters only when filtering events before decoration gets them
|
|
|
|
bool Client::buttonReleaseEvent( Window w, int /*button*/, int state, int x, int y, int x_root, int y_root )
|
|
|
|
{
|
|
|
|
if( w == decorationId() && !buttonDown)
|
2003-09-16 23:28:03 +04:00
|
|
|
return false;
|
2003-09-19 15:11:07 +04:00
|
|
|
if( w == wrapperId())
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
2006-07-04 23:36:19 +04:00
|
|
|
XAllowEvents(display(), SyncPointer, CurrentTime ); //xTime());
|
2003-09-16 23:28:03 +04:00
|
|
|
return true;
|
|
|
|
}
|
2004-03-05 17:07:11 +03:00
|
|
|
if( w != frameId() && w != decorationId() && w != moveResizeGrabWindow())
|
2003-09-16 23:28:03 +04:00
|
|
|
return true;
|
2004-03-05 16:39:27 +03:00
|
|
|
x = this->x(); // translate from grab window to local coords
|
|
|
|
y = this->y();
|
2003-09-19 15:11:07 +04:00
|
|
|
if ( (state & ( Button1Mask & Button2Mask & Button3Mask )) == 0 )
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
2006-02-19 04:33:48 +03:00
|
|
|
buttonDown = false;
|
2003-09-16 23:28:03 +04:00
|
|
|
if ( moveResizeMode )
|
|
|
|
{
|
|
|
|
finishMoveResize( false );
|
|
|
|
// mouse position is still relative to old Client position, adjust it
|
2003-09-19 15:11:07 +04:00
|
|
|
QPoint mousepos( x_root - x, y_root - y );
|
2003-09-25 13:29:18 +04:00
|
|
|
mode = mousePosition( mousepos );
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
2004-03-05 17:22:11 +03:00
|
|
|
setCursor( mode );
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-11-24 17:38:03 +03:00
|
|
|
static bool was_motion = false;
|
2004-02-03 18:16:58 +03:00
|
|
|
static Time next_motion_time = CurrentTime;
|
|
|
|
// Check whole incoming X queue for MotionNotify events
|
|
|
|
// checking whole queue is done by always returning False in the predicate.
|
|
|
|
// If there are more MotionNotify events in the queue, all until the last
|
|
|
|
// one may be safely discarded (if a ButtonRelease event comes, a MotionNotify
|
|
|
|
// will be faked from it, so there's no need to check other events).
|
|
|
|
// This helps avoiding being overloaded by being flooded from many events
|
|
|
|
// from the XServer.
|
2003-11-24 17:38:03 +03:00
|
|
|
static Bool motion_predicate( Display*, XEvent* ev, XPointer )
|
|
|
|
{
|
|
|
|
if( ev->type == MotionNotify )
|
|
|
|
{
|
2004-02-03 18:16:58 +03:00
|
|
|
was_motion = true;
|
|
|
|
next_motion_time = ev->xmotion.time; // for setting time
|
2003-11-24 17:38:03 +03:00
|
|
|
}
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool waitingMotionEvent()
|
|
|
|
{
|
2004-02-03 18:16:58 +03:00
|
|
|
// The queue doesn't need to be checked until the X timestamp
|
|
|
|
// of processes events reaches the timestamp of the last suitable
|
|
|
|
// MotionNotify event in the queue.
|
|
|
|
if( next_motion_time != CurrentTime
|
2006-07-04 23:36:19 +04:00
|
|
|
&& timestampCompare( xTime(), next_motion_time ) < 0 )
|
2004-02-03 18:16:58 +03:00
|
|
|
return true;
|
2003-11-24 17:38:03 +03:00
|
|
|
was_motion = false;
|
2006-07-04 23:36:19 +04:00
|
|
|
XSync( display(), False ); // this helps to discard more MotionNotify events
|
2003-11-24 17:38:03 +03:00
|
|
|
XEvent dummy;
|
2006-07-04 23:36:19 +04:00
|
|
|
XCheckIfEvent( display(), &dummy, motion_predicate, NULL );
|
2003-11-24 17:38:03 +03:00
|
|
|
return was_motion;
|
|
|
|
}
|
|
|
|
|
2003-09-19 15:11:07 +04:00
|
|
|
// return value matters only when filtering events before decoration gets them
|
|
|
|
bool Client::motionNotifyEvent( Window w, int /*state*/, int x, int y, int x_root, int y_root )
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
2004-03-05 16:39:27 +03:00
|
|
|
if( w != frameId() && w != decorationId() && w != moveResizeGrabWindow())
|
2003-09-16 23:28:03 +04:00
|
|
|
return true; // care only about the whole frame
|
|
|
|
if ( !buttonDown )
|
|
|
|
{
|
2003-12-15 18:10:17 +03:00
|
|
|
Position newmode = mousePosition( QPoint( x, y ));
|
2003-09-16 23:28:03 +04:00
|
|
|
if( newmode != mode )
|
|
|
|
setCursor( newmode );
|
|
|
|
mode = newmode;
|
2005-01-10 19:53:11 +03:00
|
|
|
// reset the timestamp for the optimization, otherwise with long passivity
|
|
|
|
// the option in waitingMotionEvent() may be always true
|
|
|
|
next_motion_time = CurrentTime;
|
2003-09-16 23:28:03 +04:00
|
|
|
return false;
|
2003-09-19 15:11:07 +04:00
|
|
|
}
|
2004-03-05 16:39:27 +03:00
|
|
|
if( w == moveResizeGrabWindow())
|
|
|
|
{
|
|
|
|
x = this->x(); // translate from grab window to local coords
|
|
|
|
y = this->y();
|
|
|
|
}
|
2003-11-24 17:38:03 +03:00
|
|
|
if( !waitingMotionEvent())
|
|
|
|
handleMoveResize( x, y, x_root, y_root );
|
2003-09-16 23:28:03 +04:00
|
|
|
return true;
|
|
|
|
}
|
2003-09-24 14:55:54 +04:00
|
|
|
|
2003-09-16 23:28:03 +04:00
|
|
|
void Client::focusInEvent( XFocusInEvent* e )
|
|
|
|
{
|
|
|
|
if( e->window != window())
|
|
|
|
return; // only window gets focus
|
|
|
|
if ( e->mode == NotifyUngrab )
|
|
|
|
return; // we don't care
|
|
|
|
if ( e->detail == NotifyPointer )
|
|
|
|
return; // we don't care
|
2004-03-11 16:15:04 +03:00
|
|
|
if( !isShown( false ) || !isOnCurrentDesktop()) // we unmapped it, but it got focus meanwhile ->
|
|
|
|
return; // activateNextClient() already transferred focus elsewhere
|
2003-09-16 23:28:03 +04:00
|
|
|
// check if this client is in should_get_focus list or if activation is allowed
|
|
|
|
bool activate = workspace()->allowClientActivation( this, -1U, true );
|
|
|
|
workspace()->gotFocusIn( this ); // remove from should_get_focus list
|
|
|
|
if( activate )
|
2006-02-19 04:33:48 +03:00
|
|
|
setActive( true );
|
2003-09-16 23:28:03 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
workspace()->restoreFocus();
|
|
|
|
demandAttention();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// When a client loses focus, FocusOut events are usually immediatelly
|
|
|
|
// followed by FocusIn events for another client that gains the focus
|
|
|
|
// (unless the focus goes to another screen, or to the nofocus widget).
|
|
|
|
// Without this check, the former focused client would have to be
|
|
|
|
// deactivated, and after that, the new one would be activated, with
|
|
|
|
// a short time when there would be no active client. This can cause
|
|
|
|
// flicker sometimes, e.g. when a fullscreen is shown, and focus is transferred
|
|
|
|
// from it to its transient, the fullscreen would be kept in the Active layer
|
|
|
|
// at the beginning and at the end, but not in the middle, when the active
|
|
|
|
// client would be temporarily none (see Client::belongToLayer() ).
|
|
|
|
// Therefore, the events queue is checked, whether it contains the matching
|
|
|
|
// FocusIn event, and if yes, deactivation of the previous client will
|
|
|
|
// be skipped, as activation of the new one will automatically deactivate
|
|
|
|
// previously active client.
|
|
|
|
static bool follows_focusin = false;
|
|
|
|
static bool follows_focusin_failed = false;
|
|
|
|
static Bool predicate_follows_focusin( Display*, XEvent* e, XPointer arg )
|
|
|
|
{
|
|
|
|
if( follows_focusin || follows_focusin_failed )
|
|
|
|
return False;
|
|
|
|
Client* c = ( Client* ) arg;
|
|
|
|
if( e->type == FocusIn && c->workspace()->findClient( WindowMatchPredicate( e->xfocus.window )))
|
|
|
|
{ // found FocusIn
|
|
|
|
follows_focusin = true;
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
// events that may be in the queue before the FocusIn event that's being
|
|
|
|
// searched for
|
|
|
|
if( e->type == FocusIn || e->type == FocusOut || e->type == KeymapNotify )
|
|
|
|
return False;
|
|
|
|
follows_focusin_failed = true; // a different event - stop search
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool check_follows_focusin( Client* c )
|
|
|
|
{
|
|
|
|
follows_focusin = follows_focusin_failed = false;
|
|
|
|
XEvent dummy;
|
|
|
|
// XCheckIfEvent() is used to make the search non-blocking, the predicate
|
|
|
|
// always returns False, so nothing is removed from the events queue.
|
|
|
|
// XPeekIfEvent() would block.
|
2006-07-04 23:36:19 +04:00
|
|
|
XCheckIfEvent( display(), &dummy, predicate_follows_focusin, (XPointer)c );
|
2003-09-16 23:28:03 +04:00
|
|
|
return follows_focusin;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Client::focusOutEvent( XFocusOutEvent* e )
|
|
|
|
{
|
|
|
|
if( e->window != window())
|
|
|
|
return; // only window gets focus
|
|
|
|
if ( e->mode == NotifyGrab )
|
|
|
|
return; // we don't care
|
|
|
|
if ( isShade() )
|
|
|
|
return; // here neither
|
|
|
|
if ( e->detail != NotifyNonlinear
|
|
|
|
&& e->detail != NotifyNonlinearVirtual )
|
|
|
|
// SELI check all this
|
|
|
|
return; // hack for motif apps like netscape
|
|
|
|
if ( QApplication::activePopupWidget() )
|
|
|
|
return;
|
|
|
|
if( !check_follows_focusin( this ))
|
2006-02-19 04:33:48 +03:00
|
|
|
setActive( false );
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Client::visibilityNotifyEvent( XVisibilityEvent * e)
|
|
|
|
{
|
|
|
|
if( e->window != frameId())
|
|
|
|
return; // care only about the whole frame
|
|
|
|
bool new_not_obscured = e->state == VisibilityUnobscured;
|
|
|
|
if( not_obscured == new_not_obscured )
|
|
|
|
return;
|
|
|
|
not_obscured = new_not_obscured;
|
|
|
|
updateMouseGrab();
|
|
|
|
}
|
|
|
|
|
|
|
|
// performs _NET_WM_MOVERESIZE
|
|
|
|
void Client::NETMoveResize( int x_root, int y_root, NET::Direction direction )
|
|
|
|
{
|
|
|
|
if( direction == NET::Move )
|
|
|
|
performMouseCommand( Options::MouseMove, QPoint( x_root, y_root ));
|
2006-01-06 18:20:46 +03:00
|
|
|
else if( moveResizeMode && direction == NET::MoveResizeCancel)
|
|
|
|
{
|
|
|
|
finishMoveResize( true );
|
2006-02-19 04:33:48 +03:00
|
|
|
buttonDown = false;
|
2006-01-06 18:20:46 +03:00
|
|
|
setCursor( mode );
|
|
|
|
}
|
2003-09-16 23:28:03 +04:00
|
|
|
else if( direction >= NET::TopLeft && direction <= NET::Left )
|
|
|
|
{
|
2003-12-15 18:10:17 +03:00
|
|
|
static const Position convert[] =
|
2003-09-16 23:28:03 +04:00
|
|
|
{
|
2003-12-15 18:10:17 +03:00
|
|
|
PositionTopLeft,
|
|
|
|
PositionTop,
|
|
|
|
PositionTopRight,
|
|
|
|
PositionRight,
|
|
|
|
PositionBottomRight,
|
|
|
|
PositionBottom,
|
|
|
|
PositionBottomLeft,
|
|
|
|
PositionLeft
|
2003-09-16 23:28:03 +04:00
|
|
|
};
|
|
|
|
if(!isResizable() || isShade())
|
|
|
|
return;
|
|
|
|
if( moveResizeMode )
|
|
|
|
finishMoveResize( false );
|
2006-02-19 04:33:48 +03:00
|
|
|
buttonDown = true;
|
2003-09-16 23:28:03 +04:00
|
|
|
moveOffset = QPoint( x_root - x(), y_root - y()); // map from global
|
|
|
|
invertedMoveOffset = rect().bottomRight() - moveOffset;
|
|
|
|
unrestrictedMoveResize = false;
|
|
|
|
mode = convert[ direction ];
|
|
|
|
setCursor( mode );
|
2003-11-24 17:24:34 +03:00
|
|
|
if( !startMoveResize())
|
2004-03-05 17:22:11 +03:00
|
|
|
{
|
2003-11-24 17:24:34 +03:00
|
|
|
buttonDown = false;
|
2004-03-05 17:22:11 +03:00
|
|
|
setCursor( mode );
|
|
|
|
}
|
2003-09-16 23:28:03 +04:00
|
|
|
}
|
|
|
|
else if( direction == NET::KeyboardMove )
|
|
|
|
{ // ignore mouse coordinates given in the message, mouse position is used by the moving algorithm
|
|
|
|
QCursor::setPos( geometry().center() );
|
|
|
|
performMouseCommand( Options::MouseUnrestrictedMove, geometry().center());
|
|
|
|
}
|
|
|
|
else if( direction == NET::KeyboardSize )
|
|
|
|
{ // ignore mouse coordinates given in the message, mouse position is used by the resizing algorithm
|
|
|
|
QCursor::setPos( geometry().bottomRight());
|
|
|
|
performMouseCommand( Options::MouseUnrestrictedResize, geometry().bottomRight());
|
|
|
|
}
|
2000-05-08 00:38:11 +04:00
|
|
|
}
|
2000-05-08 08:50:20 +04:00
|
|
|
|
2003-09-29 15:19:39 +04:00
|
|
|
void Client::keyPressEvent( uint key_code )
|
|
|
|
{
|
|
|
|
updateUserTime();
|
|
|
|
if ( !isMove() && !isResize() )
|
|
|
|
return;
|
|
|
|
bool is_control = key_code & Qt::CTRL;
|
2003-09-29 15:19:55 +04:00
|
|
|
bool is_alt = key_code & Qt::ALT;
|
2003-09-29 15:19:39 +04:00
|
|
|
key_code = key_code & 0xffff;
|
2003-09-29 15:19:55 +04:00
|
|
|
int delta = is_control?1:is_alt?32:8;
|
2003-09-29 15:19:39 +04:00
|
|
|
QPoint pos = QCursor::pos();
|
|
|
|
switch ( key_code )
|
|
|
|
{
|
2005-07-28 18:59:42 +04:00
|
|
|
case Qt::Key_Left:
|
2003-09-29 15:19:39 +04:00
|
|
|
pos.rx() -= delta;
|
|
|
|
break;
|
2005-07-28 18:59:42 +04:00
|
|
|
case Qt::Key_Right:
|
2003-09-29 15:19:39 +04:00
|
|
|
pos.rx() += delta;
|
|
|
|
break;
|
2005-07-28 18:59:42 +04:00
|
|
|
case Qt::Key_Up:
|
2003-09-29 15:19:39 +04:00
|
|
|
pos.ry() -= delta;
|
|
|
|
break;
|
2005-07-28 18:59:42 +04:00
|
|
|
case Qt::Key_Down:
|
2003-09-29 15:19:39 +04:00
|
|
|
pos.ry() += delta;
|
|
|
|
break;
|
2005-07-28 18:59:42 +04:00
|
|
|
case Qt::Key_Space:
|
|
|
|
case Qt::Key_Return:
|
|
|
|
case Qt::Key_Enter:
|
2003-09-29 15:19:39 +04:00
|
|
|
finishMoveResize( false );
|
2006-02-19 04:33:48 +03:00
|
|
|
buttonDown = false;
|
2004-03-05 17:22:11 +03:00
|
|
|
setCursor( mode );
|
2003-09-29 15:19:39 +04:00
|
|
|
break;
|
2005-07-28 18:59:42 +04:00
|
|
|
case Qt::Key_Escape:
|
2003-09-29 15:19:39 +04:00
|
|
|
finishMoveResize( true );
|
2006-02-19 04:33:48 +03:00
|
|
|
buttonDown = false;
|
2004-03-05 17:22:11 +03:00
|
|
|
setCursor( mode );
|
2003-09-29 15:19:39 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QCursor::setPos( pos );
|
|
|
|
}
|
|
|
|
|
2006-07-05 00:02:07 +04:00
|
|
|
// ****************************************
|
|
|
|
// Unmanaged
|
|
|
|
// ****************************************
|
|
|
|
|
|
|
|
bool Unmanaged::windowEvent( XEvent* e )
|
|
|
|
{
|
|
|
|
switch (e->type)
|
|
|
|
{
|
|
|
|
case UnmapNotify:
|
|
|
|
unmapNotifyEvent( &e->xunmap );
|
|
|
|
break;
|
|
|
|
case MapNotify:
|
|
|
|
mapNotifyEvent( &e->xmap );
|
|
|
|
break;
|
|
|
|
case ConfigureNotify:
|
|
|
|
configureNotifyEvent( &e->xconfigure );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if( e->type == Extensions::damageNotifyEvent())
|
|
|
|
damageNotifyEvent( reinterpret_cast< XDamageNotifyEvent* >( e ));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return true; // eat all events
|
|
|
|
}
|
|
|
|
|
|
|
|
void Unmanaged::mapNotifyEvent( XMapEvent* )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Unmanaged::unmapNotifyEvent( XUnmapEvent* )
|
|
|
|
{
|
|
|
|
release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Unmanaged::configureNotifyEvent( XConfigureEvent* e )
|
|
|
|
{
|
|
|
|
resetWindowPixmap();
|
2006-07-05 20:04:11 +04:00
|
|
|
// add old and new geometry to damage
|
|
|
|
workspace()->addDamage( geometry());
|
|
|
|
geom = QRect( e->x, e->y, e->width, e->height );
|
|
|
|
workspace()->addDamage( geometry());
|
2006-07-05 00:02:07 +04:00
|
|
|
}
|
|
|
|
|
2004-02-25 12:51:47 +03:00
|
|
|
// ****************************************
|
|
|
|
// Group
|
|
|
|
// ****************************************
|
|
|
|
|
|
|
|
bool Group::groupEvent( XEvent* e )
|
|
|
|
{
|
|
|
|
unsigned long dirty[ 2 ];
|
|
|
|
leader_info->event( e, dirty, 2 ); // pass through the NET stuff
|
|
|
|
if ( ( dirty[ WinInfo::PROTOCOLS ] & NET::WMIcon) != 0 )
|
|
|
|
getIcons();
|
|
|
|
if(( dirty[ WinInfo::PROTOCOLS2 ] & NET::WM2StartupId ) != 0 )
|
|
|
|
startupIdChanged();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2000-05-08 08:50:20 +04:00
|
|
|
|
2003-09-16 23:28:03 +04:00
|
|
|
} // namespace
|