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;
|
2000-10-14 23:44:24 +00:00
|
|
|
class NETWinInfo;
|
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 );
|
|
|
|
|
2000-10-17 12:51:39 +00:00
|
|
|
void show();
|
|
|
|
void hide();
|
|
|
|
|
|
|
|
void map();
|
|
|
|
void unmap();
|
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
protected:
|
|
|
|
void resizeEvent( QResizeEvent * );
|
|
|
|
bool x11Event( XEvent * ); // X11 event
|
|
|
|
|
2000-12-06 15:03:59 +00:00
|
|
|
private slots:
|
|
|
|
void deferredResize();
|
|
|
|
|
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-09-11 18:59:26 +00:00
|
|
|
bool manage( bool isMapped = FALSE, bool doNotShow = FALSE, bool isInitial = TRUE );
|
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-11-17 19:43:20 +00:00
|
|
|
enum MaximizeMode { MaximizeRestore = 0, MaximizeVertical = 1, MaximizeHorizontal = 2, MaximizeFull = 3, MaximizeAdjust };
|
2000-08-16 12:18:56 +00:00
|
|
|
bool isMaximizable() const;
|
2000-08-30 14:27:30 +00:00
|
|
|
QRect geometryRestore() const;
|
|
|
|
MaximizeMode maximizeMode() const;
|
2000-09-25 15:30:51 +00:00
|
|
|
bool isMinimizable() 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;
|
2000-09-25 15:30:51 +00:00
|
|
|
bool wantsInput() const;
|
2000-06-22 18:08:35 +00:00
|
|
|
bool isMovable() const;
|
|
|
|
bool isDesktop() const;
|
|
|
|
bool isDock() const;
|
2000-09-25 15:30:51 +00:00
|
|
|
bool isTool() 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
|
|
|
|
2000-09-11 20:54:00 +00:00
|
|
|
void takeFocus( bool force = FALSE );
|
1999-08-19 23:26:42 +00:00
|
|
|
|
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
|
|
|
|
2000-09-25 15:30:51 +00:00
|
|
|
// fullscreen hint, for stacking
|
|
|
|
bool isFullScreen() const;
|
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-08-30 14:27:30 +00:00
|
|
|
QCString wmCommand();
|
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
|
|
|
|
2000-08-30 14:27:30 +00:00
|
|
|
Colormap colormap() const;
|
|
|
|
|
2000-09-11 18:59:26 +00:00
|
|
|
void cloneMode(Client *);
|
|
|
|
|
2000-10-17 12:51:39 +00:00
|
|
|
void show();
|
|
|
|
void hide();
|
|
|
|
|
2000-11-17 19:43:20 +00:00
|
|
|
void maximizeRaw( bool vertically, bool horizontally );
|
|
|
|
|
1999-08-19 23:26:42 +00:00
|
|
|
public slots:
|
|
|
|
void iconify();
|
|
|
|
void closeWindow();
|
2000-05-17 23:02:42 +00:00
|
|
|
void killWindow();
|
2000-11-17 19:43:20 +00:00
|
|
|
void maximize( MaximizeMode m );
|
1999-08-19 23:26:42 +00:00
|
|
|
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 * );
|
|
|
|
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 );
|
2000-09-11 20:54:00 +00:00
|
|
|
|
2000-10-14 23:44:24 +00:00
|
|
|
NETWinInfo * netWinInfo();
|
|
|
|
|
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-09-25 15:30:51 +00:00
|
|
|
uint is_fullscreen :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
|
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;
|
2000-08-30 14:27:30 +00:00
|
|
|
Colormap cmap;
|
2000-10-15 14:19:15 +00:00
|
|
|
void verifyTransientFor();
|
2000-12-06 15:03:59 +00:00
|
|
|
friend class WindowWrapper;
|
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
|
|
|
|
{
|
2000-08-30 14:27:30 +00:00
|
|
|
return max_mode != MaximizeRestore;
|
1999-08-19 23:26:42 +00:00
|
|
|
}
|
|
|
|
|
2000-08-30 14:27:30 +00:00
|
|
|
inline QRect Client::geometryRestore() const
|
|
|
|
{
|
|
|
|
return geom_restore;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline Client::MaximizeMode Client::maximizeMode() const
|
|
|
|
{
|
|
|
|
return max_mode;
|
|
|
|
}
|
1999-08-19 23:26:42 +00:00
|
|
|
|
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-09-25 15:30:51 +00:00
|
|
|
|
|
|
|
inline bool Client::isFullScreen() const
|
|
|
|
{
|
|
|
|
return is_fullscreen;
|
|
|
|
}
|
|
|
|
|
2000-05-03 00:04:26 +00:00
|
|
|
inline const QRegion& Client::getMask() const
|
|
|
|
{
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
2000-08-30 14:27:30 +00:00
|
|
|
|
|
|
|
inline Colormap Client::colormap() const
|
|
|
|
{
|
|
|
|
return cmap;
|
|
|
|
}
|
|
|
|
|
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
|