2000-05-07 20:38:11 +00:00
|
|
|
/*****************************************************************
|
|
|
|
kwin - the KDE window manager
|
|
|
|
|
|
|
|
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
|
|
|
******************************************************************/
|
1999-08-19 23:26:42 +00:00
|
|
|
#ifndef CLIENT_H
|
|
|
|
#define CLIENT_H
|
|
|
|
|
|
|
|
#include "options.h"
|
|
|
|
#include <qframe.h>
|
|
|
|
#include <qvbox.h>
|
|
|
|
#include <qpixmap.h>
|
2000-05-07 23:10:21 +00:00
|
|
|
#include <qtimer.h>
|
2000-06-22 18:08:35 +00:00
|
|
|
#include <netwm_def.h>
|
1999-08-19 23:26:42 +00:00
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
|
|
|
|
class Workspace;
|
|
|
|
class Client;
|
2000-06-08 17:05:51 +00:00
|
|
|
class WinInfo;
|
1999-08-19 23:26:42 +00:00
|
|
|
|
|
|
|
class WindowWrapper : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
WindowWrapper( WId w, Client *parent=0, const char* name=0);
|
|
|
|
~WindowWrapper();
|
|
|
|
|
1999-11-28 20:10:58 +00:00
|
|
|
WId window() const;
|
1999-08-19 23:26:42 +00:00
|
|
|
void releaseWindow();
|
|
|
|
void invalidateWindow();
|
|
|
|
QSize sizeHint() const;
|
|
|
|
QSizePolicy sizePolicy() const;
|
1999-11-22 01:57:51 +00:00
|
|
|
|
2000-03-29 14:53:25 +00:00
|
|
|
void setActive( bool );
|
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
protected:
|
|
|
|
void resizeEvent( QResizeEvent * );
|
|
|
|
void showEvent( QShowEvent* );
|
|
|
|
void hideEvent( QHideEvent* );
|
|
|
|
bool x11Event( XEvent * ); // X11 event
|
|
|
|
|
2000-05-09 10:13:48 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
private:
|
|
|
|
WId win;
|
|
|
|
Time lastMouseEventTime;
|
2000-03-22 11:47:10 +00:00
|
|
|
bool reparented;
|
1999-08-19 23:26:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
inline WId WindowWrapper::window() const
|
|
|
|
{
|
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Client : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
Client( Workspace *ws, WId w, QWidget *parent=0, const char *name=0, WFlags f = 0);
|
|
|
|
~Client();
|
|
|
|
|
1999-11-28 20:10:58 +00:00
|
|
|
WId window() const;
|
|
|
|
WindowWrapper* windowWrapper() const;
|
|
|
|
Workspace* workspace() const;
|
1999-08-19 23:26:42 +00:00
|
|
|
void releaseWindow();
|
|
|
|
void invalidateWindow();
|
1999-11-28 20:10:58 +00:00
|
|
|
WId transientFor() const;
|
|
|
|
bool isTransient() const;
|
|
|
|
Client* mainClient();
|
2000-06-22 18:08:35 +00:00
|
|
|
NET::WindowType windowType() const;
|
1999-08-19 23:26:42 +00:00
|
|
|
|
|
|
|
virtual bool windowEvent( XEvent * );
|
|
|
|
|
2000-07-15 01:12:41 +00:00
|
|
|
bool manage( bool isMapped = FALSE, bool doNotShow = FALSE );
|
1999-08-19 23:26:42 +00:00
|
|
|
|
|
|
|
void setMappingState( int s );
|
|
|
|
int mappingState() const;
|
|
|
|
|
|
|
|
void requestActivation();
|
|
|
|
void withdraw();
|
|
|
|
|
|
|
|
QSize adjustedSize( const QSize& ) const;
|
|
|
|
|
1999-11-28 20:10:58 +00:00
|
|
|
QPixmap icon() const;
|
|
|
|
QPixmap miniIcon() const;
|
1999-08-19 23:26:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
// is the window in withdrawn state?
|
|
|
|
bool isWithdrawn(){
|
|
|
|
return state == WithdrawnState;
|
|
|
|
}
|
|
|
|
// is the window in iconic state?
|
|
|
|
bool isIconified(){
|
|
|
|
return state == IconicState;
|
|
|
|
}
|
|
|
|
// is the window in normal state?
|
|
|
|
bool isNormal(){
|
|
|
|
return state == NormalState;
|
|
|
|
}
|
|
|
|
|
1999-11-28 20:10:58 +00:00
|
|
|
bool isActive() const;
|
1999-08-19 23:26:42 +00:00
|
|
|
void setActive( bool );
|
|
|
|
|
|
|
|
int desktop() const;
|
1999-11-22 01:57:51 +00:00
|
|
|
void setDesktop( int );
|
1999-08-19 23:26:42 +00:00
|
|
|
bool isOnDesktop( int d ) const;
|
|
|
|
|
|
|
|
bool isShade() const;
|
|
|
|
virtual void setShade( bool );
|
2000-07-28 22:06:22 +00:00
|
|
|
void giveUpShade();
|
1999-08-19 23:26:42 +00:00
|
|
|
|
1999-11-28 20:10:58 +00:00
|
|
|
bool isMaximized() const;
|
2000-08-16 12:18:56 +00:00
|
|
|
enum MaximizeMode { MaximizeVertical, MaximizeHorizontal, MaximizeFull, MaximizeRestore, MaximizeAdjust };
|
|
|
|
bool isMaximizable() const;
|
1999-08-19 23:26:42 +00:00
|
|
|
|
1999-11-28 20:10:58 +00:00
|
|
|
bool isSticky() const;
|
1999-08-19 23:26:42 +00:00
|
|
|
void setSticky( bool );
|
|
|
|
|
2000-06-28 13:20:42 +00:00
|
|
|
bool staysOnTop() const;
|
|
|
|
void setStaysOnTop( bool );
|
2000-06-23 16:26:44 +00:00
|
|
|
|
2000-06-22 18:08:35 +00:00
|
|
|
// auxiliary functions, depend on the windowType
|
|
|
|
bool wantsTabFocus() const;
|
|
|
|
bool isMovable() const;
|
|
|
|
bool isDesktop() const;
|
|
|
|
bool isDock() const;
|
2000-07-10 15:54:17 +00:00
|
|
|
bool isMenu() const;
|
2000-07-13 20:38:10 +00:00
|
|
|
|
2000-07-13 17:59:12 +00:00
|
|
|
bool isResizable() const;
|
2000-05-30 05:52:11 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
void takeFocus();
|
|
|
|
|
1999-09-27 16:02:44 +00:00
|
|
|
void setMask( const QRegion & );
|
2000-05-03 00:04:26 +00:00
|
|
|
const QRegion& getMask() const;
|
1999-11-02 00:32:31 +00:00
|
|
|
|
1999-09-27 16:02:44 +00:00
|
|
|
// transparent stuff
|
|
|
|
virtual void drawbound( const QRect& geom );
|
|
|
|
virtual void clearbound();
|
1999-11-14 06:34:28 +00:00
|
|
|
|
|
|
|
|
1999-11-12 03:11:19 +00:00
|
|
|
// shape extensions
|
|
|
|
bool shape() const;
|
|
|
|
void updateShape();
|
1999-09-27 16:02:44 +00:00
|
|
|
|
1999-11-13 00:32:36 +00:00
|
|
|
void setGeometry( int x, int y, int w, int h );
|
|
|
|
void setGeometry( const QRect &r )
|
|
|
|
{ setGeometry( r.left(), r.top(), r.width(), r.height() ); }
|
|
|
|
void move( int x, int y );
|
|
|
|
void move( const QPoint & p )
|
|
|
|
{ move( p.x(), p.y() ); }
|
1999-11-15 00:52:05 +00:00
|
|
|
|
1999-12-01 22:09:32 +00:00
|
|
|
bool providesContextHelp() const;
|
1999-11-15 00:52:05 +00:00
|
|
|
|
1999-11-29 02:06:41 +00:00
|
|
|
bool performMouseCommand( Options::MouseCommand, QPoint globalPos );
|
2000-03-29 14:53:25 +00:00
|
|
|
|
2000-03-24 22:23:02 +00:00
|
|
|
QCString windowRole();
|
|
|
|
QCString sessionId();
|
2000-06-22 18:08:35 +00:00
|
|
|
|
2000-06-08 17:05:51 +00:00
|
|
|
QRect adjustedClientArea( const QRect& area ) const;
|
2000-06-28 13:20:42 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
public slots:
|
|
|
|
void iconify();
|
|
|
|
void closeWindow();
|
2000-05-17 23:02:42 +00:00
|
|
|
void killWindow();
|
1999-08-19 23:26:42 +00:00
|
|
|
void maximize( MaximizeMode );
|
|
|
|
void maximize();
|
|
|
|
void toggleSticky();
|
1999-12-01 22:09:32 +00:00
|
|
|
void contextHelp();
|
2000-07-09 20:29:53 +00:00
|
|
|
void autoRaise();
|
2000-07-12 12:46:58 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
protected:
|
|
|
|
void paintEvent( QPaintEvent * );
|
|
|
|
void mousePressEvent( QMouseEvent * );
|
|
|
|
void mouseReleaseEvent( QMouseEvent * );
|
|
|
|
void mouseMoveEvent( QMouseEvent * );
|
1999-12-06 00:43:55 +00:00
|
|
|
void keyPressEvent( QKeyEvent * );
|
1999-11-16 01:25:42 +00:00
|
|
|
void resizeEvent( QResizeEvent * );
|
1999-11-22 01:57:51 +00:00
|
|
|
virtual void windowWrapperShowEvent( QShowEvent* ){}
|
|
|
|
virtual void windowWrapperHideEvent( QHideEvent* ){}
|
1999-08-19 23:26:42 +00:00
|
|
|
void enterEvent( QEvent * );
|
|
|
|
void leaveEvent( QEvent * );
|
|
|
|
void showEvent( QShowEvent* );
|
|
|
|
void hideEvent( QHideEvent* );
|
|
|
|
bool x11Event( XEvent * ); // X11 event
|
2000-05-26 13:54:50 +00:00
|
|
|
|
2000-05-11 03:31:54 +00:00
|
|
|
virtual void activateLayout();
|
1999-08-19 23:26:42 +00:00
|
|
|
|
|
|
|
bool eventFilter( QObject *, QEvent * );
|
|
|
|
|
|
|
|
|
|
|
|
virtual void init();
|
|
|
|
virtual void captionChange( const QString& name );
|
|
|
|
virtual void iconChange();
|
|
|
|
virtual void activeChange( bool );
|
|
|
|
virtual void maximizeChange( bool );
|
|
|
|
virtual void stickyChange( bool );
|
|
|
|
|
|
|
|
|
|
|
|
enum MousePosition {
|
|
|
|
Nowhere, TopLeft , BottomRight, BottomLeft, TopRight, Top, Bottom, Left, Right, Center
|
|
|
|
};
|
|
|
|
|
|
|
|
virtual MousePosition mousePosition( const QPoint& ) const;
|
|
|
|
virtual void setMouseCursor( MousePosition m );
|
|
|
|
|
2000-06-28 13:20:42 +00:00
|
|
|
|
2000-06-23 16:26:44 +00:00
|
|
|
virtual void animateIconifyOrDeiconify( bool iconify );
|
|
|
|
virtual QPixmap animationPixmap( int w );
|
|
|
|
|
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
// handlers for X11 events
|
|
|
|
bool mapRequest( XMapRequestEvent& e );
|
|
|
|
bool unmapNotify( XUnmapEvent& e );
|
|
|
|
bool configureRequest( XConfigureRequestEvent& e );
|
|
|
|
bool propertyNotify( XPropertyEvent& e );
|
1999-11-28 20:10:58 +00:00
|
|
|
bool clientMessage( XClientMessageEvent& e );
|
1999-08-19 23:26:42 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QSize sizeForWindowSize( const QSize&, bool ignore_height = FALSE ) const;
|
|
|
|
void getWmNormalHints();
|
|
|
|
void fetchName();
|
|
|
|
void gravitate( bool invert );
|
|
|
|
|
|
|
|
|
|
|
|
WId win;
|
|
|
|
WindowWrapper* wwrap;
|
|
|
|
Workspace* wspace;
|
|
|
|
int desk;
|
|
|
|
bool buttonDown;
|
1999-09-27 16:02:44 +00:00
|
|
|
bool moveResizeMode;
|
|
|
|
bool isMove() const {
|
|
|
|
return moveResizeMode && mode == Center;
|
|
|
|
}
|
|
|
|
bool isResize() const {
|
1999-11-28 16:25:59 +00:00
|
|
|
return moveResizeMode && !isMove();
|
1999-09-27 16:02:44 +00:00
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
MousePosition mode;
|
|
|
|
QPoint moveOffset;
|
|
|
|
QPoint invertedMoveOffset;
|
|
|
|
QSize clientSize;
|
|
|
|
XSizeHints xSizeHint;
|
|
|
|
void sendSynteticConfigureNotify();
|
|
|
|
int state;
|
|
|
|
QRect original_geometry;
|
1999-09-27 16:02:44 +00:00
|
|
|
QRect geom; //### TODO
|
1999-08-19 23:26:42 +00:00
|
|
|
WId transient_for;
|
2000-08-10 13:01:12 +00:00
|
|
|
uint transient_for_defined;
|
2000-06-22 18:08:35 +00:00
|
|
|
uint shaded :1;
|
|
|
|
uint active :1;
|
|
|
|
uint is_sticky :1;
|
2000-06-28 13:20:42 +00:00
|
|
|
uint stays_on_top : 1;
|
2000-06-22 18:08:35 +00:00
|
|
|
uint is_shape :1;
|
|
|
|
uint may_move :1;
|
2000-08-09 10:02:56 +00:00
|
|
|
uint skip_taskbar :1;
|
1999-08-19 23:26:42 +00:00
|
|
|
uint Pdeletewindow :1; // does the window understand the DeleteWindow protocol?
|
|
|
|
uint Ptakefocus :1;// does the window understand the TakeFocus protocol?
|
1999-12-01 22:09:32 +00:00
|
|
|
uint Pcontexthelp : 1; // does the window understand the ContextHelp protocol?
|
1999-11-28 20:10:58 +00:00
|
|
|
uint input :1; // does the window want input in its wm_hints
|
1999-11-22 01:57:51 +00:00
|
|
|
uint mapped :1; // keeps track of our visiblity within the asynchronous event flow
|
2000-06-22 18:08:35 +00:00
|
|
|
void getWMHints();
|
|
|
|
void getWindowProtocols();
|
1999-08-19 23:26:42 +00:00
|
|
|
QPixmap icon_pix;
|
|
|
|
QPixmap miniicon_pix;
|
|
|
|
QRect geom_restore;
|
2000-08-16 12:18:56 +00:00
|
|
|
MaximizeMode max_mode;
|
1999-09-27 16:02:44 +00:00
|
|
|
QRegion mask;
|
2000-06-08 17:05:51 +00:00
|
|
|
WinInfo* info;
|
2000-07-09 20:29:53 +00:00
|
|
|
QTimer* autoRaiseTimer;
|
Preliminary support for avoiding covering clients such as kicker
which want to be permanently visible.
I've used an XAtom called '_NET_AVOID_SPEC'. This of course can change
if need be. I think it's correct according to the wm spec, but the
wm spec seems to be empty on gnome.org, so who knows.
Windows can choose to be avoided by setting an XTextProperty
with one value, which can be either 'N', 'S', 'E', or 'W', according
to which screen edge they are anchored to.
kwin then sets its 'clientArea' rect appropriately, so that (in
theory at least) clients will not enter this area in some circumstances,
such as when being mapped for the first time.
You can see that this actually works if you start lots of konsoles. They
don't appear over the panel. I don't know what happens if you move the
panel, but I presume things will be screwed up, because I haven't
looked at that yet.
If you maximise a window, it'll still fill the screen, because the
implementation of maximise in kwin/client.cpp doesn't take account
of the workspace's clientArea rect. This is easy to fix, but I've
been awake for too long, so I'll do it after 42 winks.
svn path=/trunk/kdebase/kwin/; revision=46772
2000-04-16 09:06:03 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
inline WId Client::window() const
|
|
|
|
{
|
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline WindowWrapper* Client::windowWrapper() const
|
|
|
|
{
|
|
|
|
return wwrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline Workspace* Client::workspace() const
|
|
|
|
{
|
|
|
|
return wspace;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline WId Client::transientFor() const
|
|
|
|
{
|
|
|
|
return transient_for;
|
|
|
|
}
|
|
|
|
|
1999-11-28 20:10:58 +00:00
|
|
|
inline bool Client::isTransient() const
|
|
|
|
{
|
2000-08-10 13:01:12 +00:00
|
|
|
return transient_for != 0 || transient_for_defined;
|
1999-11-28 20:10:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
inline int Client::mappingState() const
|
|
|
|
{
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline bool Client::isActive() const
|
|
|
|
{
|
|
|
|
return active;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the virtual desktop within the workspace() the client window
|
|
|
|
is located in, -1 if it isn't located on any special desktop. This may be
|
|
|
|
if the window wasn't mapped yet or if the window is sticky. Do not use
|
|
|
|
desktop() directly, use isOnDesktop() instead.
|
|
|
|
*/
|
|
|
|
inline int Client::desktop() const
|
|
|
|
{
|
|
|
|
return desk;
|
|
|
|
}
|
|
|
|
|
2000-07-12 12:46:58 +00:00
|
|
|
inline bool Client::isSticky() const
|
|
|
|
{
|
|
|
|
return is_sticky;
|
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
/*!
|
|
|
|
Returns whether the client is on visible or iconified on the virtual
|
|
|
|
desktop \a d. This is always TRUE for sticky clients.
|
|
|
|
*/
|
|
|
|
inline bool Client::isOnDesktop( int d ) const
|
|
|
|
{
|
|
|
|
return desk == d || desk == -1 || isSticky();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline QPixmap Client::icon() const
|
|
|
|
{
|
|
|
|
return icon_pix;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QPixmap Client::miniIcon() const
|
|
|
|
{
|
|
|
|
return miniicon_pix;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Is the client maximized?
|
|
|
|
*/
|
|
|
|
inline bool Client::isMaximized() const
|
|
|
|
{
|
|
|
|
return !geom_restore.isNull();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-28 13:20:42 +00:00
|
|
|
inline bool Client::staysOnTop() const
|
|
|
|
{
|
|
|
|
return stays_on_top;
|
|
|
|
}
|
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
|
1999-11-12 03:11:19 +00:00
|
|
|
inline bool Client::shape() const
|
|
|
|
{
|
|
|
|
return is_shape;
|
|
|
|
}
|
|
|
|
|
2000-05-03 00:04:26 +00:00
|
|
|
inline const QRegion& Client::getMask() const
|
|
|
|
{
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
class NoBorderClient : public Client
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
NoBorderClient( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 );
|
|
|
|
~NoBorderClient();
|
1999-11-17 17:25:26 +00:00
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|