2000-03-24 22:23:02 +00:00
|
|
|
/*****************************************************************
|
|
|
|
kwin - the KDE window manager
|
|
|
|
|
|
|
|
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
|
|
|
******************************************************************/
|
2000-07-29 07:59:24 +00:00
|
|
|
//#define QT_CLEAN_NAMESPACE
|
1999-11-28 20:58:58 +00:00
|
|
|
#include <klocale.h>
|
2000-04-08 19:35:52 +00:00
|
|
|
#include <kapp.h>
|
2000-06-06 19:44:21 +00:00
|
|
|
#include <kdebug.h>
|
2000-04-08 19:35:52 +00:00
|
|
|
#include <dcopclient.h>
|
1999-08-19 23:26:42 +00:00
|
|
|
#include <qapplication.h>
|
|
|
|
#include <qcursor.h>
|
|
|
|
#include <qbitmap.h>
|
1999-09-27 16:02:44 +00:00
|
|
|
#include <qimage.h>
|
1999-08-19 23:26:42 +00:00
|
|
|
#include <qwmatrix.h>
|
|
|
|
#include <qlayout.h>
|
1999-09-27 16:02:44 +00:00
|
|
|
#include <qpainter.h>
|
1999-12-01 22:09:32 +00:00
|
|
|
#include <qwhatsthis.h>
|
2000-06-23 16:26:44 +00:00
|
|
|
#include <qdatetime.h>
|
2000-05-07 23:10:21 +00:00
|
|
|
#include <qtimer.h>
|
2000-06-08 17:05:51 +00:00
|
|
|
#include <kwin.h>
|
|
|
|
#include <netwm.h>
|
1999-08-19 23:26:42 +00:00
|
|
|
#include "workspace.h"
|
|
|
|
#include "client.h"
|
2000-05-07 20:38:11 +00:00
|
|
|
#include "events.h"
|
1999-08-19 23:26:42 +00:00
|
|
|
#include "atoms.h"
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xos.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <X11/Xatom.h>
|
1999-11-12 03:11:19 +00:00
|
|
|
#include <X11/extensions/shape.h>
|
1999-08-19 23:26:42 +00:00
|
|
|
|
|
|
|
extern Atom qt_wm_state;
|
1999-11-28 21:41:15 +00:00
|
|
|
extern Time kwin_time;
|
1999-08-19 23:26:42 +00:00
|
|
|
|
1999-12-06 00:43:55 +00:00
|
|
|
static bool resizeHorizontalDirectionFixed = FALSE;
|
|
|
|
static bool resizeVerticalDirectionFixed = FALSE;
|
2000-06-24 17:58:10 +00:00
|
|
|
static bool blockAnimation = FALSE;
|
|
|
|
|
1999-09-27 16:02:44 +00:00
|
|
|
|
|
|
|
static QRect* visible_bound = 0;
|
|
|
|
|
2000-06-08 17:05:51 +00:00
|
|
|
// NET WM Protocol handler class
|
|
|
|
class WinInfo : public NETWinInfo {
|
|
|
|
public:
|
2000-06-10 14:05:47 +00:00
|
|
|
WinInfo(::Client * c, Display * display, Window window,
|
2000-06-08 17:05:51 +00:00
|
|
|
Window rwin, unsigned long pr )
|
|
|
|
: NETWinInfo( display, window, rwin, pr, NET::WindowManager ) {
|
2000-06-10 14:05:47 +00:00
|
|
|
m_client = c;
|
|
|
|
}
|
|
|
|
|
2000-06-24 19:09:50 +00:00
|
|
|
virtual void changeDesktop(int desktop) {
|
2000-06-23 18:56:59 +00:00
|
|
|
if ( desktop == NETWinInfo::OnAllDesktops )
|
|
|
|
m_client->setSticky( TRUE );
|
|
|
|
else
|
|
|
|
m_client->workspace()->sendClientToDesktop( m_client, desktop );
|
2000-06-08 17:05:51 +00:00
|
|
|
}
|
2000-06-24 19:09:50 +00:00
|
|
|
virtual void changeState( unsigned long state, unsigned long mask ) {
|
2000-06-23 16:26:44 +00:00
|
|
|
// state : kwin.h says: possible values are or'ed combinations of NET::Modal,
|
|
|
|
// NET::Sticky, NET::MaxVert, NET::MaxHoriz, NET::Shaded, NET::SkipTaskbar
|
2000-06-10 14:05:47 +00:00
|
|
|
|
2000-06-23 16:26:44 +00:00
|
|
|
state &= mask; // for safety, clear all other bits
|
|
|
|
|
|
|
|
if ( mask & NET::Shaded )
|
|
|
|
m_client->setShade( state & NET::Shaded );
|
|
|
|
|
|
|
|
if ( mask & NET::Max ) {
|
2000-06-23 18:18:34 +00:00
|
|
|
if ( (state & NET::Max) == NET::Max )
|
2000-06-23 16:26:44 +00:00
|
|
|
m_client->maximize( Client::MaximizeFull );
|
|
|
|
else if ( state & NET::MaxVert )
|
|
|
|
m_client->maximize( Client::MaximizeVertical );
|
|
|
|
else if ( state & NET::MaxHoriz )
|
|
|
|
m_client->maximize( Client::MaximizeHorizontal );
|
2000-06-23 18:18:34 +00:00
|
|
|
else
|
|
|
|
m_client->maximize( Client::MaximizeRestore );
|
2000-06-28 13:20:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( mask & NET::StaysOnTop ) {
|
|
|
|
m_client->setStaysOnTop( state & NET::StaysOnTop );
|
|
|
|
m_client->workspace()->raiseClient( m_client );
|
|
|
|
}
|
2000-06-10 14:05:47 +00:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
::Client * m_client;
|
2000-06-08 17:05:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1999-09-27 16:02:44 +00:00
|
|
|
void Client::drawbound( const QRect& geom )
|
|
|
|
{
|
|
|
|
if ( visible_bound )
|
|
|
|
*visible_bound = geom;
|
|
|
|
else
|
|
|
|
visible_bound = new QRect( geom );
|
|
|
|
QPainter p ( workspace()->desktopWidget() );
|
|
|
|
p.setPen( QPen( Qt::white, 5 ) );
|
|
|
|
p.setRasterOp( Qt::XorROP );
|
|
|
|
p.drawRect( geom );
|
|
|
|
}
|
1999-11-12 03:11:19 +00:00
|
|
|
|
1999-09-27 16:02:44 +00:00
|
|
|
void Client::clearbound()
|
|
|
|
{
|
|
|
|
if ( !visible_bound )
|
|
|
|
return;
|
|
|
|
drawbound( *visible_bound );
|
|
|
|
delete visible_bound;
|
|
|
|
visible_bound = 0;
|
|
|
|
}
|
|
|
|
|
1999-11-12 03:11:19 +00:00
|
|
|
void Client::updateShape()
|
|
|
|
{
|
1999-11-14 06:34:28 +00:00
|
|
|
if ( shape() )
|
1999-11-12 03:11:19 +00:00
|
|
|
XShapeCombineShape(qt_xdisplay(), winId(), ShapeBounding,
|
|
|
|
windowWrapper()->x(), windowWrapper()->y(),
|
|
|
|
window(), ShapeBounding, ShapeSet);
|
1999-11-14 06:34:28 +00:00
|
|
|
else
|
1999-11-12 03:11:19 +00:00
|
|
|
XShapeCombineMask( qt_xdisplay(), winId(), ShapeBounding, 0, 0,
|
|
|
|
None, ShapeSet);
|
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
|
|
|
|
static void sendClientMessage(Window w, Atom a, long x){
|
|
|
|
XEvent ev;
|
|
|
|
long mask;
|
|
|
|
|
|
|
|
memset(&ev, 0, sizeof(ev));
|
|
|
|
ev.xclient.type = ClientMessage;
|
|
|
|
ev.xclient.window = w;
|
|
|
|
ev.xclient.message_type = a;
|
|
|
|
ev.xclient.format = 32;
|
|
|
|
ev.xclient.data.l[0] = x;
|
1999-11-28 21:41:15 +00:00
|
|
|
ev.xclient.data.l[1] = kwin_time;
|
1999-08-19 23:26:42 +00:00
|
|
|
mask = 0L;
|
|
|
|
if (w == qt_xrootwin())
|
|
|
|
mask = SubstructureRedirectMask; /* magic! */
|
|
|
|
XSendEvent(qt_xdisplay(), w, False, mask, &ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\class WindowWrapper client.h
|
|
|
|
|
|
|
|
\brief The WindowWrapper class encapsulates a client's managed
|
|
|
|
window.
|
|
|
|
|
|
|
|
There's not much to know about this class, it's completley handled by
|
|
|
|
the abstract class Client. You get access to the window wrapper with
|
1999-12-06 00:43:55 +00:00
|
|
|
Client::windowWrapper(). The big advantage of WindowWrapper is,
|
1999-08-19 23:26:42 +00:00
|
|
|
that you can use just like a normal QWidget, although it encapsulates
|
|
|
|
an X window that belongs to another application.
|
|
|
|
|
|
|
|
In particular, this means adding a client's windowWrapper() to a
|
|
|
|
QLayout for the geometry management. See StdClient for an example
|
|
|
|
on how to do this.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
WindowWrapper::WindowWrapper( WId w, Client *parent, const char* name)
|
|
|
|
: QWidget( parent, name )
|
|
|
|
{
|
|
|
|
win = w;
|
2000-05-08 20:22:10 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
setMouseTracking( TRUE );
|
|
|
|
|
1999-11-22 01:57:51 +00:00
|
|
|
setBackgroundColor( colorGroup().background() );
|
1999-11-25 12:53:17 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
// we don't want the window to be destroyed when we are destroyed
|
|
|
|
XAddToSaveSet(qt_xdisplay(), win );
|
|
|
|
|
2000-03-22 14:29:10 +00:00
|
|
|
// no need to be mapped at this point
|
|
|
|
XUnmapWindow( qt_xdisplay(), win );
|
2000-03-24 22:23:02 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
// set the border width to 0
|
|
|
|
XWindowChanges wc;
|
|
|
|
wc.border_width = 0;
|
|
|
|
XConfigureWindow( qt_xdisplay(), win, CWBorderWidth, &wc );
|
|
|
|
|
2000-03-22 14:29:10 +00:00
|
|
|
// overwrite Qt-defaults because we need SubstructureNotifyMask
|
|
|
|
XSelectInput( qt_xdisplay(), winId(),
|
|
|
|
KeyPressMask | KeyReleaseMask |
|
|
|
|
ButtonPressMask | ButtonReleaseMask |
|
|
|
|
KeymapStateMask |
|
|
|
|
ButtonMotionMask |
|
|
|
|
PointerMotionMask | // need this, too!
|
|
|
|
EnterWindowMask | LeaveWindowMask |
|
|
|
|
FocusChangeMask |
|
|
|
|
ExposureMask |
|
|
|
|
StructureNotifyMask |
|
|
|
|
SubstructureRedirectMask |
|
|
|
|
SubstructureNotifyMask
|
|
|
|
);
|
|
|
|
|
|
|
|
XSelectInput( qt_xdisplay(), w,
|
|
|
|
FocusChangeMask |
|
2000-08-13 17:07:26 +00:00
|
|
|
PropertyChangeMask |
|
|
|
|
EnterWindowMask | LeaveWindowMask
|
2000-03-22 14:29:10 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// install a passive grab to catch mouse button events
|
|
|
|
XGrabButton(qt_xdisplay(), AnyButton, AnyModifier, winId(), FALSE,
|
|
|
|
ButtonPressMask,
|
|
|
|
GrabModeSync, GrabModeAsync,
|
|
|
|
None, None );
|
|
|
|
|
|
|
|
reparented = FALSE;
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
WindowWrapper::~WindowWrapper()
|
|
|
|
{
|
|
|
|
releaseWindow();
|
|
|
|
}
|
|
|
|
|
2000-03-29 14:53:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void ungrabButton( WId winId, int modifier )
|
|
|
|
{
|
|
|
|
XUngrabButton( qt_xdisplay(), AnyButton, modifier, winId );
|
|
|
|
XUngrabButton( qt_xdisplay(), AnyButton, modifier | LockMask, winId );
|
|
|
|
}
|
|
|
|
|
2000-05-07 20:38:11 +00:00
|
|
|
/*!
|
2000-03-29 14:53:25 +00:00
|
|
|
Called by the client to notify the window wrapper when activation
|
|
|
|
state changes.
|
2000-05-07 20:38:11 +00:00
|
|
|
|
2000-03-29 14:53:25 +00:00
|
|
|
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 WindowWrapper::setActive( bool active )
|
|
|
|
{
|
|
|
|
if ( active ) {
|
2000-07-09 20:29:53 +00:00
|
|
|
if ( options->focusPolicy == Options::ClickToFocus || !options->clickRaise )
|
|
|
|
ungrabButton( winId(), None );
|
2000-03-29 14:53:25 +00:00
|
|
|
ungrabButton( winId(), ShiftMask );
|
|
|
|
ungrabButton( winId(), ControlMask );
|
|
|
|
ungrabButton( winId(), ControlMask | ShiftMask );
|
|
|
|
} else {
|
|
|
|
XGrabButton(qt_xdisplay(), AnyButton, AnyModifier, winId(), FALSE,
|
|
|
|
ButtonPressMask,
|
|
|
|
GrabModeSync, GrabModeAsync,
|
|
|
|
None, None );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
QSize WindowWrapper::sizeHint() const
|
|
|
|
{
|
|
|
|
return size();
|
|
|
|
}
|
|
|
|
|
|
|
|
QSizePolicy WindowWrapper::sizePolicy() const
|
|
|
|
{
|
|
|
|
return QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WindowWrapper::resizeEvent( QResizeEvent * )
|
|
|
|
{
|
2000-03-22 11:47:10 +00:00
|
|
|
if ( win && reparented ) {
|
2000-05-09 10:13:48 +00:00
|
|
|
XMoveResizeWindow( qt_xdisplay(), win,
|
|
|
|
0, 0, width(), height() );
|
1999-11-12 03:11:19 +00:00
|
|
|
if ( ((Client*)parentWidget())->shape() )
|
|
|
|
((Client*)parentWidget())->updateShape();
|
|
|
|
}
|
1999-11-07 04:43:59 +00:00
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
|
|
|
|
void WindowWrapper::showEvent( QShowEvent* )
|
|
|
|
{
|
|
|
|
if ( win ) {
|
2000-03-22 11:47:10 +00:00
|
|
|
if ( !reparented ) {
|
2000-03-22 14:29:10 +00:00
|
|
|
// get the window. We do it this late in order to
|
|
|
|
// guarantee that our geometry is final. This allows
|
|
|
|
// toolkits to guess the proper frame geometry when
|
|
|
|
// processing the ReparentNotify event from X.
|
2000-03-22 11:47:10 +00:00
|
|
|
XReparentWindow( qt_xdisplay(), win, winId(), 0, 0 );
|
|
|
|
reparented = TRUE;
|
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
XMoveResizeWindow( qt_xdisplay(), win,
|
|
|
|
0, 0, width(), height() );
|
|
|
|
XMapRaised( qt_xdisplay(), win );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void WindowWrapper::hideEvent( QHideEvent* )
|
|
|
|
{
|
|
|
|
if ( win )
|
1999-11-15 00:52:05 +00:00
|
|
|
XUnmapWindow( qt_xdisplay(), win );
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WindowWrapper::invalidateWindow()
|
|
|
|
{
|
|
|
|
win = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Releases the window. The client has done its job and the window is still existing.
|
|
|
|
*/
|
|
|
|
void WindowWrapper::releaseWindow()
|
|
|
|
{
|
|
|
|
if ( win ) {
|
2000-03-22 11:47:10 +00:00
|
|
|
if ( reparented ) {
|
|
|
|
XReparentWindow( qt_xdisplay(), win,
|
|
|
|
((Client*)parentWidget())->workspace()->rootWin(),
|
|
|
|
parentWidget()->x(),
|
|
|
|
parentWidget()->y() );
|
|
|
|
}
|
2000-03-21 20:02:27 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
XRemoveFromSaveSet(qt_xdisplay(), win );
|
|
|
|
invalidateWindow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool WindowWrapper::x11Event( XEvent * e)
|
|
|
|
{
|
|
|
|
switch ( e->type ) {
|
|
|
|
case ButtonPress:
|
1999-11-29 02:06:41 +00:00
|
|
|
{
|
2000-07-09 20:29:53 +00:00
|
|
|
if ( ((Client*)parentWidget())->isActive()
|
|
|
|
&& ( options->focusPolicy != Options::ClickToFocus && options->clickRaise ) ) {
|
2000-07-10 21:48:13 +00:00
|
|
|
((Client*)parentWidget())->autoRaise();
|
2000-07-09 20:29:53 +00:00
|
|
|
ungrabButton( winId(), None );
|
|
|
|
}
|
|
|
|
|
1999-11-29 02:06:41 +00:00
|
|
|
bool mod1 = (e->xbutton.state & Mod1Mask) == Mod1Mask;
|
|
|
|
Options::MouseCommand com = Options::MouseNothing;
|
|
|
|
if ( mod1){
|
|
|
|
switch (e->xbutton.button) {
|
|
|
|
case Button1:
|
|
|
|
com = options->commandAll1();
|
2000-03-21 20:02:27 +00:00
|
|
|
break;
|
|
|
|
case Button2:
|
1999-11-29 02:06:41 +00:00
|
|
|
com = options->commandAll2();
|
|
|
|
break;
|
|
|
|
case Button3:
|
|
|
|
com = options->commandAll3();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (e->xbutton.button) {
|
|
|
|
case Button1:
|
|
|
|
com = options->commandWindow1();
|
2000-03-21 20:02:27 +00:00
|
|
|
break;
|
|
|
|
case Button2:
|
1999-11-29 02:06:41 +00:00
|
|
|
com = options->commandWindow2();
|
|
|
|
break;
|
|
|
|
case Button3:
|
|
|
|
com = options->commandWindow3();
|
|
|
|
break;
|
1999-11-29 14:19:32 +00:00
|
|
|
default:
|
1999-11-29 02:06:41 +00:00
|
|
|
com = Options::MouseActivateAndPassClick;
|
|
|
|
}
|
|
|
|
}
|
1999-11-29 14:19:32 +00:00
|
|
|
bool replay = ( (Client*)parentWidget() )->performMouseCommand( com,
|
1999-11-29 02:06:41 +00:00
|
|
|
QPoint( e->xbutton.x_root, e->xbutton.y_root) );
|
2000-03-21 20:02:27 +00:00
|
|
|
|
1999-11-29 02:06:41 +00:00
|
|
|
XAllowEvents(qt_xdisplay(), replay? ReplayPointer : SyncPointer, kwin_time);
|
1999-08-19 23:26:42 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
1999-11-29 14:19:32 +00:00
|
|
|
case ButtonRelease:
|
1999-11-29 02:06:41 +00:00
|
|
|
XAllowEvents(qt_xdisplay(), SyncPointer, kwin_time);
|
1999-08-19 23:26:42 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-27 16:02:44 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
/*!
|
|
|
|
\class Client client.h
|
|
|
|
|
|
|
|
\brief The Client class encapsulates a window decoration frame.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Creates a client on workspace \a ws for window \a w.
|
|
|
|
*/
|
|
|
|
Client::Client( Workspace *ws, WId w, QWidget *parent, const char *name, WFlags f )
|
2000-05-26 13:54:50 +00:00
|
|
|
: QWidget( parent, name, f | WStyle_Customize | WStyle_NoBorder )
|
1999-08-19 23:26:42 +00:00
|
|
|
{
|
|
|
|
wspace = ws;
|
|
|
|
win = w;
|
2000-07-09 20:29:53 +00:00
|
|
|
autoRaiseTimer = 0;
|
2000-06-08 17:05:51 +00:00
|
|
|
|
|
|
|
unsigned long properties =
|
|
|
|
NET::WMDesktop |
|
|
|
|
NET::WMState |
|
|
|
|
NET::WMWindowType |
|
|
|
|
NET::WMStrut |
|
2000-06-23 16:26:44 +00:00
|
|
|
NET::WMName |
|
|
|
|
NET::WMIconGeometry
|
2000-06-08 17:05:51 +00:00
|
|
|
;
|
|
|
|
|
2000-06-10 14:05:47 +00:00
|
|
|
info = new WinInfo( this, qt_xdisplay(), win, qt_xrootwin(), properties );
|
2000-06-08 17:05:51 +00:00
|
|
|
|
1999-11-15 00:52:05 +00:00
|
|
|
mapped = 0;
|
1999-08-19 23:26:42 +00:00
|
|
|
wwrap = new WindowWrapper( w, this );
|
|
|
|
wwrap->installEventFilter( this );
|
|
|
|
|
|
|
|
// set the initial mapping state
|
|
|
|
setMappingState( WithdrawnState );
|
|
|
|
desk = -1; // and no desktop yet
|
|
|
|
|
|
|
|
mode = Nowhere;
|
|
|
|
buttonDown = FALSE;
|
1999-09-27 16:02:44 +00:00
|
|
|
moveResizeMode = FALSE;
|
1999-08-19 23:26:42 +00:00
|
|
|
setMouseTracking( TRUE );
|
|
|
|
|
|
|
|
active = FALSE;
|
|
|
|
shaded = FALSE;
|
|
|
|
transient_for = None;
|
2000-08-10 13:01:12 +00:00
|
|
|
transient_for_defined = FALSE;
|
1999-11-12 03:11:19 +00:00
|
|
|
is_shape = FALSE;
|
1999-11-12 03:21:10 +00:00
|
|
|
is_sticky = FALSE;
|
2000-06-28 13:20:42 +00:00
|
|
|
stays_on_top = FALSE;
|
2000-04-19 04:36:47 +00:00
|
|
|
may_move = TRUE;
|
2000-08-09 10:02:56 +00:00
|
|
|
skip_taskbar = FALSE;
|
1999-08-19 23:26:42 +00:00
|
|
|
|
1999-11-28 20:10:58 +00:00
|
|
|
getWMHints();
|
1999-08-19 23:26:42 +00:00
|
|
|
getWindowProtocols();
|
|
|
|
getWmNormalHints(); // get xSizeHint
|
|
|
|
fetchName();
|
|
|
|
|
2000-06-29 19:15:00 +00:00
|
|
|
Window ww;
|
|
|
|
if ( !XGetTransientForHint( qt_xdisplay(), (Window) win, &ww ) )
|
1999-08-19 23:26:42 +00:00
|
|
|
transient_for = None;
|
2000-08-10 13:01:12 +00:00
|
|
|
else {
|
2000-06-29 19:15:00 +00:00
|
|
|
transient_for = (WId) ww;
|
2000-08-10 13:01:12 +00:00
|
|
|
transient_for_defined = TRUE;
|
|
|
|
}
|
2000-03-06 19:14:20 +00:00
|
|
|
|
2000-01-10 03:49:49 +00:00
|
|
|
if ( mainClient()->isSticky() )
|
|
|
|
setSticky( TRUE );
|
2000-03-06 19:14:20 +00:00
|
|
|
|
2000-07-16 21:12:33 +00:00
|
|
|
// window wants to stay on top?
|
2000-08-10 13:01:12 +00:00
|
|
|
stays_on_top = ( info->state() & NET::StaysOnTop) != 0 || ( transient_for == None && transient_for_defined );
|
2000-08-09 12:58:12 +00:00
|
|
|
|
2000-08-09 10:02:56 +00:00
|
|
|
// window does not want a taskbar entry?
|
|
|
|
skip_taskbar = ( info->state() & NET::SkipTaskbar) != 0;
|
2000-07-16 23:40:21 +00:00
|
|
|
|
2000-06-08 01:33:53 +00:00
|
|
|
|
|
|
|
// should we open this window on a certain desktop?
|
2000-06-28 13:20:42 +00:00
|
|
|
if ( info->desktop() == NETWinInfo::OnAllDesktops )
|
|
|
|
setSticky( TRUE );
|
2000-07-09 20:29:53 +00:00
|
|
|
else if ( info->desktop() )
|
2000-07-16 21:12:33 +00:00
|
|
|
desk = info->desktop(); // window had the initial desktop property!
|
2000-06-08 01:33:53 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Destructor, nothing special.
|
|
|
|
*/
|
|
|
|
Client::~Client()
|
|
|
|
{
|
|
|
|
releaseWindow();
|
2000-06-02 00:20:41 +00:00
|
|
|
if (workspace()->activeClient() == this)
|
2000-07-11 11:41:52 +00:00
|
|
|
workspace()->setFocusChangeEnabled(true); // Safety
|
2000-06-08 17:05:51 +00:00
|
|
|
|
|
|
|
delete info;
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Manages the clients. This means handling the very first maprequest:
|
|
|
|
reparenting, initial geometry, initial state, placement, etc.
|
|
|
|
*/
|
2000-07-15 01:12:41 +00:00
|
|
|
bool Client::manage( bool isMapped, bool doNotShow )
|
1999-08-19 23:26:42 +00:00
|
|
|
{
|
|
|
|
|
2000-05-10 23:44:29 +00:00
|
|
|
if (layout())
|
|
|
|
layout()->setResizeMode( QLayout::Minimum );
|
2000-07-27 17:58:09 +00:00
|
|
|
|
2000-07-19 01:26:00 +00:00
|
|
|
XWindowAttributes attr;
|
|
|
|
if (XGetWindowAttributes(qt_xdisplay(), win, &attr))
|
|
|
|
original_geometry.setRect(attr.x, attr.y, attr.width, attr.height );
|
2000-07-27 17:58:09 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
QRect geom( original_geometry );
|
|
|
|
bool placementDone = FALSE;
|
2000-08-10 12:38:37 +00:00
|
|
|
|
2000-06-08 17:05:51 +00:00
|
|
|
SessionInfo* session = workspace()->takeSessionInfo( this );
|
|
|
|
if ( session )
|
|
|
|
geom.setRect( session->x, session->y, session->width, session->height );
|
2000-03-24 22:23:02 +00:00
|
|
|
|
2000-08-21 17:37:10 +00:00
|
|
|
QRect area = workspace()->clientArea();
|
2000-08-21 19:09:23 +00:00
|
|
|
|
2000-08-01 16:44:15 +00:00
|
|
|
if ( isMapped || session || isTransient() ) {
|
1999-08-19 23:26:42 +00:00
|
|
|
placementDone = TRUE;
|
2000-08-16 12:18:56 +00:00
|
|
|
if ( geom == workspace()->geometry() )
|
2000-08-01 16:44:15 +00:00
|
|
|
may_move = FALSE; // don't let fullscreen windows be moved around
|
|
|
|
} else {
|
1999-11-25 16:05:27 +00:00
|
|
|
if ( (xSizeHint.flags & PPosition) || (xSizeHint.flags & USPosition) ) {
|
2000-08-09 12:58:12 +00:00
|
|
|
placementDone = TRUE;
|
2000-08-10 12:13:36 +00:00
|
|
|
if ( windowType() == NET::Normal && !area.contains( geom.topLeft() ) ) {
|
2000-08-09 10:02:56 +00:00
|
|
|
int tx = geom.x();
|
|
|
|
int ty = geom.y();
|
|
|
|
if ( tx >= 0 && tx < area.x() )
|
2000-07-13 20:31:36 +00:00
|
|
|
tx = area.x();
|
2000-08-09 10:02:56 +00:00
|
|
|
if ( ty >= 0 && ty < area.y() )
|
|
|
|
ty = area.y();
|
2000-08-10 12:13:36 +00:00
|
|
|
if ( tx > area.right() || ty > area.bottom() )
|
2000-08-09 12:58:12 +00:00
|
|
|
placementDone = FALSE; // weird, do not trust.
|
|
|
|
else
|
|
|
|
geom.moveTopLeft( QPoint( tx, ty ) );
|
2000-07-13 20:31:36 +00:00
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
1999-11-30 00:29:34 +00:00
|
|
|
if ( (xSizeHint.flags & USSize) || (xSizeHint.flags & PSize) ) {
|
|
|
|
// keep in mind that we now actually have a size :-)
|
|
|
|
}
|
1999-11-25 16:05:27 +00:00
|
|
|
if (xSizeHint.flags & PMaxSize)
|
|
|
|
geom.setSize( geom.size().boundedTo( QSize(xSizeHint.max_width, xSizeHint.max_height ) ) );
|
|
|
|
if (xSizeHint.flags & PMinSize)
|
|
|
|
geom.setSize( geom.size().expandedTo( QSize(xSizeHint.min_width, xSizeHint.min_height ) ) );
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
1999-11-25 12:53:17 +00:00
|
|
|
windowWrapper()->resize( geom.size() );
|
1999-08-19 23:26:42 +00:00
|
|
|
// the clever activate() trick is necessary
|
2000-05-11 03:31:54 +00:00
|
|
|
activateLayout();
|
1999-08-19 23:26:42 +00:00
|
|
|
resize ( sizeForWindowSize( geom.size() ) );
|
2000-05-11 03:31:54 +00:00
|
|
|
activateLayout();
|
2000-07-14 20:51:15 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
|
|
|
|
move( geom.x(), geom.y() );
|
|
|
|
gravitate( FALSE );
|
2000-08-21 19:09:23 +00:00
|
|
|
|
1999-11-25 16:05:27 +00:00
|
|
|
if ( !placementDone ) {
|
1999-08-19 23:26:42 +00:00
|
|
|
workspace()->doPlacement( this );
|
|
|
|
placementDone = TRUE;
|
2000-08-21 17:37:10 +00:00
|
|
|
} else if ( windowType() == NET::Normal ) {
|
|
|
|
if ( geometry().right() > area.right() && width() < area.width() )
|
|
|
|
move( area.right() - width(), y() );
|
|
|
|
if ( geometry().bottom() > area.bottom() && height() < area.height() )
|
|
|
|
move( x(), area.bottom() - height() );
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
1999-11-12 03:11:19 +00:00
|
|
|
if ( (is_shape = Shape::hasShape( win )) ) {
|
|
|
|
updateShape();
|
|
|
|
}
|
1999-11-14 06:34:28 +00:00
|
|
|
|
2000-03-24 22:23:02 +00:00
|
|
|
// initial state
|
1999-11-16 01:25:42 +00:00
|
|
|
int state = NormalState;
|
2000-06-08 17:05:51 +00:00
|
|
|
if ( session ) {
|
|
|
|
if ( session->iconified )
|
2000-03-24 22:23:02 +00:00
|
|
|
state = IconicState;
|
|
|
|
} else {
|
|
|
|
// find out the initial state. Several possibilities exist
|
|
|
|
XWMHints * hints = XGetWMHints(qt_xdisplay(), win );
|
|
|
|
if (hints && (hints->flags & StateHint))
|
|
|
|
state = hints->initial_state;
|
|
|
|
if (hints)
|
|
|
|
XFree(hints);
|
|
|
|
}
|
|
|
|
|
2000-06-08 01:33:53 +00:00
|
|
|
// initial desktop placement - note we don't clobber desk if it is
|
|
|
|
// set to some value, in case the initial desktop code in the
|
|
|
|
// constructor has already set a value for us
|
2000-06-08 17:05:51 +00:00
|
|
|
if ( session ) {
|
|
|
|
desk = session->desktop;
|
|
|
|
} else if ( desk <= 0 ) {
|
2000-07-16 21:12:33 +00:00
|
|
|
// if this window is transient, ensure that it is opened on the
|
|
|
|
// same window as its parent. this is necessary when an application
|
|
|
|
// starts up on a different desktop than is currently displayed
|
|
|
|
//
|
2000-08-21 17:37:10 +00:00
|
|
|
if ( isTransient() && !mainClient()->isSticky() )
|
2000-07-16 21:12:33 +00:00
|
|
|
desk = mainClient()->desktop();
|
|
|
|
|
|
|
|
if ( desk <= 0 ) {
|
|
|
|
// assume window wants to be visible on the current desktop
|
|
|
|
desk = workspace()->currentDesktop();
|
|
|
|
} else if ( !isMapped && !doNotShow && desk != workspace()->currentDesktop() ) {
|
|
|
|
//window didn't specify any specific desktop but will appear
|
2000-07-16 23:40:21 +00:00
|
|
|
//somewhere else. This happens for example with "save data?"
|
2000-07-16 21:12:33 +00:00
|
|
|
//dialogs on shutdown. Switch to the respective desktop in
|
|
|
|
//that case.
|
|
|
|
workspace()->setCurrentDesktop( desk );
|
|
|
|
}
|
2000-03-24 22:23:02 +00:00
|
|
|
}
|
2000-06-10 14:05:47 +00:00
|
|
|
|
2000-06-08 17:05:51 +00:00
|
|
|
info->setDesktop( desk );
|
2000-07-15 01:12:41 +00:00
|
|
|
|
2000-03-25 14:14:34 +00:00
|
|
|
|
1999-11-16 01:25:42 +00:00
|
|
|
setMappingState( state );
|
2000-07-15 01:12:41 +00:00
|
|
|
|
2000-07-15 00:46:38 +00:00
|
|
|
bool showMe = state == NormalState && isOnDesktop( workspace()->currentDesktop() );
|
2000-07-16 21:12:33 +00:00
|
|
|
|
2000-07-15 01:12:41 +00:00
|
|
|
if ( workspace()->isNotManaged( caption() ) )
|
|
|
|
doNotShow = TRUE;
|
|
|
|
|
|
|
|
if ( showMe && !doNotShow ) {
|
2000-05-07 20:38:11 +00:00
|
|
|
Events::raise( isTransient() ? Events::TransNew : Events::New );
|
2000-07-15 00:46:38 +00:00
|
|
|
if ( isMapped ) {
|
|
|
|
show();
|
|
|
|
} else {
|
|
|
|
workspace()->raiseClient( this ); // ensure constrains
|
|
|
|
show();
|
|
|
|
if ( options->focusPolicyIsReasonable() && wantsTabFocus() )
|
|
|
|
workspace()->requestFocus( this );
|
|
|
|
}
|
2000-03-24 22:23:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// other settings from the previous session
|
2000-06-08 17:05:51 +00:00
|
|
|
if ( session ) {
|
|
|
|
setSticky( session->sticky );
|
2000-03-24 22:23:02 +00:00
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
|
2000-06-08 17:05:51 +00:00
|
|
|
delete session;
|
2000-07-15 01:12:41 +00:00
|
|
|
|
|
|
|
if ( !doNotShow )
|
2000-07-15 00:46:38 +00:00
|
|
|
workspace()->updateClientArea();
|
2000-07-15 01:12:41 +00:00
|
|
|
|
2000-07-15 00:46:38 +00:00
|
|
|
return showMe;
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Gets the client's normal WM hints and reconfigures itself respectively.
|
|
|
|
*/
|
|
|
|
void Client::getWmNormalHints()
|
|
|
|
{
|
|
|
|
// TODO keep in mind changing of fix size! if !isWithdrawn()!
|
|
|
|
long msize;
|
1999-11-13 03:48:58 +00:00
|
|
|
if (XGetWMNormalHints(qt_xdisplay(), win, &xSizeHint, &msize) == 0 )
|
|
|
|
xSizeHint.flags = 0;
|
2000-08-21 17:37:10 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Fetches the window's caption (WM_NAME property). It will be
|
|
|
|
stored in the client's caption().
|
|
|
|
*/
|
|
|
|
void Client::fetchName()
|
|
|
|
{
|
2000-06-08 17:05:51 +00:00
|
|
|
QString s;
|
2000-07-14 20:51:15 +00:00
|
|
|
|
2000-07-14 19:35:23 +00:00
|
|
|
if ( info->name() ) {
|
|
|
|
s = QString::fromUtf8( info->name() );
|
|
|
|
} else {
|
|
|
|
char* c = 0;
|
|
|
|
if ( XFetchName( qt_xdisplay(), win, &c ) != 0 ) {
|
|
|
|
s = QString::fromLocal8Bit( c );
|
|
|
|
XFree( c );
|
|
|
|
}
|
2000-06-08 17:05:51 +00:00
|
|
|
}
|
1999-11-29 14:19:32 +00:00
|
|
|
|
1999-11-28 20:58:58 +00:00
|
|
|
if ( s != caption() ) {
|
|
|
|
setCaption( "" );
|
|
|
|
if (workspace()->hasCaption( s ) ){
|
|
|
|
int i = 2;
|
|
|
|
QString s2;
|
|
|
|
do {
|
|
|
|
s2 = s + " <" + QString::number(i) + ">";
|
|
|
|
i++;
|
|
|
|
} while (workspace()->hasCaption(s2) );
|
|
|
|
s = s2;
|
|
|
|
}
|
|
|
|
setCaption( s );
|
2000-06-08 17:05:51 +00:00
|
|
|
|
|
|
|
info->setVisibleName( s.utf8() );
|
1999-11-28 20:58:58 +00:00
|
|
|
|
|
|
|
if ( !isWithdrawn() )
|
|
|
|
captionChange( caption() );
|
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets the client window's mapping state. Possible values are
|
|
|
|
WithdrawnState, IconicState, NormalState.
|
|
|
|
*/
|
|
|
|
void Client::setMappingState(int s){
|
|
|
|
if ( !win)
|
|
|
|
return;
|
|
|
|
unsigned long data[2];
|
|
|
|
data[0] = (unsigned long) s;
|
|
|
|
data[1] = (unsigned long) None;
|
|
|
|
|
|
|
|
state = s;
|
|
|
|
XChangeProperty(qt_xdisplay(), win, qt_wm_state, qt_wm_state, 32,
|
|
|
|
PropModeReplace, (unsigned char *)data, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
General handler for XEvents concerning the client window
|
|
|
|
*/
|
|
|
|
bool Client::windowEvent( XEvent * e)
|
|
|
|
{
|
2000-06-08 17:05:51 +00:00
|
|
|
|
|
|
|
unsigned int dirty = info->event( e ); // pass through the NET stuff
|
|
|
|
|
2000-07-14 20:51:15 +00:00
|
|
|
if ( ( dirty & NET::WMName ) != 0 )
|
|
|
|
fetchName();
|
2000-08-04 21:29:02 +00:00
|
|
|
if ( ( dirty & NET::WMStrut ) != 0 )
|
|
|
|
workspace()->updateClientArea();
|
2000-08-09 12:58:12 +00:00
|
|
|
|
2000-06-08 17:05:51 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
switch (e->type) {
|
|
|
|
case UnmapNotify:
|
1999-11-15 00:52:05 +00:00
|
|
|
if ( e->xunmap.window == winId() ) {
|
|
|
|
mapped = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
return unmapNotify( e->xunmap );
|
1999-11-15 00:52:05 +00:00
|
|
|
case MapNotify:
|
|
|
|
if ( e->xmap.window == winId() ) {
|
|
|
|
mapped = 1;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
1999-08-19 23:26:42 +00:00
|
|
|
case MapRequest:
|
|
|
|
return mapRequest( e->xmaprequest );
|
|
|
|
case ConfigureRequest:
|
|
|
|
return configureRequest( e->xconfigurerequest );
|
|
|
|
case PropertyNotify:
|
|
|
|
return propertyNotify( e->xproperty );
|
|
|
|
case ButtonPress:
|
|
|
|
case ButtonRelease:
|
|
|
|
break;
|
|
|
|
case FocusIn:
|
|
|
|
if ( e->xfocus.mode == NotifyUngrab )
|
|
|
|
break; // we don't care
|
|
|
|
if ( e->xfocus.detail == NotifyPointer )
|
|
|
|
break; // we don't care
|
|
|
|
setActive( TRUE );
|
|
|
|
break;
|
|
|
|
case FocusOut:
|
|
|
|
if ( e->xfocus.mode == NotifyGrab )
|
|
|
|
break; // we don't care
|
|
|
|
if ( isShade() )
|
|
|
|
break; // we neither
|
|
|
|
if ( e->xfocus.detail != NotifyNonlinear )
|
|
|
|
return TRUE; // hack for motif apps like netscape
|
|
|
|
setActive( FALSE );
|
|
|
|
break;
|
1999-11-02 00:32:31 +00:00
|
|
|
case ReparentNotify:
|
|
|
|
break;
|
1999-11-28 20:10:58 +00:00
|
|
|
case ClientMessage:
|
|
|
|
return clientMessage( e->xclient );
|
1999-08-19 23:26:42 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE; // we accept everything :-)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles map requests of the client window
|
|
|
|
*/
|
|
|
|
bool Client::mapRequest( XMapRequestEvent& /* e */ )
|
|
|
|
{
|
|
|
|
switch ( mappingState() ) {
|
|
|
|
case WithdrawnState:
|
|
|
|
manage();
|
|
|
|
break;
|
|
|
|
case IconicState:
|
2000-06-24 17:58:10 +00:00
|
|
|
// only show window if we're on current desktop
|
|
|
|
if ( isOnDesktop( workspace()->currentDesktop() ) )
|
|
|
|
show();
|
|
|
|
else
|
|
|
|
setMappingState( NormalState );
|
1999-08-19 23:26:42 +00:00
|
|
|
break;
|
|
|
|
case NormalState:
|
2000-06-08 01:33:53 +00:00
|
|
|
// only show window if we're on current desktop
|
2000-06-08 17:05:51 +00:00
|
|
|
if ( isOnDesktop( workspace()->currentDesktop() ) )
|
|
|
|
show(); // for safety
|
1999-08-19 23:26:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles unmap notify events of the client window
|
|
|
|
*/
|
|
|
|
bool Client::unmapNotify( XUnmapEvent& e )
|
|
|
|
{
|
|
|
|
|
1999-11-15 00:52:05 +00:00
|
|
|
if ( e.event != windowWrapper()->winId() && !e.send_event )
|
|
|
|
return TRUE;
|
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
switch ( mappingState() ) {
|
|
|
|
case IconicState:
|
|
|
|
// only react on sent events, all others are produced by us
|
|
|
|
if ( e.send_event )
|
|
|
|
withdraw();
|
|
|
|
break;
|
|
|
|
case NormalState:
|
1999-11-15 15:57:48 +00:00
|
|
|
if ( ( !mapped || !windowWrapper()->isVisibleTo( this )) && !e.send_event )
|
1999-11-15 00:52:05 +00:00
|
|
|
return TRUE; // this event was produced by us as well
|
1999-08-19 23:26:42 +00:00
|
|
|
|
|
|
|
// maybe we will be destroyed soon. Check this first.
|
|
|
|
XEvent ev;
|
1999-11-16 01:25:42 +00:00
|
|
|
if ( XCheckTypedWindowEvent (qt_xdisplay(), windowWrapper()->winId(),
|
1999-08-19 23:26:42 +00:00
|
|
|
DestroyNotify, &ev) ){
|
|
|
|
workspace()->destroyClient( this );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
// fall through
|
|
|
|
case WithdrawnState: // however that has been possible....
|
|
|
|
withdraw();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Withdraws the window and destroys the client afterwards
|
|
|
|
*/
|
|
|
|
void Client::withdraw()
|
|
|
|
{
|
2000-05-07 20:38:11 +00:00
|
|
|
Events::raise( isTransient() ? Events::TransDelete : Events::Delete );
|
1999-08-19 23:26:42 +00:00
|
|
|
setMappingState( WithdrawnState );
|
2000-07-17 17:10:00 +00:00
|
|
|
info->setDesktop( 0 );
|
|
|
|
desk = 0;
|
1999-08-19 23:26:42 +00:00
|
|
|
releaseWindow();
|
|
|
|
workspace()->destroyClient( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles configure requests of the client window
|
|
|
|
*/
|
|
|
|
bool Client::configureRequest( XConfigureRequestEvent& e )
|
|
|
|
{
|
1999-11-25 16:05:27 +00:00
|
|
|
if ( isResize() )
|
1999-11-26 22:10:25 +00:00
|
|
|
return TRUE; // we have better things to do right now
|
1999-11-25 16:05:27 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
if ( isShade() )
|
|
|
|
setShade( FALSE );
|
|
|
|
|
1999-11-14 05:53:53 +00:00
|
|
|
// compress configure requests
|
|
|
|
XEvent otherEvent;
|
|
|
|
while (XCheckTypedWindowEvent (qt_xdisplay(), win,
|
|
|
|
ConfigureRequest, &otherEvent) ) {
|
|
|
|
if (otherEvent.xconfigurerequest.value_mask == e.value_mask)
|
|
|
|
e = otherEvent.xconfigurerequest;
|
|
|
|
else {
|
|
|
|
XPutBackEvent(qt_xdisplay(), &otherEvent);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-11-14 06:34:28 +00:00
|
|
|
|
2000-05-08 19:37:54 +00:00
|
|
|
bool stacking = e.value_mask & CWStackMode;
|
|
|
|
int stack_mode = e.detail;
|
2000-05-08 21:12:49 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
if ( e.value_mask & CWBorderWidth ) {
|
|
|
|
// first, get rid of a window border
|
|
|
|
XWindowChanges wc;
|
|
|
|
unsigned int value_mask = 0;
|
2000-03-21 20:02:27 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
wc.border_width = 0;
|
|
|
|
value_mask = CWBorderWidth;
|
|
|
|
XConfigureWindow( qt_xdisplay(), win, value_mask, & wc );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( e.value_mask & (CWX | CWY ) ) {
|
2000-08-09 12:06:03 +00:00
|
|
|
int ox = 0;
|
|
|
|
int oy = 0;
|
|
|
|
int gravity = NorthWestGravity;
|
|
|
|
if ( xSizeHint.flags & PWinGravity)
|
|
|
|
gravity = xSizeHint.win_gravity;
|
2000-08-10 12:38:37 +00:00
|
|
|
if ( gravity == StaticGravity ) { // only with StaticGravity according to ICCCM 4.1.5
|
2000-08-09 12:06:03 +00:00
|
|
|
ox = windowWrapper()->x();
|
|
|
|
oy = windowWrapper()->y();
|
|
|
|
}
|
|
|
|
int nx = x() + ox;
|
|
|
|
int ny = y() + oy;
|
1999-08-19 23:26:42 +00:00
|
|
|
if ( e.value_mask & CWX )
|
|
|
|
nx = e.x;
|
|
|
|
if ( e.value_mask & CWY )
|
|
|
|
ny = e.y;
|
2000-08-10 12:13:36 +00:00
|
|
|
QPoint np( nx-ox, ny-oy);
|
|
|
|
if ( windowType() == NET::Normal ) {
|
|
|
|
// crap for broken netscape
|
|
|
|
QRect area = workspace()->clientArea();
|
|
|
|
if ( !area.contains( np ) ){
|
|
|
|
if ( np.x() < area.x() )
|
|
|
|
np.rx() = area.x();
|
|
|
|
if ( np.y() < area.y() )
|
|
|
|
np.ry() = area.y();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
move( np );
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( e.value_mask & (CWWidth | CWHeight ) ) {
|
|
|
|
int nw = windowWrapper()->width();
|
|
|
|
int nh = windowWrapper()->height();
|
|
|
|
if ( e.value_mask & CWWidth )
|
|
|
|
nw = e.width;
|
|
|
|
if ( e.value_mask & CWHeight )
|
|
|
|
nh = e.height;
|
2000-08-09 12:58:12 +00:00
|
|
|
QSize ns = sizeForWindowSize( QSize( nw, nh ) );
|
|
|
|
if ( ns == size() )
|
2000-08-09 18:59:41 +00:00
|
|
|
return TRUE; // broken xemacs stuff (ediff)
|
2000-08-09 12:58:12 +00:00
|
|
|
resize( ns );
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
2000-05-08 21:12:49 +00:00
|
|
|
|
2000-05-08 19:37:54 +00:00
|
|
|
if ( stacking ){
|
|
|
|
switch (stack_mode){
|
|
|
|
case Above:
|
|
|
|
case TopIf:
|
|
|
|
workspace()->raiseClient( this );
|
|
|
|
break;
|
|
|
|
case Below:
|
|
|
|
case BottomIf:
|
|
|
|
workspace()->lowerClient( this );
|
|
|
|
break;
|
|
|
|
case Opposite:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
|
|
|
|
sendSynteticConfigureNotify();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Handles property changes of the client window
|
|
|
|
*/
|
|
|
|
bool Client::propertyNotify( XPropertyEvent& e )
|
|
|
|
{
|
|
|
|
switch ( e.atom ) {
|
|
|
|
case XA_WM_NORMAL_HINTS:
|
|
|
|
getWmNormalHints();
|
|
|
|
break;
|
|
|
|
case XA_WM_NAME:
|
|
|
|
fetchName();
|
|
|
|
break;
|
|
|
|
case XA_WM_TRANSIENT_FOR:
|
2000-06-29 19:15:00 +00:00
|
|
|
Window ww;
|
2000-08-10 13:01:12 +00:00
|
|
|
if ( !XGetTransientForHint( qt_xdisplay(), (Window) win, &ww ) ) {
|
1999-08-19 23:26:42 +00:00
|
|
|
transient_for = None;
|
2000-08-10 13:01:12 +00:00
|
|
|
transient_for_defined = FALSE;
|
|
|
|
} else {
|
2000-06-29 19:15:00 +00:00
|
|
|
transient_for = (WId) ww;
|
2000-08-10 13:01:12 +00:00
|
|
|
transient_for_defined = TRUE;
|
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
break;
|
|
|
|
case XA_WM_HINTS:
|
1999-11-28 20:10:58 +00:00
|
|
|
getWMHints();
|
1999-08-19 23:26:42 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if ( e.atom == atoms->wm_protocols )
|
|
|
|
getWindowProtocols();
|
2000-03-21 20:02:27 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-28 20:10:58 +00:00
|
|
|
/*!
|
|
|
|
Handles client messages for the client window
|
|
|
|
*/
|
|
|
|
bool Client::clientMessage( XClientMessageEvent& e )
|
|
|
|
{
|
2000-06-28 13:20:42 +00:00
|
|
|
|
2000-06-24 17:58:10 +00:00
|
|
|
if ( e.message_type == atoms->kde_wm_change_state ) {
|
|
|
|
if ( e.data.l[0] == IconicState && isNormal() ) {
|
|
|
|
if ( e.data.l[1] )
|
|
|
|
blockAnimation = TRUE;
|
|
|
|
iconify();
|
|
|
|
} else if ( e.data.l[1] == NormalState && isIconified() ) {
|
|
|
|
if ( e.data.l[1] )
|
|
|
|
blockAnimation = TRUE;
|
|
|
|
// only show window if we're on current desktop
|
|
|
|
if ( isOnDesktop( workspace()->currentDesktop() ) )
|
|
|
|
show();
|
|
|
|
else
|
|
|
|
setMappingState( NormalState );
|
|
|
|
}
|
|
|
|
blockAnimation = FALSE;
|
|
|
|
} else if ( e.message_type == atoms->wm_change_state) {
|
2000-06-28 13:20:42 +00:00
|
|
|
if ( e.data.l[0] == IconicState && isNormal() )
|
1999-11-28 20:10:58 +00:00
|
|
|
iconify();
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-11-29 14:19:32 +00:00
|
|
|
|
1999-11-28 20:10:58 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
/*!
|
|
|
|
Auxiliary function to inform the client about the current window
|
|
|
|
configuration.
|
|
|
|
|
|
|
|
*/
|
|
|
|
void Client::sendSynteticConfigureNotify()
|
|
|
|
{
|
|
|
|
XConfigureEvent c;
|
|
|
|
c.type = ConfigureNotify;
|
|
|
|
c.event = win;
|
|
|
|
c.window = win;
|
|
|
|
c.x = x() + windowWrapper()->x();
|
|
|
|
c.y = y() + windowWrapper()->y();
|
|
|
|
c.width = windowWrapper()->width();
|
|
|
|
c.height = windowWrapper()->height();
|
|
|
|
c.border_width = 0;
|
|
|
|
XSendEvent( qt_xdisplay(), c.event, TRUE, NoEventMask, (XEvent*)&c );
|
2000-06-08 17:05:51 +00:00
|
|
|
|
|
|
|
// inform clients about the frame geometry
|
|
|
|
NETStrut strut;
|
|
|
|
QRect wr = windowWrapper()->geometry();
|
|
|
|
QRect mr = rect();
|
|
|
|
strut.left = wr.left();
|
|
|
|
strut.right = mr.right() - wr.right();
|
|
|
|
strut.top = wr.top();
|
|
|
|
strut.bottom = mr.bottom() - wr.bottom();
|
|
|
|
info->setKDEFrameStrut( strut );
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Adjust the frame size \a frame according to he window's size hints.
|
|
|
|
*/
|
|
|
|
QSize Client::adjustedSize( const QSize& frame) const
|
|
|
|
{
|
|
|
|
// first, get the window size for the given frame size s
|
|
|
|
|
|
|
|
QSize wsize( frame.width() - ( width() - wwrap->width() ),
|
|
|
|
frame.height() - ( height() - wwrap->height() ) );
|
|
|
|
|
|
|
|
return sizeForWindowSize( wsize );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Calculate the appropriate frame size for the given window size \a
|
|
|
|
wsize.
|
|
|
|
|
|
|
|
\a wsize is adapted according to the window's size hints (minimum,
|
|
|
|
maximum and incremental size changes).
|
|
|
|
|
|
|
|
*/
|
|
|
|
QSize Client::sizeForWindowSize( const QSize& wsize, bool ignore_height) const
|
|
|
|
{
|
|
|
|
int w = wsize.width();
|
|
|
|
int h = wsize.height();
|
|
|
|
if (w<1) w = 1;
|
|
|
|
if (h<1) h = 1;
|
|
|
|
|
|
|
|
int bw = 0;
|
|
|
|
int bh = 0;
|
|
|
|
|
|
|
|
if (xSizeHint.flags & PBaseSize) {
|
|
|
|
bw = xSizeHint.base_width;
|
|
|
|
bh = xSizeHint.base_height;
|
|
|
|
if (w < xSizeHint.base_width)
|
|
|
|
w = xSizeHint.base_width;
|
|
|
|
if (h < xSizeHint.base_height)
|
|
|
|
h = xSizeHint.base_height;
|
2000-08-21 19:09:23 +00:00
|
|
|
} else if ( xSizeHint.flags & PMinSize ) {
|
|
|
|
bw = xSizeHint.min_width;
|
|
|
|
bh = xSizeHint.min_height;
|
|
|
|
if (w < xSizeHint.min_width)
|
|
|
|
w = xSizeHint.min_width;
|
|
|
|
if (h < xSizeHint.min_height)
|
|
|
|
h = xSizeHint.min_height;
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (xSizeHint.flags & PResizeInc) {
|
|
|
|
if ( xSizeHint.width_inc > 0 ) {
|
|
|
|
int sx = (w - bw) / xSizeHint.width_inc;
|
|
|
|
w = bw + sx * xSizeHint.width_inc;
|
|
|
|
}
|
|
|
|
if ( xSizeHint.height_inc > 0 ) {
|
|
|
|
int sy = (h - bh) / xSizeHint.height_inc;
|
|
|
|
h = bh + sy * xSizeHint.height_inc;
|
|
|
|
}
|
|
|
|
}
|
1999-11-25 16:05:27 +00:00
|
|
|
|
1999-11-25 12:53:17 +00:00
|
|
|
if (xSizeHint.flags & PMaxSize) {
|
1999-11-25 16:05:27 +00:00
|
|
|
w = QMIN( xSizeHint.max_width, w );
|
|
|
|
h = QMIN( xSizeHint.max_height, h );
|
|
|
|
}
|
|
|
|
if (xSizeHint.flags & PMinSize) {
|
|
|
|
w = QMAX( xSizeHint.min_width, w );
|
|
|
|
h = QMAX( xSizeHint.min_height, h );
|
1999-11-25 12:53:17 +00:00
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
|
1999-11-29 02:06:41 +00:00
|
|
|
w = QMAX( minimumWidth(), w );
|
|
|
|
h = QMAX( minimumHeight(), h );
|
1999-11-29 14:19:32 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
int ww = wwrap->width();
|
1999-11-22 02:23:13 +00:00
|
|
|
int wh = 0;
|
1999-08-19 23:26:42 +00:00
|
|
|
if ( !wwrap->testWState( WState_ForceHide ) )
|
1999-11-22 02:23:13 +00:00
|
|
|
wh = wwrap->height();
|
1999-11-25 12:53:17 +00:00
|
|
|
|
1999-11-22 02:23:13 +00:00
|
|
|
if ( ignore_height && wsize.height() == 0 )
|
|
|
|
h = 0;
|
1999-11-22 01:57:51 +00:00
|
|
|
|
1999-11-25 12:53:17 +00:00
|
|
|
return QSize( width() - ww + w, height()-wh+h );
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-13 20:31:36 +00:00
|
|
|
/*!
|
2000-07-13 17:59:12 +00:00
|
|
|
Returns whether the window is resizable or has a fixed size.
|
|
|
|
*/
|
|
|
|
bool Client::isResizable() const
|
|
|
|
{
|
2000-08-01 16:44:15 +00:00
|
|
|
if ( !isMovable() )
|
|
|
|
return FALSE;
|
2000-08-04 21:29:02 +00:00
|
|
|
|
2000-07-13 17:59:12 +00:00
|
|
|
if ( ( xSizeHint.flags & PMaxSize) == 0 || (xSizeHint.flags & PMinSize ) == 0 )
|
|
|
|
return TRUE;
|
|
|
|
return ( xSizeHint.min_width != xSizeHint.max_width ) ||
|
|
|
|
( xSizeHint.min_height != xSizeHint.max_height );
|
|
|
|
}
|
|
|
|
|
2000-08-16 12:18:56 +00:00
|
|
|
/*
|
|
|
|
Returns whether the window is maximizable or not
|
|
|
|
*/
|
|
|
|
bool Client::isMaximizable() const
|
|
|
|
{
|
|
|
|
if ( isMaximized() )
|
|
|
|
return TRUE;
|
|
|
|
return isResizable() && !isTransient();
|
|
|
|
}
|
|
|
|
|
2000-07-13 17:59:12 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
/*!
|
|
|
|
Reimplemented to provide move/resize
|
|
|
|
*/
|
|
|
|
void Client::mousePressEvent( QMouseEvent * e)
|
|
|
|
{
|
2000-05-31 22:26:28 +00:00
|
|
|
if (buttonDown) return;
|
|
|
|
if (e->state() & AltButton)
|
|
|
|
{
|
|
|
|
Options::MouseCommand com = Options::MouseNothing;
|
|
|
|
if ( e->button() == LeftButton ) {
|
|
|
|
com = options->commandAll1();
|
|
|
|
}
|
|
|
|
else if (e->button() == MidButton) {
|
|
|
|
com = options->commandAll2();
|
|
|
|
}
|
|
|
|
else if (e->button() == RightButton) {
|
|
|
|
com = options->commandAll3();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
performMouseCommand( com, e->globalPos());
|
2000-05-03 06:30:37 +00:00
|
|
|
}
|
2000-05-31 22:26:28 +00:00
|
|
|
else {
|
|
|
|
if ( e->button() == LeftButton ) {
|
|
|
|
if ( options->focusPolicyIsReasonable() )
|
|
|
|
workspace()->requestFocus( this );
|
|
|
|
workspace()->raiseClient( this );
|
|
|
|
mouseMoveEvent( e );
|
|
|
|
buttonDown = TRUE;
|
|
|
|
moveOffset = e->pos();
|
|
|
|
invertedMoveOffset = rect().bottomRight() - e->pos();
|
|
|
|
}
|
|
|
|
else if ( e->button() == MidButton ) {
|
|
|
|
workspace()->lowerClient( this );
|
|
|
|
}
|
|
|
|
else if ( e->button() == RightButton ) {
|
2000-07-10 21:48:13 +00:00
|
|
|
if ( isActive() & ( options->focusPolicy != Options::ClickToFocus && options->clickRaise ) )
|
|
|
|
autoRaise();
|
|
|
|
workspace()->clientPopup( this )->popup( e->globalPos() );
|
2000-05-31 22:26:28 +00:00
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Reimplemented to provide move/resize
|
|
|
|
*/
|
|
|
|
void Client::mouseReleaseEvent( QMouseEvent * e)
|
|
|
|
{
|
1999-11-29 02:06:41 +00:00
|
|
|
if ( (e->stateAfter() & MouseButtonMask) == 0 ) {
|
1999-08-19 23:26:42 +00:00
|
|
|
buttonDown = FALSE;
|
1999-09-27 16:02:44 +00:00
|
|
|
if ( moveResizeMode ) {
|
|
|
|
clearbound();
|
|
|
|
if ( ( isMove() && options->moveMode != Options::Opaque )
|
|
|
|
|| ( isResize() && options->resizeMode != Options::Opaque ) )
|
|
|
|
XUngrabServer( qt_xdisplay() );
|
|
|
|
setGeometry( geom );
|
2000-05-07 20:38:11 +00:00
|
|
|
Events::raise( isResize() ? Events::ResizeEnd : Events::MoveEnd );
|
1999-09-27 16:02:44 +00:00
|
|
|
moveResizeMode = FALSE;
|
2000-07-14 01:49:22 +00:00
|
|
|
workspace()->setFocusChangeEnabled(true);
|
1999-09-27 16:02:44 +00:00
|
|
|
releaseMouse();
|
1999-12-06 00:43:55 +00:00
|
|
|
releaseKeyboard();
|
1999-09-27 16:02:44 +00:00
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-16 01:25:42 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
*/
|
|
|
|
void Client::resizeEvent( QResizeEvent * e)
|
|
|
|
{
|
|
|
|
QWidget::resizeEvent( e );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-28 22:06:22 +00:00
|
|
|
void Client::giveUpShade()
|
|
|
|
{
|
|
|
|
wwrap->show();
|
|
|
|
workspace()->requestFocus( this );
|
|
|
|
shaded = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
/*!
|
|
|
|
Reimplemented to provide move/resize
|
|
|
|
*/
|
|
|
|
void Client::mouseMoveEvent( QMouseEvent * e)
|
|
|
|
{
|
|
|
|
if ( !buttonDown ) {
|
|
|
|
mode = mousePosition( e->pos() );
|
|
|
|
setMouseCursor( mode );
|
2000-05-27 01:56:08 +00:00
|
|
|
geom = geometry();
|
1999-08-19 23:26:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-06-22 18:08:35 +00:00
|
|
|
if ( !isMovable()) return;
|
2000-04-19 04:36:47 +00:00
|
|
|
|
1999-09-27 16:02:44 +00:00
|
|
|
if ( !moveResizeMode )
|
|
|
|
{
|
|
|
|
QPoint p( e->pos() - moveOffset );
|
2000-05-11 03:52:24 +00:00
|
|
|
if (p.manhattanLength() >= 6) {
|
1999-09-27 16:02:44 +00:00
|
|
|
moveResizeMode = TRUE;
|
2000-08-16 12:18:56 +00:00
|
|
|
if ( isMaximized() ) {
|
|
|
|
// in case we were maximized, reset state
|
2000-08-21 12:05:22 +00:00
|
|
|
geom_restore = QRect();
|
2000-08-16 12:18:56 +00:00
|
|
|
maximizeChange(FALSE );
|
|
|
|
}
|
2000-07-11 11:41:52 +00:00
|
|
|
workspace()->setFocusChangeEnabled(false);
|
2000-05-07 20:38:11 +00:00
|
|
|
Events::raise( isResize() ? Events::ResizeStart : Events::MoveStart );
|
1999-09-27 16:02:44 +00:00
|
|
|
grabMouse( cursor() ); // to keep the right cursor
|
|
|
|
if ( ( isMove() && options->moveMode != Options::Opaque )
|
|
|
|
|| ( isResize() && options->resizeMode != Options::Opaque ) )
|
|
|
|
XGrabServer( qt_xdisplay() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-08-01 12:42:03 +00:00
|
|
|
if ( mode != Center && shaded )
|
2000-07-28 22:06:22 +00:00
|
|
|
giveUpShade();
|
1999-08-19 23:26:42 +00:00
|
|
|
|
1999-11-15 15:57:48 +00:00
|
|
|
QPoint globalPos = e->globalPos(); // pos() + geometry().topLeft();
|
1999-08-19 23:26:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
QPoint p = globalPos + invertedMoveOffset;
|
|
|
|
|
|
|
|
QPoint pp = globalPos - moveOffset;
|
|
|
|
|
|
|
|
QSize mpsize( geometry().right() - pp.x() + 1, geometry().bottom() - pp.y() + 1 );
|
|
|
|
mpsize = adjustedSize( mpsize );
|
|
|
|
QPoint mp( geometry().right() - mpsize.width() + 1,
|
|
|
|
geometry().bottom() - mpsize.height() + 1 );
|
|
|
|
|
1999-09-27 16:02:44 +00:00
|
|
|
geom = geometry();
|
1999-08-19 23:26:42 +00:00
|
|
|
switch ( mode ) {
|
|
|
|
case TopLeft:
|
|
|
|
geom = QRect( mp, geometry().bottomRight() ) ;
|
|
|
|
break;
|
|
|
|
case BottomRight:
|
|
|
|
geom = QRect( geometry().topLeft(), p ) ;
|
|
|
|
break;
|
|
|
|
case BottomLeft:
|
|
|
|
geom = QRect( QPoint(mp.x(), geometry().y() ), QPoint( geometry().right(), p.y()) ) ;
|
|
|
|
break;
|
|
|
|
case TopRight:
|
|
|
|
geom = QRect( QPoint(geometry().x(), mp.y() ), QPoint( p.x(), geometry().bottom()) ) ;
|
|
|
|
break;
|
|
|
|
case Top:
|
|
|
|
geom = QRect( QPoint( geometry().left(), mp.y() ), geometry().bottomRight() ) ;
|
|
|
|
break;
|
|
|
|
case Bottom:
|
|
|
|
geom = QRect( geometry().topLeft(), QPoint( geometry().right(), p.y() ) ) ;
|
|
|
|
break;
|
|
|
|
case Left:
|
|
|
|
geom = QRect( QPoint( mp.x(), geometry().top() ), geometry().bottomRight() ) ;
|
|
|
|
break;
|
|
|
|
case Right:
|
|
|
|
geom = QRect( geometry().topLeft(), QPoint( p.x(), geometry().bottom() ) ) ;
|
|
|
|
break;
|
|
|
|
case Center:
|
|
|
|
geom.moveTopLeft( pp );
|
|
|
|
break;
|
|
|
|
default:
|
2000-06-08 17:05:51 +00:00
|
|
|
//fprintf(stderr, "KWin::mouseMoveEvent with mode = %d\n", mode);
|
1999-08-19 23:26:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-05-27 01:56:08 +00:00
|
|
|
QRect desktopArea = workspace()->clientArea();
|
|
|
|
int marge = 5;
|
|
|
|
|
1999-09-27 16:02:44 +00:00
|
|
|
if ( isResize() && geom.size() != size() ) {
|
2000-05-27 01:56:08 +00:00
|
|
|
if (geom.bottom() < desktopArea.top()+marge)
|
|
|
|
geom.setBottom(desktopArea.top()+marge);
|
|
|
|
if (geom.top() > desktopArea.bottom()-marge)
|
|
|
|
geom.setTop(desktopArea.bottom()-marge);
|
|
|
|
if (geom.right() < desktopArea.left()+marge)
|
|
|
|
geom.setRight(desktopArea.left()+marge);
|
|
|
|
if (geom.left() > desktopArea.right()-marge)
|
|
|
|
geom.setLeft(desktopArea.right()-marge);
|
|
|
|
|
|
|
|
geom.setSize( adjustedSize( geom.size() ) );
|
1999-09-27 16:02:44 +00:00
|
|
|
if (options->resizeMode == Options::Opaque ) {
|
|
|
|
setGeometry( geom );
|
|
|
|
} else if ( options->resizeMode == Options::Transparent ) {
|
|
|
|
clearbound();
|
|
|
|
drawbound( geom );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( isMove() && geom.topLeft() != geometry().topLeft() ) {
|
1999-11-25 16:38:11 +00:00
|
|
|
geom.moveTopLeft( workspace()->adjustClientPosition( this, geom.topLeft() ) );
|
2000-05-27 01:56:08 +00:00
|
|
|
if (geom.bottom() < desktopArea.top()+marge)
|
|
|
|
geom.moveBottomLeft( QPoint( geom.left(), desktopArea.top()+marge));
|
|
|
|
if (geom.top() > desktopArea.bottom()-marge)
|
|
|
|
geom.moveTopLeft( QPoint( geom.left(), desktopArea.bottom()-marge));
|
|
|
|
if (geom.right() < desktopArea.left()+marge)
|
|
|
|
geom.moveTopRight( QPoint( desktopArea.left()+marge, geom.top()));
|
|
|
|
if (geom.left() > desktopArea.right()-marge)
|
|
|
|
geom.moveTopLeft( QPoint( desktopArea.right()-marge, geom.top()));
|
|
|
|
switch ( options->moveMode ) {
|
|
|
|
case Options::Opaque:
|
|
|
|
move( geom.topLeft() );
|
|
|
|
break;
|
|
|
|
case Options::Transparent:
|
|
|
|
clearbound();
|
|
|
|
drawbound( geom );
|
|
|
|
break;
|
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
2000-03-24 22:23:02 +00:00
|
|
|
|
|
|
|
QApplication::syncX(); // process our own configure events synchronously.
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Reimplemented to provide move/resize
|
|
|
|
*/
|
|
|
|
void Client::enterEvent( QEvent * )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Reimplemented to provide move/resize
|
|
|
|
*/
|
|
|
|
void Client::leaveEvent( QEvent * )
|
|
|
|
{
|
|
|
|
if ( !buttonDown )
|
|
|
|
setCursor( arrowCursor );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-13 00:32:36 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Reimplemented to inform the client about the new window position.
|
|
|
|
*/
|
|
|
|
void Client::setGeometry( int x, int y, int w, int h )
|
|
|
|
{
|
|
|
|
QWidget::setGeometry(x, y, w, h);
|
2000-07-14 01:49:22 +00:00
|
|
|
sendSynteticConfigureNotify();
|
1999-11-13 00:32:36 +00:00
|
|
|
}
|
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
/*!
|
|
|
|
Reimplemented to inform the client about the new window position.
|
|
|
|
*/
|
1999-11-13 00:32:36 +00:00
|
|
|
void Client::move( int x, int y )
|
1999-08-19 23:26:42 +00:00
|
|
|
{
|
1999-11-13 00:32:36 +00:00
|
|
|
QWidget::move( x, y );
|
1999-08-19 23:26:42 +00:00
|
|
|
sendSynteticConfigureNotify();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!\reimp
|
|
|
|
*/
|
|
|
|
void Client::showEvent( QShowEvent* )
|
|
|
|
{
|
2000-06-23 16:26:44 +00:00
|
|
|
if ( isIconified() && !isTransient() )
|
|
|
|
animateIconifyOrDeiconify( FALSE );
|
1999-08-19 23:26:42 +00:00
|
|
|
setMappingState( NormalState );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Reimplemented to hide the window wrapper as well. Also informs the
|
|
|
|
workspace.
|
|
|
|
*/
|
|
|
|
void Client::hideEvent( QHideEvent* )
|
|
|
|
{
|
|
|
|
workspace()->clientHidden( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Late initialialize the client after the window has been managed.
|
|
|
|
|
|
|
|
Ensure to call the superclasses init() implementation when subclassing.
|
|
|
|
*/
|
|
|
|
void Client::init()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!\fn captionChange( const QString& name )
|
|
|
|
|
|
|
|
Indicates that the caption (the window title) changed to \a
|
|
|
|
name. Subclasses shall then repaint the title string in a clever,
|
|
|
|
fast mannor. The default implementation calls repaint( FALSE );
|
|
|
|
*/
|
|
|
|
void Client::captionChange( const QString& )
|
|
|
|
{
|
|
|
|
repaint( FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!\fn activeChange( bool act )
|
|
|
|
|
|
|
|
Indicates that the activation state changed to \a act. Subclasses
|
|
|
|
may want to indicate the new state graphically in a clever, fast
|
|
|
|
mannor. The default implementation calls repaint( FALSE );
|
|
|
|
*/
|
|
|
|
void Client::activeChange( bool )
|
|
|
|
{
|
|
|
|
repaint( FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Indicates that the application's icon changed to \a act. Subclasses
|
|
|
|
may want to indicate the new state graphically in a clever, fast
|
|
|
|
mannor. The default implementation calls repaint( FALSE );
|
|
|
|
*/
|
|
|
|
void Client::iconChange()
|
|
|
|
{
|
|
|
|
repaint( FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!\fn maximizeChange( bool max )
|
|
|
|
|
|
|
|
Indicates that the window was maximized or demaximized. \a max is
|
|
|
|
set respectively. Subclasses may want to indicate the new state
|
|
|
|
graphically, for example with a different icon.
|
|
|
|
*/
|
|
|
|
void Client::maximizeChange( bool )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!\fn stickyChange( bool sticky )
|
|
|
|
|
|
|
|
Indicates that the window was made sticky or unsticky. \a sticky is
|
|
|
|
set respectively. Subclasses may want to indicate the new state
|
|
|
|
graphically, for example with a different icon.
|
|
|
|
*/
|
|
|
|
void Client::stickyChange( bool )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Paints a client window.
|
|
|
|
|
|
|
|
The default implementation does nothing. To be implemented by subclasses.
|
|
|
|
*/
|
|
|
|
void Client::paintEvent( QPaintEvent * )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Releases the window. The client has done its job and the window is still existing.
|
|
|
|
*/
|
|
|
|
void Client::releaseWindow()
|
|
|
|
{
|
|
|
|
if ( win ) {
|
|
|
|
gravitate( TRUE );
|
|
|
|
windowWrapper()->releaseWindow();
|
|
|
|
win = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Invalidates the window to avoid the client accessing it again.
|
|
|
|
|
|
|
|
This function is called by the workspace when the window has been
|
|
|
|
destroyed.
|
|
|
|
*/
|
|
|
|
void Client::invalidateWindow()
|
|
|
|
{
|
|
|
|
win = 0;
|
|
|
|
windowWrapper()->invalidateWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-23 16:26:44 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Iconifies this client plus its transients
|
|
|
|
*/
|
1999-08-19 23:26:42 +00:00
|
|
|
void Client::iconify()
|
|
|
|
{
|
2000-08-21 12:05:22 +00:00
|
|
|
if ( windowType() != NET::Normal && windowType() != NET::Toolbar ) // desktop and dock cannot be minimized
|
|
|
|
return;
|
2000-05-20 07:54:11 +00:00
|
|
|
|
1999-11-28 20:17:57 +00:00
|
|
|
if ( isShade() )
|
|
|
|
setShade( FALSE );
|
1999-11-14 06:34:28 +00:00
|
|
|
if ( workspace()->iconifyMeansWithdraw( this ) ) {
|
2000-05-07 20:38:11 +00:00
|
|
|
Events::raise( isTransient() ? Events::TransDelete : Events::Delete );
|
1999-11-14 06:34:28 +00:00
|
|
|
setMappingState( WithdrawnState );
|
|
|
|
hide();
|
|
|
|
return;
|
|
|
|
}
|
2000-05-07 20:38:11 +00:00
|
|
|
Events::raise( Events::Iconify );
|
1999-08-19 23:26:42 +00:00
|
|
|
setMappingState( IconicState );
|
2000-06-28 13:20:42 +00:00
|
|
|
|
2000-08-09 10:02:56 +00:00
|
|
|
if ( !isTransient() && isVisible() )
|
2000-06-23 16:26:44 +00:00
|
|
|
animateIconifyOrDeiconify( TRUE );
|
1999-08-19 23:26:42 +00:00
|
|
|
hide();
|
2000-06-28 13:20:42 +00:00
|
|
|
|
1999-11-28 20:10:58 +00:00
|
|
|
workspace()->iconifyOrDeiconifyTransientsOf( this );
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
2000-06-23 16:26:44 +00:00
|
|
|
|
2000-06-28 13:20:42 +00:00
|
|
|
/*!
|
2000-06-23 16:26:44 +00:00
|
|
|
Closes the window by either sending a delete_window message or
|
|
|
|
using XKill.
|
|
|
|
*/
|
1999-08-19 23:26:42 +00:00
|
|
|
void Client::closeWindow()
|
|
|
|
{
|
2000-05-07 20:38:11 +00:00
|
|
|
Events::raise( Events::Close );
|
|
|
|
if ( Pdeletewindow ){
|
|
|
|
sendClientMessage( win, atoms->wm_protocols, atoms->wm_delete_window);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// client will not react on wm_delete_window. We have not choice
|
|
|
|
// but destroy his connection to the XServer.
|
|
|
|
XKillClient(qt_xdisplay(), win );
|
|
|
|
workspace()->destroyClient( this );
|
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
2000-06-23 16:26:44 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Kills the window via XKill
|
|
|
|
*/
|
2000-05-17 23:02:42 +00:00
|
|
|
void Client::killWindow()
|
|
|
|
{
|
|
|
|
// not sure if we need an Events::Kill or not.. until then, use
|
|
|
|
// Events::Close
|
|
|
|
Events::raise( Events::Close );
|
|
|
|
|
|
|
|
// always kill this client at the server
|
|
|
|
XKillClient(qt_xdisplay(), win );
|
|
|
|
workspace()->destroyClient( this );
|
|
|
|
}
|
|
|
|
|
1999-11-22 01:57:51 +00:00
|
|
|
void Client::maximize( MaximizeMode m)
|
1999-08-19 23:26:42 +00:00
|
|
|
{
|
2000-08-16 12:18:56 +00:00
|
|
|
if ( !isMaximizable() )
|
|
|
|
return;
|
2000-05-20 07:54:11 +00:00
|
|
|
|
2000-05-07 20:38:11 +00:00
|
|
|
QRect clientArea = workspace()->clientArea();
|
1999-11-25 12:53:17 +00:00
|
|
|
|
2000-05-07 20:38:11 +00:00
|
|
|
if (isShade())
|
|
|
|
setShade( FALSE );
|
2000-04-26 21:28:51 +00:00
|
|
|
|
2000-08-16 12:18:56 +00:00
|
|
|
if ( m == MaximizeAdjust ) {
|
|
|
|
m = max_mode;
|
|
|
|
} else {
|
|
|
|
if ( !geom_restore.isNull() )
|
|
|
|
m = MaximizeRestore;
|
2000-06-28 13:20:42 +00:00
|
|
|
|
2000-08-16 12:18:56 +00:00
|
|
|
if ( m != MaximizeRestore ) {
|
|
|
|
Events::raise( Events::Maximize );
|
|
|
|
geom_restore = geometry();
|
|
|
|
}
|
2000-06-23 18:18:34 +00:00
|
|
|
}
|
2000-04-26 21:28:51 +00:00
|
|
|
|
2000-06-23 18:18:34 +00:00
|
|
|
switch (m) {
|
2000-04-26 21:28:51 +00:00
|
|
|
|
2000-06-23 18:18:34 +00:00
|
|
|
case MaximizeVertical:
|
|
|
|
setGeometry(
|
|
|
|
QRect(QPoint(x(), clientArea.top()),
|
|
|
|
adjustedSize(QSize(width(), clientArea.height())))
|
|
|
|
);
|
|
|
|
info->setState( NET::MaxVert, NET::MaxVert );
|
|
|
|
break;
|
2000-04-26 21:28:51 +00:00
|
|
|
|
2000-06-23 18:18:34 +00:00
|
|
|
case MaximizeHorizontal:
|
2000-04-26 21:28:51 +00:00
|
|
|
|
2000-06-23 18:18:34 +00:00
|
|
|
setGeometry(
|
|
|
|
QRect(
|
|
|
|
QPoint(clientArea.left(), y()),
|
|
|
|
adjustedSize(QSize(clientArea.width(), height())))
|
|
|
|
);
|
|
|
|
info->setState( NET::MaxHoriz, NET::MaxHoriz );
|
|
|
|
break;
|
2000-06-28 13:20:42 +00:00
|
|
|
|
2000-06-23 18:18:34 +00:00
|
|
|
case MaximizeRestore: {
|
2000-05-07 20:38:11 +00:00
|
|
|
Events::raise( Events::UnMaximize );
|
|
|
|
setGeometry(geom_restore);
|
2000-08-16 12:18:56 +00:00
|
|
|
geom_restore = QRect();
|
2000-06-23 18:18:34 +00:00
|
|
|
info->setState( 0, NET::Max );
|
|
|
|
} break;
|
|
|
|
|
2000-08-16 12:18:56 +00:00
|
|
|
case MaximizeFull: {
|
|
|
|
QRect r = QRect(clientArea.topLeft(), adjustedSize(clientArea.size()));
|
|
|
|
|
|
|
|
// hide right and left border of maximized windows
|
2000-08-22 10:35:22 +00:00
|
|
|
if ( !options->moveResizeMaximizedWindows ) {
|
|
|
|
if ( r.left() == 0 )
|
|
|
|
r.setLeft( r.left() - windowWrapper()->x() );
|
|
|
|
if ( r.right() == workspace()->geometry().right() )
|
|
|
|
r.setRight( r.right() + width() - windowWrapper()->geometry().right() );
|
|
|
|
}
|
2000-08-16 12:18:56 +00:00
|
|
|
setGeometry( r );
|
2000-06-23 18:18:34 +00:00
|
|
|
info->setState( NET::Max, NET::Max );
|
2000-08-16 12:18:56 +00:00
|
|
|
} break;
|
|
|
|
default:
|
|
|
|
break;
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
2000-06-23 18:18:34 +00:00
|
|
|
|
2000-08-16 12:18:56 +00:00
|
|
|
max_mode = m;
|
|
|
|
|
2000-06-23 18:18:34 +00:00
|
|
|
maximizeChange( m != MaximizeRestore );
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Client::toggleSticky()
|
|
|
|
{
|
|
|
|
setSticky( !isSticky() );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Client::maximize()
|
|
|
|
{
|
|
|
|
maximize( MaximizeFull );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Catch events of the WindowWrapper
|
|
|
|
*/
|
|
|
|
bool Client::eventFilter( QObject *o, QEvent * e)
|
|
|
|
{
|
|
|
|
if ( o != wwrap )
|
|
|
|
return FALSE;
|
|
|
|
switch ( e->type() ) {
|
1999-11-22 01:57:51 +00:00
|
|
|
case QEvent::Show:
|
|
|
|
windowWrapperShowEvent( (QShowEvent*)e );
|
|
|
|
break;
|
|
|
|
case QEvent::Hide:
|
|
|
|
windowWrapperHideEvent( (QHideEvent*)e );
|
|
|
|
break;
|
1999-08-19 23:26:42 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-03-24 09:11:37 +00:00
|
|
|
void Client::gravitate( bool invert )
|
|
|
|
{
|
|
|
|
int gravity, dx, dy;
|
|
|
|
dx = dy = 0;
|
|
|
|
|
|
|
|
gravity = NorthWestGravity;
|
|
|
|
if ( xSizeHint.flags & PWinGravity)
|
|
|
|
gravity = xSizeHint.win_gravity;
|
|
|
|
|
|
|
|
switch (gravity) {
|
|
|
|
case NorthWestGravity:
|
|
|
|
dx = 0;
|
|
|
|
dy = 0;
|
|
|
|
break;
|
|
|
|
case NorthGravity:
|
|
|
|
dx = -windowWrapper()->x();
|
|
|
|
dy = 0;
|
|
|
|
break;
|
|
|
|
case NorthEastGravity:
|
|
|
|
dx = -( width() - windowWrapper()->width() );
|
|
|
|
dy = 0;
|
|
|
|
break;
|
|
|
|
case WestGravity:
|
|
|
|
dx = 0;
|
|
|
|
dy = -windowWrapper()->y();
|
|
|
|
break;
|
|
|
|
case CenterGravity:
|
|
|
|
case StaticGravity:
|
|
|
|
dx = -windowWrapper()->x();
|
|
|
|
dy = -windowWrapper()->y();
|
|
|
|
break;
|
|
|
|
case EastGravity:
|
|
|
|
dx = -( width() - windowWrapper()->width() );
|
|
|
|
dy = -windowWrapper()->y();
|
|
|
|
break;
|
|
|
|
case SouthWestGravity:
|
|
|
|
dx = 0;
|
|
|
|
dy = -( height() - windowWrapper()->height() );
|
|
|
|
break;
|
|
|
|
case SouthGravity:
|
|
|
|
dx = -windowWrapper()->x();
|
|
|
|
dy = -( height() - windowWrapper()->height() );
|
|
|
|
break;
|
|
|
|
case SouthEastGravity:
|
|
|
|
dx = -( width() - windowWrapper()->width() - 1 );
|
|
|
|
dy = -( height() - windowWrapper()->height() - 1 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (invert)
|
|
|
|
move( x() - dx, y() - dy );
|
|
|
|
else
|
|
|
|
move( x() + dx, y() + dy );
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Reimplement to handle crossing events (qt should provide xroot, yroot)
|
2000-06-23 16:26:44 +00:00
|
|
|
|
2000-06-22 18:08:35 +00:00
|
|
|
Crossing events are necessary for the focus-follows-mouse focus
|
|
|
|
policies, to do proper activation and deactivation.
|
1999-08-19 23:26:42 +00:00
|
|
|
*/
|
|
|
|
bool Client::x11Event( XEvent * e)
|
|
|
|
{
|
2000-06-22 18:08:35 +00:00
|
|
|
if ( e->type == EnterNotify && e->xcrossing.mode == NotifyNormal ) {
|
2000-06-23 16:26:44 +00:00
|
|
|
if ( options->focusPolicy == Options::ClickToFocus )
|
2000-06-22 18:08:35 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2000-07-11 11:41:52 +00:00
|
|
|
if ( options->autoRaise && !isDesktop() && !isDock() && !isMenu() && workspace()->focusChangeEnabled() ) {
|
2000-07-09 20:29:53 +00:00
|
|
|
delete autoRaiseTimer;
|
|
|
|
autoRaiseTimer = new QTimer( this );
|
|
|
|
connect( autoRaiseTimer, SIGNAL( timeout() ), this, SLOT( autoRaise() ) );
|
|
|
|
autoRaiseTimer->start( options->autoRaiseInterval, TRUE );
|
|
|
|
}
|
|
|
|
|
2000-07-10 15:54:17 +00:00
|
|
|
if ( options->focusPolicy != Options::FocusStrictlyUnderMouse && ( isDesktop() || isDock() || isMenu() ) )
|
2000-06-22 18:08:35 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
workspace()->requestFocus( this );
|
1999-08-19 23:26:42 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2000-08-16 12:18:56 +00:00
|
|
|
|
2000-06-22 18:08:35 +00:00
|
|
|
if ( e->type == LeaveNotify && e->xcrossing.mode == NotifyNormal ) {
|
1999-08-19 23:26:42 +00:00
|
|
|
if ( !buttonDown )
|
|
|
|
setCursor( arrowCursor );
|
2000-07-09 21:43:19 +00:00
|
|
|
bool lostMouse = !rect().contains( QPoint( e->xcrossing.x, e->xcrossing.y ) );
|
|
|
|
if ( lostMouse ) {
|
|
|
|
delete autoRaiseTimer;
|
|
|
|
autoRaiseTimer = 0;
|
2000-08-13 17:07:26 +00:00
|
|
|
}
|
2000-06-22 18:08:35 +00:00
|
|
|
if ( options->focusPolicy == Options::FocusStrictlyUnderMouse )
|
2000-07-09 21:43:19 +00:00
|
|
|
if ( isActive() && lostMouse )
|
1999-08-19 23:26:42 +00:00
|
|
|
workspace()->requestFocus( 0 ) ;
|
|
|
|
return TRUE;
|
|
|
|
}
|
2000-08-16 12:18:56 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns a logical mouse position for the cursor position \a
|
|
|
|
p. Possible positions are: Nowhere, TopLeft , BottomRight,
|
|
|
|
BottomLeft, TopRight, Top, Bottom, Left, Right, Center
|
|
|
|
*/
|
|
|
|
Client::MousePosition Client::mousePosition( const QPoint& p ) const
|
|
|
|
{
|
|
|
|
const int range = 16;
|
|
|
|
const int border = 4;
|
|
|
|
|
|
|
|
MousePosition m = Nowhere;
|
|
|
|
|
|
|
|
|
|
|
|
if ( ( p.x() > border && p.x() < width() - border )
|
|
|
|
&& ( p.y() > border && p.y() < height() - border ) )
|
|
|
|
return Center;
|
|
|
|
|
|
|
|
if ( p.y() <= range && p.x() <= range)
|
|
|
|
m = TopLeft;
|
|
|
|
else if ( p.y() >= height()-range && p.x() >= width()-range)
|
|
|
|
m = BottomRight;
|
|
|
|
else if ( p.y() >= height()-range && p.x() <= range)
|
|
|
|
m = BottomLeft;
|
|
|
|
else if ( p.y() <= range && p.x() >= width()-range)
|
|
|
|
m = TopRight;
|
|
|
|
else if ( p.y() <= border )
|
|
|
|
m = Top;
|
|
|
|
else if ( p.y() >= height()-border )
|
|
|
|
m = Bottom;
|
|
|
|
else if ( p.x() <= border )
|
|
|
|
m = Left;
|
|
|
|
else if ( p.x() >= width()-border )
|
|
|
|
m = Right;
|
|
|
|
else
|
|
|
|
m = Center;
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets an appropriate cursor shape for the logical mouse position \a m
|
|
|
|
|
|
|
|
\sa QWidget::setCursor()
|
|
|
|
*/
|
|
|
|
void Client::setMouseCursor( MousePosition m )
|
|
|
|
{
|
2000-08-16 12:18:56 +00:00
|
|
|
if ( !isResizable() ) {
|
|
|
|
setCursor( arrowCursor );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
switch ( m ) {
|
|
|
|
case TopLeft:
|
|
|
|
case BottomRight:
|
|
|
|
setCursor( sizeFDiagCursor );
|
|
|
|
break;
|
|
|
|
case BottomLeft:
|
|
|
|
case TopRight:
|
|
|
|
setCursor( sizeBDiagCursor );
|
|
|
|
break;
|
|
|
|
case Top:
|
|
|
|
case Bottom:
|
|
|
|
setCursor( sizeVerCursor );
|
|
|
|
break;
|
|
|
|
case Left:
|
|
|
|
case Right:
|
|
|
|
setCursor( sizeHorCursor );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
setCursor( arrowCursor );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Client::isShade() const
|
|
|
|
{
|
|
|
|
return shaded;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Client::setShade( bool s )
|
|
|
|
{
|
2000-06-22 18:08:35 +00:00
|
|
|
if (!isMovable())
|
2000-05-20 07:54:11 +00:00
|
|
|
return;
|
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
if ( shaded == s )
|
|
|
|
return;
|
|
|
|
|
|
|
|
shaded = s;
|
|
|
|
|
2000-07-09 20:29:53 +00:00
|
|
|
int as = options->animateShade? options->animSteps : 1;
|
1999-11-26 01:24:52 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
if (shaded ) {
|
1999-11-22 01:57:51 +00:00
|
|
|
int h = height();
|
1999-08-19 23:26:42 +00:00
|
|
|
QSize s( sizeForWindowSize( QSize( windowWrapper()->width(), 0), TRUE ) );
|
|
|
|
windowWrapper()->hide();
|
1999-11-22 01:57:51 +00:00
|
|
|
repaint( FALSE ); // force direct repaint
|
2000-08-16 13:11:21 +00:00
|
|
|
bool wasNorthWest = testWFlags( WNorthWestGravity );
|
1999-11-22 01:57:51 +00:00
|
|
|
setWFlags( WNorthWestGravity );
|
1999-11-29 02:49:20 +00:00
|
|
|
int step = QMAX( 4, QABS( h - s.height() ) / as )+1;
|
|
|
|
do {
|
1999-11-22 01:57:51 +00:00
|
|
|
h -= step;
|
|
|
|
resize ( s.width(), h );
|
|
|
|
QApplication::syncX();
|
1999-11-26 01:24:52 +00:00
|
|
|
} while ( h > s.height() + step );
|
2000-08-16 13:11:21 +00:00
|
|
|
if ( !wasNorthWest )
|
|
|
|
clearWFlags( WNorthWestGravity );
|
1999-08-19 23:26:42 +00:00
|
|
|
resize (s );
|
1999-11-29 03:01:09 +00:00
|
|
|
XEvent tmpE;
|
|
|
|
do {
|
|
|
|
XWindowEvent (qt_xdisplay(), windowWrapper()->winId(),
|
|
|
|
SubstructureNotifyMask, &tmpE);
|
|
|
|
} while ( tmpE.type != UnmapNotify || tmpE.xunmap.window != win );
|
1999-08-19 23:26:42 +00:00
|
|
|
} else {
|
1999-11-22 01:57:51 +00:00
|
|
|
int h = height();
|
1999-11-22 02:23:13 +00:00
|
|
|
QSize s( sizeForWindowSize( windowWrapper()->size(), TRUE ) );
|
1999-11-22 01:57:51 +00:00
|
|
|
setWFlags( WNorthWestGravity );
|
1999-11-29 02:49:20 +00:00
|
|
|
int step = QMAX( 4, QABS( h - s.height() ) / as )+1;
|
|
|
|
do {
|
1999-11-22 01:57:51 +00:00
|
|
|
h += step;
|
|
|
|
resize ( s.width(), h );
|
|
|
|
// assume a border
|
|
|
|
// we do not have time to wait for X to send us paint events
|
|
|
|
repaint( 0, h - step-5, width(), step+5, TRUE);
|
|
|
|
QApplication::syncX();
|
1999-11-26 01:24:52 +00:00
|
|
|
} while ( h < s.height() - step );
|
1999-11-22 01:57:51 +00:00
|
|
|
clearWFlags( WNorthWestGravity );
|
|
|
|
resize ( s );
|
1999-08-19 23:26:42 +00:00
|
|
|
windowWrapper()->show();
|
2000-05-11 03:52:24 +00:00
|
|
|
activateLayout();
|
1999-11-16 01:25:42 +00:00
|
|
|
repaint();
|
1999-08-19 23:26:42 +00:00
|
|
|
if ( isActive() )
|
|
|
|
workspace()->requestFocus( this );
|
|
|
|
}
|
1999-11-29 14:19:32 +00:00
|
|
|
|
1999-11-28 20:17:57 +00:00
|
|
|
workspace()->iconifyOrDeiconifyTransientsOf( this );
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets the client's active state to \a act.
|
|
|
|
|
|
|
|
This function does only change the visual appearance of the client,
|
|
|
|
it does not change the focus setting. Use
|
|
|
|
Workspace::activateClient() or Workspace::requestFocus() instead.
|
|
|
|
|
|
|
|
If a client receives or looses the focus, it calls setActive() on
|
|
|
|
its own.
|
|
|
|
|
|
|
|
*/
|
|
|
|
void Client::setActive( bool act)
|
|
|
|
{
|
2000-03-29 14:53:25 +00:00
|
|
|
windowWrapper()->setActive( act );
|
1999-12-06 00:43:55 +00:00
|
|
|
if ( act )
|
|
|
|
workspace()->setActiveClient( this );
|
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
if ( active == act )
|
|
|
|
return;
|
|
|
|
active = act;
|
2000-07-09 20:29:53 +00:00
|
|
|
if ( !active && autoRaiseTimer ) {
|
|
|
|
delete autoRaiseTimer;
|
|
|
|
autoRaiseTimer = 0;
|
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
activeChange( active );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Sets the window's sticky property to b
|
|
|
|
*/
|
|
|
|
void Client::setSticky( bool b )
|
|
|
|
{
|
|
|
|
if ( is_sticky == b )
|
|
|
|
return;
|
|
|
|
is_sticky = b;
|
2000-06-28 13:20:42 +00:00
|
|
|
if ( isVisible() ) {
|
|
|
|
if ( is_sticky )
|
|
|
|
Events::raise( Events::Sticky );
|
|
|
|
else
|
|
|
|
Events::raise( Events::UnSticky );
|
|
|
|
}
|
1999-11-22 01:57:51 +00:00
|
|
|
if ( !is_sticky )
|
|
|
|
setDesktop( workspace()->currentDesktop() );
|
2000-06-08 17:05:51 +00:00
|
|
|
else
|
|
|
|
info->setDesktop( NETWinInfo::OnAllDesktops );
|
2000-01-10 03:47:30 +00:00
|
|
|
workspace()->setStickyTransientsOf( this, b );
|
1999-08-19 23:26:42 +00:00
|
|
|
stickyChange( is_sticky );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-28 13:20:42 +00:00
|
|
|
/*!
|
|
|
|
Let the window stay on top or not, depending on \a b
|
2000-07-09 20:29:53 +00:00
|
|
|
|
2000-06-28 13:20:42 +00:00
|
|
|
\sa Workspace::setClientOnTop()
|
|
|
|
*/
|
|
|
|
void Client::setStaysOnTop( bool b )
|
|
|
|
{
|
|
|
|
if ( b == staysOnTop() )
|
|
|
|
return;
|
|
|
|
stays_on_top = b;
|
|
|
|
info->setState( b?NET::StaysOnTop:0, NET::StaysOnTop );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-22 01:57:51 +00:00
|
|
|
void Client::setDesktop( int desktop)
|
|
|
|
{
|
|
|
|
desk = desktop;
|
2000-06-08 17:05:51 +00:00
|
|
|
info->setDesktop( desktop );
|
1999-11-22 01:57:51 +00:00
|
|
|
}
|
|
|
|
|
1999-11-28 20:10:58 +00:00
|
|
|
void Client::getWMHints()
|
1999-08-19 23:26:42 +00:00
|
|
|
{
|
2000-06-08 17:05:51 +00:00
|
|
|
// get the icons, allow scaling
|
|
|
|
icon_pix = KWin::icon( win, 32, 32, TRUE );
|
|
|
|
miniicon_pix = KWin::icon( win, 16, 16, TRUE );
|
1999-08-19 23:26:42 +00:00
|
|
|
if ( !isWithdrawn() )
|
|
|
|
iconChange();
|
1999-11-29 14:19:32 +00:00
|
|
|
|
1999-11-28 20:10:58 +00:00
|
|
|
input = TRUE;
|
|
|
|
XWMHints *hints = XGetWMHints(qt_xdisplay(), win );
|
|
|
|
if ( hints ) {
|
|
|
|
if ( hints->flags & InputHint )
|
|
|
|
input = hints->input;
|
|
|
|
XFree((char*)hints);
|
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Client::getWindowProtocols(){
|
|
|
|
Atom *p;
|
|
|
|
int i,n;
|
|
|
|
|
|
|
|
Pdeletewindow = 0;
|
|
|
|
Ptakefocus = 0;
|
1999-12-01 22:09:32 +00:00
|
|
|
Pcontexthelp = 0;
|
1999-08-19 23:26:42 +00:00
|
|
|
|
|
|
|
if (XGetWMProtocols(qt_xdisplay(), win, &p, &n)){
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
if (p[i] == atoms->wm_delete_window)
|
|
|
|
Pdeletewindow = 1;
|
|
|
|
else if (p[i] == atoms->wm_take_focus)
|
|
|
|
Ptakefocus = 1;
|
1999-12-01 22:09:32 +00:00
|
|
|
else if (p[i] == atoms->net_wm_context_help)
|
|
|
|
Pcontexthelp = 1;
|
1999-08-19 23:26:42 +00:00
|
|
|
if (n>0)
|
|
|
|
XFree(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Puts the focus on this window. Clients should never calls this
|
|
|
|
themselves, instead they should use Workspace::requestFocus().
|
|
|
|
*/
|
|
|
|
void Client::takeFocus()
|
|
|
|
{
|
2000-07-10 15:54:17 +00:00
|
|
|
if ( isMenu() )
|
|
|
|
return; // menus don't take focus
|
2000-07-11 14:38:17 +00:00
|
|
|
|
1999-11-28 20:10:58 +00:00
|
|
|
if ( input )
|
1999-11-28 21:41:15 +00:00
|
|
|
XSetInputFocus( qt_xdisplay(), win, RevertToPointerRoot, kwin_time );
|
1999-11-01 23:41:44 +00:00
|
|
|
if ( Ptakefocus )
|
1999-08-19 23:26:42 +00:00
|
|
|
sendClientMessage(win, atoms->wm_protocols, atoms->wm_take_focus);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-27 16:02:44 +00:00
|
|
|
/*!\reimp
|
|
|
|
*/
|
|
|
|
void Client::setMask( const QRegion & reg)
|
|
|
|
{
|
|
|
|
mask = reg;
|
|
|
|
QWidget::setMask( reg );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-28 20:10:58 +00:00
|
|
|
/*!
|
|
|
|
Returns the main client. For normal windows, this is the window
|
|
|
|
itself. For transient windows, it is the parent.
|
1999-11-29 14:19:32 +00:00
|
|
|
|
1999-11-28 20:10:58 +00:00
|
|
|
*/
|
|
|
|
Client* Client::mainClient()
|
|
|
|
{
|
2000-08-10 13:01:12 +00:00
|
|
|
if ( !isTransient() && transientFor() != 0 )
|
1999-11-28 20:10:58 +00:00
|
|
|
return this;
|
|
|
|
ClientList saveset;
|
|
|
|
Client* c = this;
|
|
|
|
do {
|
|
|
|
saveset.append( c );
|
|
|
|
c = workspace()->findClient( c->transientFor() );
|
|
|
|
} while ( c && c->isTransient() && !saveset.contains( c ) );
|
1999-11-29 14:19:32 +00:00
|
|
|
|
1999-11-28 20:10:58 +00:00
|
|
|
return c?c:this;
|
|
|
|
}
|
|
|
|
|
1999-11-22 01:57:51 +00:00
|
|
|
|
1999-12-01 22:09:32 +00:00
|
|
|
/*!
|
|
|
|
Returns whether the window provides context help or not. If it does,
|
|
|
|
you should show a help menu item or a help button lie '?' and call
|
|
|
|
contextHelp() if this is invoked.
|
1999-12-06 00:43:55 +00:00
|
|
|
|
1999-12-01 22:09:32 +00:00
|
|
|
\sa contextHelp()
|
|
|
|
*/
|
|
|
|
bool Client::providesContextHelp() const
|
|
|
|
{
|
|
|
|
return Pcontexthelp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Invokes context help on the window. Only works if the window
|
|
|
|
actually provides context help.
|
1999-12-06 00:43:55 +00:00
|
|
|
|
1999-12-01 22:09:32 +00:00
|
|
|
\sa providesContextHelp()
|
|
|
|
*/
|
|
|
|
void Client::contextHelp()
|
|
|
|
{
|
|
|
|
if ( Pcontexthelp ) {
|
|
|
|
sendClientMessage(win, atoms->wm_protocols, atoms->net_wm_context_help);
|
|
|
|
QWhatsThis::enterWhatsThisMode();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-29 02:06:41 +00:00
|
|
|
|
1999-12-06 00:43:55 +00:00
|
|
|
/*!
|
|
|
|
Performs a mouse command on this client (see options.h)
|
|
|
|
*/
|
1999-11-29 02:06:41 +00:00
|
|
|
bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPos)
|
|
|
|
{
|
|
|
|
bool replay = FALSE;
|
|
|
|
switch (command) {
|
|
|
|
case Options::MouseRaise:
|
2000-06-22 22:10:27 +00:00
|
|
|
workspace()->raiseClient( this );
|
1999-11-29 02:06:41 +00:00
|
|
|
break;
|
|
|
|
case Options::MouseLower:
|
2000-06-22 22:10:27 +00:00
|
|
|
workspace()->lowerClient( this );
|
1999-11-29 02:06:41 +00:00
|
|
|
break;
|
|
|
|
case Options::MouseOperationsMenu:
|
|
|
|
break;
|
|
|
|
case Options::MouseToggleRaiseAndLower:
|
2000-06-22 22:10:27 +00:00
|
|
|
if ( workspace()->topClientOnDesktop() == this )
|
|
|
|
workspace()->lowerClient( this );
|
|
|
|
else
|
|
|
|
workspace()->raiseClient( this );
|
1999-11-29 02:06:41 +00:00
|
|
|
break;
|
|
|
|
case Options::MouseActivateAndRaise:
|
|
|
|
workspace()->requestFocus( this );
|
|
|
|
workspace()->raiseClient( this );
|
|
|
|
break;
|
|
|
|
case Options::MouseActivateAndLower:
|
|
|
|
workspace()->requestFocus( this );
|
|
|
|
workspace()->raiseClient( this );
|
|
|
|
break;
|
|
|
|
case Options::MouseActivate:
|
|
|
|
workspace()->requestFocus( this );
|
|
|
|
break;
|
|
|
|
case Options::MouseActivateRaiseAndPassClick:
|
|
|
|
workspace()->requestFocus( this );
|
|
|
|
workspace()->raiseClient( this );
|
|
|
|
replay = TRUE;
|
|
|
|
break;
|
|
|
|
case Options::MouseActivateAndPassClick:
|
|
|
|
workspace()->requestFocus( this );
|
|
|
|
workspace()->raiseClient( this );
|
|
|
|
replay = TRUE;
|
|
|
|
break;
|
|
|
|
case Options::MouseMove:
|
2000-06-22 22:10:27 +00:00
|
|
|
if (!isMovable())
|
|
|
|
break;
|
1999-11-29 02:06:41 +00:00
|
|
|
mode = Center;
|
|
|
|
moveResizeMode = TRUE;
|
2000-08-16 12:18:56 +00:00
|
|
|
if ( isMaximized() ) {
|
|
|
|
// in case we were maximized, reset state
|
2000-08-21 12:05:22 +00:00
|
|
|
geom_restore = QRect();
|
2000-08-16 12:18:56 +00:00
|
|
|
maximizeChange(FALSE );
|
|
|
|
}
|
2000-07-11 11:41:52 +00:00
|
|
|
workspace()->setFocusChangeEnabled(false);
|
1999-11-29 02:06:41 +00:00
|
|
|
buttonDown = TRUE;
|
|
|
|
moveOffset = mapFromGlobal( globalPos );
|
|
|
|
invertedMoveOffset = rect().bottomRight() - moveOffset;
|
1999-11-29 14:19:32 +00:00
|
|
|
grabMouse( arrowCursor );
|
1999-12-06 00:43:55 +00:00
|
|
|
grabKeyboard();
|
1999-11-29 02:06:41 +00:00
|
|
|
if ( options->moveMode != Options::Opaque )
|
|
|
|
XGrabServer( qt_xdisplay() );
|
|
|
|
break;
|
2000-07-07 11:47:45 +00:00
|
|
|
case Options::MouseResize: {
|
2000-06-22 22:10:27 +00:00
|
|
|
if (!isMovable())
|
|
|
|
break;
|
1999-11-29 02:06:41 +00:00
|
|
|
moveResizeMode = TRUE;
|
2000-08-16 12:18:56 +00:00
|
|
|
if ( isMaximized() ) {
|
|
|
|
// in case we were maximized, reset state
|
2000-08-21 12:05:22 +00:00
|
|
|
geom_restore = QRect();
|
2000-08-16 12:18:56 +00:00
|
|
|
maximizeChange(FALSE );
|
|
|
|
}
|
2000-07-11 11:41:52 +00:00
|
|
|
workspace()->setFocusChangeEnabled(false);
|
1999-11-29 02:06:41 +00:00
|
|
|
buttonDown = TRUE;
|
|
|
|
moveOffset = mapFromGlobal( globalPos );
|
2000-07-07 11:47:45 +00:00
|
|
|
int x = moveOffset.x(), y = moveOffset.y();
|
|
|
|
bool left = x < width() / 3;
|
|
|
|
bool right = x >= 2 * width() / 3;
|
|
|
|
bool top = y < height() / 3;
|
|
|
|
bool bot = y >= 2 * height() / 3;
|
|
|
|
if (top)
|
|
|
|
mode = left ? TopLeft : (right ? TopRight : Top);
|
|
|
|
else if (bot)
|
|
|
|
mode = left ? BottomLeft : (right ? BottomRight : Bottom);
|
|
|
|
else
|
|
|
|
mode = (x < width() / 2) ? Left : Right;
|
1999-11-29 02:06:41 +00:00
|
|
|
invertedMoveOffset = rect().bottomRight() - moveOffset;
|
|
|
|
setMouseCursor( mode );
|
|
|
|
grabMouse( cursor() );
|
1999-12-06 00:43:55 +00:00
|
|
|
grabKeyboard();
|
|
|
|
resizeHorizontalDirectionFixed = FALSE;
|
|
|
|
resizeVerticalDirectionFixed = FALSE;
|
1999-11-29 02:06:41 +00:00
|
|
|
if ( options->resizeMode != Options::Opaque )
|
|
|
|
XGrabServer( qt_xdisplay() );
|
2000-07-07 11:47:45 +00:00
|
|
|
} break;
|
1999-11-29 02:06:41 +00:00
|
|
|
case Options::MouseNothing:
|
|
|
|
// fall through
|
|
|
|
default:
|
|
|
|
replay = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return replay;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-06 00:43:55 +00:00
|
|
|
void Client::keyPressEvent( QKeyEvent * e )
|
|
|
|
{
|
|
|
|
if ( !isMove() && !isResize() )
|
|
|
|
return;
|
|
|
|
bool is_control = e->state() & ControlButton;
|
|
|
|
int delta = is_control?1:8;
|
|
|
|
QPoint pos = QCursor::pos();
|
|
|
|
switch ( e->key() ) {
|
|
|
|
case Key_Left:
|
|
|
|
pos.rx() -= delta;
|
|
|
|
if ( pos.x() <= workspace()->geometry().left() ) {
|
1999-12-06 15:44:29 +00:00
|
|
|
if ( mode == TopLeft || mode == BottomLeft ) {
|
|
|
|
moveOffset.rx() += delta;
|
|
|
|
invertedMoveOffset.rx() += delta;
|
|
|
|
} else {
|
|
|
|
moveOffset.rx() -= delta;
|
|
|
|
invertedMoveOffset.rx() -= delta;
|
|
|
|
}
|
1999-12-06 00:43:55 +00:00
|
|
|
}
|
|
|
|
if ( isResize() && !resizeHorizontalDirectionFixed ) {
|
|
|
|
resizeHorizontalDirectionFixed = TRUE;
|
|
|
|
if ( mode == BottomRight )
|
|
|
|
mode = BottomLeft;
|
|
|
|
else if ( mode == TopRight )
|
|
|
|
mode = TopLeft;
|
|
|
|
setMouseCursor( mode );
|
|
|
|
grabMouse( cursor() );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Key_Right:
|
|
|
|
pos.rx() += delta;
|
|
|
|
if ( pos.x() >= workspace()->geometry().right() ) {
|
1999-12-06 15:44:29 +00:00
|
|
|
if ( mode == TopRight || mode == BottomRight ) {
|
|
|
|
moveOffset.rx() += delta;
|
|
|
|
invertedMoveOffset.rx() += delta;
|
|
|
|
} else {
|
|
|
|
moveOffset.rx() -= delta;
|
|
|
|
invertedMoveOffset.rx() -= delta;
|
|
|
|
}
|
1999-12-06 00:43:55 +00:00
|
|
|
}
|
|
|
|
if ( isResize() && !resizeHorizontalDirectionFixed ) {
|
|
|
|
resizeHorizontalDirectionFixed = TRUE;
|
|
|
|
if ( mode == BottomLeft )
|
|
|
|
mode = BottomRight;
|
|
|
|
else if ( mode == TopLeft )
|
|
|
|
mode = TopRight;
|
|
|
|
setMouseCursor( mode );
|
|
|
|
grabMouse( cursor() );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Key_Up:
|
|
|
|
pos.ry() -= delta;
|
|
|
|
if ( pos.y() <= workspace()->geometry().top() ) {
|
1999-12-06 15:44:29 +00:00
|
|
|
if ( mode == TopLeft || mode == TopRight ) {
|
|
|
|
moveOffset.ry() += delta;
|
|
|
|
invertedMoveOffset.ry() += delta;
|
|
|
|
} else {
|
|
|
|
moveOffset.ry() -= delta;
|
|
|
|
invertedMoveOffset.ry() -= delta;
|
|
|
|
}
|
1999-12-06 00:43:55 +00:00
|
|
|
}
|
|
|
|
if ( isResize() && !resizeVerticalDirectionFixed ) {
|
|
|
|
resizeVerticalDirectionFixed = TRUE;
|
|
|
|
if ( mode == BottomLeft )
|
|
|
|
mode = TopLeft;
|
|
|
|
else if ( mode == BottomRight )
|
|
|
|
mode = TopRight;
|
|
|
|
setMouseCursor( mode );
|
|
|
|
grabMouse( cursor() );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Key_Down:
|
|
|
|
pos.ry() += delta;
|
|
|
|
if ( pos.y() >= workspace()->geometry().bottom() ) {
|
1999-12-06 15:44:29 +00:00
|
|
|
if ( mode == BottomLeft || mode == BottomRight ) {
|
|
|
|
moveOffset.ry() += delta;
|
|
|
|
invertedMoveOffset.ry() += delta;
|
|
|
|
} else {
|
|
|
|
moveOffset.ry() -= delta;
|
|
|
|
invertedMoveOffset.ry() -= delta;
|
|
|
|
}
|
1999-12-06 00:43:55 +00:00
|
|
|
}
|
|
|
|
if ( isResize() && !resizeVerticalDirectionFixed ) {
|
|
|
|
resizeVerticalDirectionFixed = TRUE;
|
|
|
|
if ( mode == TopLeft )
|
|
|
|
mode = BottomLeft;
|
|
|
|
else if ( mode == TopRight )
|
|
|
|
mode = BottomRight;
|
|
|
|
setMouseCursor( mode );
|
|
|
|
grabMouse( cursor() );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Key_Space:
|
|
|
|
case Key_Return:
|
|
|
|
case Key_Enter:
|
|
|
|
clearbound();
|
|
|
|
if ( ( isMove() && options->moveMode != Options::Opaque )
|
|
|
|
|| ( isResize() && options->resizeMode != Options::Opaque ) )
|
|
|
|
XUngrabServer( qt_xdisplay() );
|
|
|
|
setGeometry( geom );
|
|
|
|
moveResizeMode = FALSE;
|
2000-07-11 11:41:52 +00:00
|
|
|
workspace()->setFocusChangeEnabled(true);
|
1999-12-06 00:43:55 +00:00
|
|
|
releaseMouse();
|
|
|
|
releaseKeyboard();
|
|
|
|
buttonDown = FALSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QCursor::setPos( pos );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-24 22:23:02 +00:00
|
|
|
QCString Client::windowRole()
|
|
|
|
{
|
|
|
|
extern Atom qt_window_role;
|
|
|
|
Atom type;
|
|
|
|
int format;
|
|
|
|
unsigned long length, after;
|
|
|
|
unsigned char *data;
|
|
|
|
QCString result;
|
|
|
|
if ( XGetWindowProperty( qt_xdisplay(), win, qt_window_role, 0, 1024,
|
|
|
|
FALSE, XA_STRING, &type, &format,
|
|
|
|
&length, &after, &data ) == Success ) {
|
|
|
|
if ( data )
|
|
|
|
result = (const char*) data;
|
|
|
|
XFree( data );
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
QCString Client::sessionId()
|
|
|
|
{
|
|
|
|
extern Atom qt_sm_client_id;
|
|
|
|
Atom type;
|
|
|
|
int format;
|
|
|
|
unsigned long length, after;
|
|
|
|
unsigned char *data;
|
|
|
|
QCString result;
|
|
|
|
if ( XGetWindowProperty( qt_xdisplay(), win, qt_sm_client_id, 0, 1024,
|
|
|
|
FALSE, XA_STRING, &type, &format,
|
|
|
|
&length, &after, &data ) == Success ) {
|
|
|
|
if ( data )
|
|
|
|
result = (const char*) data;
|
|
|
|
XFree( data );
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-05-11 03:31:54 +00:00
|
|
|
void Client::activateLayout()
|
|
|
|
{
|
2000-05-26 13:54:50 +00:00
|
|
|
if ( layout() )
|
|
|
|
layout()->activate();
|
2000-05-11 03:31:54 +00:00
|
|
|
}
|
|
|
|
|
2000-06-22 14:12:13 +00:00
|
|
|
|
2000-06-22 18:08:35 +00:00
|
|
|
NET::WindowType Client::windowType() const
|
|
|
|
{
|
|
|
|
NET::WindowType wt = info->windowType();
|
|
|
|
if ( wt == NET::Unknown )
|
|
|
|
wt = NET::Normal;
|
|
|
|
return wt;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Client::wantsTabFocus() const
|
|
|
|
{
|
2000-08-09 10:02:56 +00:00
|
|
|
return windowType() == NET::Normal && ( input || Ptakefocus ) && !skip_taskbar;
|
2000-06-22 18:08:35 +00:00
|
|
|
}
|
|
|
|
|
2000-08-04 21:29:02 +00:00
|
|
|
/*!
|
2000-08-01 16:44:15 +00:00
|
|
|
Returns whether the window is moveable or has a fixed
|
|
|
|
position. !isMovable implies !isResizable.
|
|
|
|
*/
|
2000-06-22 18:08:35 +00:00
|
|
|
bool Client::isMovable() const
|
|
|
|
{
|
2000-08-21 12:05:22 +00:00
|
|
|
return may_move &&
|
2000-08-16 12:18:56 +00:00
|
|
|
( windowType() == NET::Normal || windowType() == NET::Toolbar ) &&
|
2000-08-22 10:35:22 +00:00
|
|
|
( !isMaximized() || ( options->moveResizeMaximizedWindows || max_mode != MaximizeFull ) );
|
2000-06-22 18:08:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Client::isDesktop() const
|
|
|
|
{
|
|
|
|
return windowType() == NET::Desktop;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Client::isDock() const
|
|
|
|
{
|
|
|
|
return windowType() == NET::Dock;
|
|
|
|
}
|
|
|
|
|
2000-07-10 15:54:17 +00:00
|
|
|
bool Client::isMenu() const
|
|
|
|
{
|
|
|
|
return windowType() == NET::Menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-22 18:08:35 +00:00
|
|
|
|
2000-06-23 16:26:44 +00:00
|
|
|
/*!
|
2000-06-22 14:12:13 +00:00
|
|
|
Returns \a area with the client's strut taken into account.
|
2000-06-23 16:26:44 +00:00
|
|
|
|
2000-06-22 14:12:13 +00:00
|
|
|
Used from Workspace in updateClientArea.
|
|
|
|
*/
|
2000-06-08 17:05:51 +00:00
|
|
|
QRect Client::adjustedClientArea( const QRect& area ) const
|
2000-05-04 23:12:29 +00:00
|
|
|
{
|
2000-06-08 17:05:51 +00:00
|
|
|
QRect r = area;
|
|
|
|
NETStrut strut = info->strut();
|
|
|
|
if ( strut.left > 0 )
|
|
|
|
r.setLeft( r.left() + (int) strut.left );
|
|
|
|
if ( strut.top > 0 )
|
|
|
|
r.setTop( r.top() + (int) strut.top );
|
|
|
|
if ( strut.right > 0 )
|
|
|
|
r.setRight( r.right() - (int) strut.right );
|
|
|
|
if ( strut.bottom > 0 )
|
|
|
|
r.setBottom( r.bottom() - (int) strut.bottom );
|
|
|
|
return r;
|
2000-05-04 23:12:29 +00:00
|
|
|
}
|
|
|
|
|
2000-06-08 17:05:51 +00:00
|
|
|
|
2000-06-23 16:26:44 +00:00
|
|
|
void Client::animateIconifyOrDeiconify( bool iconify)
|
|
|
|
{
|
2000-06-24 17:58:10 +00:00
|
|
|
if ( blockAnimation )
|
|
|
|
return;
|
2000-06-23 16:26:44 +00:00
|
|
|
// the function is a bit tricky since it will ensure that an
|
|
|
|
// animation action needs always the same time regardless of the
|
|
|
|
// performance of the machine or the X-Server.
|
|
|
|
|
|
|
|
float lf,rf,tf,bf,step;
|
|
|
|
|
|
|
|
int options_dot_ResizeAnimation = 1;
|
|
|
|
|
|
|
|
step = 40. * (11 - options_dot_ResizeAnimation);
|
|
|
|
|
|
|
|
NETRect r = info->iconGeometry();
|
|
|
|
QRect icongeom( r.pos.x, r.pos.y, r.size.width, r.size.height );
|
|
|
|
if ( !icongeom.isValid() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
QPixmap pm = animationPixmap( iconify ? width() : icongeom.width() );
|
|
|
|
|
|
|
|
QRect before, after;
|
|
|
|
if ( iconify ) {
|
|
|
|
before = QRect( x(), y(), width(), pm.height() );
|
|
|
|
after = QRect( icongeom.x(), icongeom.y(), icongeom.width(), pm.height() );
|
|
|
|
} else {
|
|
|
|
before = QRect( icongeom.x(), icongeom.y(), icongeom.width(), pm.height() );
|
|
|
|
after = QRect( x(), y(), width(), pm.height() );
|
|
|
|
}
|
2000-06-28 13:20:42 +00:00
|
|
|
|
2000-06-23 16:26:44 +00:00
|
|
|
lf = (after.left() - before.left())/step;
|
2000-06-28 13:20:42 +00:00
|
|
|
rf = (after.right() - before.right())/step;
|
|
|
|
tf = (after.top() - before.top())/step;
|
2000-06-23 16:26:44 +00:00
|
|
|
bf = (after.bottom() - before.bottom())/step;
|
|
|
|
|
|
|
|
|
|
|
|
XGrabServer( qt_xdisplay() );
|
2000-06-28 13:20:42 +00:00
|
|
|
|
2000-06-23 16:26:44 +00:00
|
|
|
QRect area = before;
|
|
|
|
QRect area2;
|
|
|
|
QPixmap pm2;
|
|
|
|
|
|
|
|
QTime t;
|
|
|
|
t.start();
|
|
|
|
float diff;
|
|
|
|
|
|
|
|
QPainter p ( workspace()->desktopWidget() );
|
|
|
|
bool need_to_clear = FALSE;
|
|
|
|
QPixmap pm3;
|
|
|
|
do {
|
|
|
|
if (area2 != area){
|
|
|
|
pm = animationPixmap( area.width() );
|
|
|
|
pm2 = QPixmap::grabWindow( qt_xrootwin(), area.x(), area.y(), area.width(), area.height() );
|
|
|
|
p.drawPixmap( area.x(), area.y(), pm );
|
|
|
|
if ( need_to_clear ) {
|
|
|
|
p.drawPixmap( area2.x(), area2.y(), pm3 );
|
|
|
|
need_to_clear = FALSE;
|
|
|
|
}
|
|
|
|
area2 = area;
|
|
|
|
}
|
|
|
|
XFlush(qt_xdisplay());
|
|
|
|
XSync( qt_xdisplay(), FALSE );
|
|
|
|
diff = t.elapsed();
|
|
|
|
if (diff > step)
|
|
|
|
diff = step;
|
|
|
|
area.setLeft(before.left() + int(diff*lf));
|
|
|
|
area.setRight(before.right() + int(diff*rf));
|
|
|
|
area.setTop(before.top() + int(diff*tf));
|
|
|
|
area.setBottom(before.bottom() + int(diff*bf));
|
|
|
|
if (area2 != area ) {
|
|
|
|
if ( area2.intersects( area ) )
|
|
|
|
p.drawPixmap( area2.x(), area2.y(), pm2 );
|
|
|
|
else { // no overlap, we can clear later to avoid flicker
|
|
|
|
pm3 = pm2;
|
|
|
|
need_to_clear = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while ( t.elapsed() < step);
|
|
|
|
if (area2 == area || need_to_clear )
|
|
|
|
p.drawPixmap( area2.x(), area2.y(), pm2 );
|
2000-06-28 13:20:42 +00:00
|
|
|
|
2000-06-23 16:26:44 +00:00
|
|
|
p.end();
|
|
|
|
XUngrabServer( qt_xdisplay() );
|
|
|
|
}
|
|
|
|
|
2000-07-09 20:29:53 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
The pixmap shown during iconify/deiconify animation
|
|
|
|
*/
|
2000-06-23 16:26:44 +00:00
|
|
|
QPixmap Client::animationPixmap( int w )
|
|
|
|
{
|
|
|
|
QFont font = options->font(isActive());
|
|
|
|
QFontMetrics fm( font );
|
|
|
|
QPixmap pm( w, fm.lineSpacing() );
|
|
|
|
pm.fill( options->color(Options::TitleBar, isActive() || isIconified() ) );
|
|
|
|
QPainter p( &pm );
|
|
|
|
p.setPen(options->color(Options::Font, isActive() || isIconified() ));
|
|
|
|
p.setFont(options->font(isActive()));
|
|
|
|
p.drawText( pm.rect(), AlignLeft|AlignVCenter|SingleLine, caption() );
|
|
|
|
return pm;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-09 20:29:53 +00:00
|
|
|
|
|
|
|
void Client::autoRaise()
|
|
|
|
{
|
|
|
|
workspace()->raiseClient( this );
|
|
|
|
delete autoRaiseTimer;
|
|
|
|
autoRaiseTimer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-25 12:53:17 +00:00
|
|
|
NoBorderClient::NoBorderClient( Workspace *ws, WId w, QWidget *parent, const char *name )
|
1999-08-19 23:26:42 +00:00
|
|
|
: Client( ws, w, parent, name )
|
|
|
|
{
|
1999-11-07 04:43:59 +00:00
|
|
|
QHBoxLayout* h = new QHBoxLayout( this );
|
|
|
|
h->addWidget( windowWrapper() );
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NoBorderClient::~NoBorderClient()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2000-07-16 10:20:29 +00:00
|
|
|
QPixmap * kwin_get_menu_pix_hack()
|
|
|
|
{
|
|
|
|
static QPixmap p;
|
|
|
|
return &p;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-09 00:20:21 +00:00
|
|
|
#include "client.moc"
|
2000-06-08 17:05:51 +00:00
|
|
|
|