Suspend updating of window-specific settings during shutdown,

so that KWin doesn't have to be killed as the first one during shutdown.


svn path=/trunk/KDE/kdebase/workspace/; revision=645397
icc-effect-5.14.5
Luboš Luňák 2007-03-22 14:27:04 +00:00
parent 81fdcfd20b
commit 082c4e95e3
5 changed files with 323 additions and 262 deletions

262
client.h
View File

@ -28,7 +28,6 @@ License. See the file "COPYING" for the exact licensing terms.
#include "workspace.h"
#include "kdecoration.h"
#include "rules.h"
#include "toplevel.h"
class QTimer;
class KProcess;
@ -39,18 +38,21 @@ namespace KWinInternal
class Workspace;
class Client;
class WinInfo;
class SessionInfo;
class Bridge;
class Client
: public Toplevel
class Client : public QObject, public KDecorationDefines
{
Q_OBJECT
public:
Client( Workspace *ws );
Window window() const;
Window frameId() const;
Window wrapperId() const;
Window decorationId() const;
Workspace* workspace() const;
const Client* transientFor() const;
Client* transientFor();
bool isTransient() const;
@ -64,20 +66,25 @@ class Client
const Group* group() const;
Group* group();
void checkGroup( Group* gr = NULL, bool force = false );
void changeClientLeaderGroup( Group* gr );
// prefer isXXX() instead
NET::WindowType windowType( bool direct = false, int supported_types = SUPPORTED_WINDOW_TYPES_MASK ) const;
const WindowRules* rules() const;
void removeRule( Rules* r );
void setupWindowRules( bool ignore_temporary );
void applyWindowRules();
void updateWindowRules();
// returns true for "special" windows and false for windows which are "normal"
// (normal=window which has a border, can be moved by the user, can be closed, etc.)
// true for Desktop, Dock, Splash, Override and TopMenu (and Toolbar??? - for now)
// false for Normal, Dialog, Utility and Menu (and Toolbar??? - not yet) TODO
bool isSpecialWindow() const;
bool hasNETSupport() const;
QRect geometry() const;
QSize size() const;
QSize minSize() const;
QSize maxSize() const;
QPoint pos() const;
QRect rect() const;
int x() const;
int y() const;
int width() const;
int height() const;
QPoint clientPos() const; // inside of geometry()
QSize clientSize() const;
@ -85,8 +92,8 @@ class Client
virtual bool eventFilter( QObject* o, QEvent* e );
bool manage( Window w, bool isMapped );
void releaseWindow( bool on_shutdown = false );
void destroyClient();
enum Sizemode // how to resize the window in order to obey constains (mainly aspect ratios)
{
@ -104,8 +111,11 @@ class Client
bool isActive() const;
void setActive( bool );
virtual int desktop() const;
int desktop() const;
void setDesktop( int );
bool isOnDesktop( int d ) const;
bool isOnCurrentDesktop() const;
bool isOnAllDesktops() const;
void setOnAllDesktops( bool set );
// !isMinimized() && not hidden, i.e. normally visible on some virtual desktop
@ -123,7 +133,6 @@ class Client
MaximizeMode maximizeMode() const;
bool isMinimizable() const;
void setMaximize( bool vertically, bool horizontally );
QRect iconGeometry() const;
void setFullScreen( bool set, bool user );
bool isFullScreen() const;
@ -158,9 +167,24 @@ class Client
// auxiliary functions, depend on the windowType
bool wantsTabFocus() const;
bool wantsInput() const;
bool hasNETSupport() const;
bool isMovable() const;
bool isDesktop() const;
bool isDock() const;
bool isToolbar() const;
bool isTopMenu() const;
bool isMenu() const;
bool isNormalWindow() const; // normal as in 'NET::Normal or NET::Unknown non-transient'
bool isDialog() const;
bool isSplash() const;
bool isUtility() const;
// returns true for "special" windows and false for windows which are "normal"
// (normal=window which has a border, can be moved by the user, can be closed, etc.)
// true for Desktop, Dock, Splash, Override and TopMenu (and Toolbar??? - for now)
// false for Normal, Dialog, Utility and Menu (and Toolbar??? - not yet) TODO
bool isSpecialWindow() const;
bool isResizable() const;
bool isMovable() const;
bool isCloseable() const; // may be closed by the user (may have a close button)
void takeActivity( int flags, bool handled, allowed_t ); // takes ActivityFlags as arg (in utils.h)
@ -173,8 +197,10 @@ class Client
void updateDecoration( bool check_workspace_pos, bool force = false );
void checkBorderSizes();
// shape extensions
bool shape() const;
void updateShape();
void setGeometry( int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet );
void setGeometry( const QRect& r, ForceGeometry_t force = NormalGeometrySet );
void move( int x, int y, ForceGeometry_t force = NormalGeometrySet );
@ -198,6 +224,15 @@ class Client
bool performMouseCommand( Options::MouseCommand, QPoint globalPos, bool handled = false );
QByteArray windowRole() const;
QByteArray sessionId();
QByteArray resourceName() const;
QByteArray resourceClass() const;
QByteArray wmCommand();
QByteArray wmClientMachine( bool use_localhost ) const;
Window wmClientLeader() const;
pid_t pid() const;
QRect adjustedClientArea( const QRect& desktop, const QRect& area ) const;
Colormap colormap() const;
@ -222,6 +257,12 @@ class Client
void gotPing( Time timestamp );
static QByteArray staticWindowRole(WId);
static QByteArray staticSessionId(WId);
static QByteArray staticWmCommand(WId);
static QByteArray staticWmClientMachine(WId);
static Window staticWmClientLeader(WId);
void checkWorkspacePosition();
void updateUserTime( Time time = CurrentTime );
Time userTime() const;
@ -231,8 +272,8 @@ class Client
// does 'delete c;'
static void deleteClient( Client* c, allowed_t );
static bool resourceMatch( const Client* c1, const Client* c2 );
static bool belongToSameApplication( const Client* c1, const Client* c2, bool active_hack = false );
static bool sameAppWindowRoleMatch( const Client* c1, const Client* c2, bool active_hack );
static void readIcons( Window win, QPixmap* icon, QPixmap* miniicon );
void minimize( bool avoid_animation = false );
@ -244,18 +285,10 @@ class Client
void showContextHelp();
void cancelShadeHover();
void cancelAutoRaise();
void destroyClient();
void checkActiveModal();
bool hasStrut() const;
bool isMove() const
{
return moveResizeMode && mode == PositionCenter;
}
bool isResize() const
{
return moveResizeMode && mode != PositionCenter;
}
private slots:
void autoRaise();
void shadeHover();
@ -273,6 +306,8 @@ class Client
void setCursor( Position m );
void setCursor( const QCursor& c );
void animateMinimizeOrUnminimize( bool minimize );
QPixmap animationPixmap( int w );
// transparent stuff
void drawbound( const QRect& geom );
void clearbound();
@ -283,11 +318,10 @@ class Client
void unmapNotifyEvent( XUnmapEvent*e );
void destroyNotifyEvent( XDestroyWindowEvent*e );
void configureRequestEvent( XConfigureRequestEvent* e );
virtual void propertyNotifyEvent( XPropertyEvent* e );
void propertyNotifyEvent( XPropertyEvent* e );
void clientMessageEvent( XClientMessageEvent* e );
void enterNotifyEvent( XCrossingEvent* e );
void leaveNotifyEvent( XCrossingEvent* e );
void visibilityNotifyEvent( XVisibilityEvent* e );
void focusInEvent( XFocusInEvent* e );
void focusOutEvent( XFocusOutEvent* e );
@ -297,9 +331,6 @@ class Client
void processDecorationButtonPress( int button, int state, int x, int y, int x_root, int y_root );
protected:
virtual void debug( kdbgstream& stream ) const;
private slots:
void pingTimeout();
void processKillerExited();
@ -321,12 +352,13 @@ class Client
void getWmNormalHints();
void getMotifHints();
void getIcons();
void getWmClientLeader();
void getWmClientMachine();
void fetchName();
void fetchIconicName();
QString readName() const;
void setCaption( const QString& s, bool force = false );
bool hasTransientInternal( const Client* c, bool indirect, ConstClientList& set ) const;
void updateWindowRules();
void finishWindowRules();
void setShortcutInternal( const KShortcut& cut );
@ -336,7 +368,7 @@ class Client
void configureRequest( int value_mask, int rx, int ry, int rw, int rh, int gravity, bool from_tool );
NETExtendedStrut strut() const;
int checkShadeGeometry( int w, int h );
void blockGeometryUpdates( bool block );
void postponeGeometryUpdates( bool postpone );
bool startMoveResize();
void finishMoveResize( bool cancel );
@ -366,11 +398,14 @@ class Client
Time readUserTimeMapTimestamp( const KStartupInfoId* asn_id, const KStartupInfoData* asn_data,
bool session ) const;
Time readUserCreationTime() const;
static bool sameAppWindowRoleMatch( const Client* c1, const Client* c2, bool active_hack );
void startupIdChanged();
Window client;
Window wrapper;
Window frame;
KDecoration* decoration;
Workspace* wspace;
Bridge* bridge;
int desk;
bool buttonDown;
@ -378,6 +413,14 @@ class Client
bool move_faked_activity;
Window move_resize_grab_window;
bool unrestrictedMoveResize;
bool isMove() const
{
return moveResizeMode && mode == PositionCenter;
}
bool isResize() const
{
return moveResizeMode && mode != PositionCenter;
}
Position mode;
QPoint moveOffset;
@ -403,6 +446,7 @@ class Client
uint active :1;
uint deleting : 1; // true when doing cleanup and destroying the client
uint keep_above : 1; // NET::KeepAbove (was stays_on_top)
uint is_shape :1;
uint skip_taskbar :1;
uint original_skip_taskbar :1; // unaffected by KWin
uint Pdeletewindow :1; // does the window understand the DeleteWindow protocol?
@ -422,7 +466,6 @@ class Client
uint modal : 1; // NET::Modal
uint noborder : 1;
uint user_noborder : 1;
uint not_obscured : 1;
uint urgency : 1; // XWMHints, UrgencyHint
uint ignore_focus_stealing : 1; // don't apply focus stealing prevention to this client
uint demands_attention : 1;
@ -442,10 +485,16 @@ class Client
QRect geom_fs_restore;
MaximizeMode maxmode_restore;
int workarea_diff_x, workarea_diff_y;
WinInfo* info;
QTimer* autoRaiseTimer;
QTimer* shadeHoverTimer;
Colormap cmap;
QByteArray resource_name;
QByteArray resource_class;
QByteArray client_machine;
QString cap_normal, cap_iconic, cap_suffix;
WId wmClientLeaderWin;
QByteArray window_role;
Group* in_group;
Window window_group;
Layer in_layer;
@ -454,10 +503,10 @@ class Client
Time ping_timestamp;
Time user_time;
unsigned long allowed_actions;
QRect frame_geometry;
QSize client_size;
int block_geometry_updates; // >0 - new geometry is remembered, but not actually set
int postpone_geometry_updates; // >0 - new geometry is remembered, but not actually set
bool pending_geometry_update;
QRect geom_before_block;
bool shade_geometry_change;
int border_left, border_right, border_top, border_bottom;
QRegion _mask;
@ -467,20 +516,22 @@ class Client
friend struct FetchNameInternalPredicate;
friend struct CheckIgnoreFocusStealingProcedure;
friend struct ResetupRulesProcedure;
friend class GeometryUpdatesBlocker;
friend class GeometryUpdatesPostponer;
void show() { assert( false ); } // SELI remove after Client is no longer QWidget
void hide() { assert( false ); }
QTimer* demandAttentionKNotifyTimer;
friend bool performTransiencyCheck();
};
// helper for Client::blockGeometryUpdates() being called in pairs (true/false)
class GeometryUpdatesBlocker
// helper for Client::postponeGeometryUpdates() being called in pairs (true/false)
class GeometryUpdatesPostponer
{
public:
GeometryUpdatesBlocker( Client* c )
: cl( c ) { cl->blockGeometryUpdates( true ); }
~GeometryUpdatesBlocker()
{ cl->blockGeometryUpdates( false ); }
GeometryUpdatesPostponer( Client* c )
: cl( c ) { cl->postponeGeometryUpdates( true ); }
~GeometryUpdatesPostponer()
{ cl->postponeGeometryUpdates( false ); }
private:
Client* cl;
};
@ -496,11 +547,20 @@ class WinInfo : public NETWinInfo
Window rwin, const unsigned long pr[], int pr_size );
virtual void changeDesktop(int desktop);
virtual void changeState( unsigned long state, unsigned long mask );
void disable();
private:
Client * m_client;
};
inline Window Client::window() const
{
return client;
}
inline Window Client::frameId() const
{
return frame;
}
inline Window Client::wrapperId() const
{
return wrapper;
@ -511,6 +571,11 @@ inline Window Client::decorationId() const
return decoration != NULL ? decoration->widget()->winId() : None;
}
inline Workspace* Client::workspace() const
{
return wspace;
}
inline const Client* Client::transientFor() const
{
return transient_for;
@ -558,6 +623,16 @@ inline int Client::mappingState() const
return mapping_state;
}
inline QByteArray Client::resourceName() const
{
return resource_name; // it is always lowercase
}
inline QByteArray Client::resourceClass() const
{
return resource_class; // it is always lowercase
}
inline
bool Client::isMinimized() const
{
@ -569,6 +644,30 @@ inline bool Client::isActive() const
return active;
}
/*!
Returns the virtual desktop within the workspace() the client window
is located in, 0 if it isn't located on any special desktop (not mapped yet),
or NET::OnAllDesktops. Do not use desktop() directly, use
isOnDesktop() instead.
*/
inline int Client::desktop() const
{
return desk;
}
inline bool Client::isOnAllDesktops() const
{
return desk == NET::OnAllDesktops;
}
/*!
Returns whether the client is on the virtual desktop \a d.
This is always true for onAllDesktops clients.
*/
inline bool Client::isOnDesktop( int d ) const
{
return desk == d || /*desk == 0 ||*/ isOnAllDesktops();
}
inline
bool Client::isShown( bool shaded_is_shown ) const
{
@ -632,6 +731,12 @@ inline bool Client::keepBelow() const
return keep_below;
}
inline bool Client::shape() const
{
return is_shape;
}
inline bool Client::isFullScreen() const
{
return fullscreen_mode != FullScreenNone;
@ -652,6 +757,11 @@ inline Colormap Client::colormap() const
return cmap;
}
inline pid_t Client::pid() const
{
return info->pid();
}
inline void Client::invalidateLayer()
{
in_layer = UnknownLayer;
@ -677,6 +787,51 @@ inline bool Client::isManaged() const
return mapping_state != WithdrawnState;
}
inline QByteArray Client::windowRole() const
{
return window_role;
}
inline QRect Client::geometry() const
{
return frame_geometry;
}
inline QSize Client::size() const
{
return frame_geometry.size();
}
inline QPoint Client::pos() const
{
return frame_geometry.topLeft();
}
inline int Client::x() const
{
return frame_geometry.x();
}
inline int Client::y() const
{
return frame_geometry.y();
}
inline int Client::width() const
{
return frame_geometry.width();
}
inline int Client::height() const
{
return frame_geometry.height();
}
inline QRect Client::rect() const
{
return QRect( 0, 0, width(), height());
}
inline QPoint Client::clientPos() const
{
return QPoint( border_left, border_top );
@ -722,7 +877,7 @@ inline const WindowRules* Client::rules() const
return &client_rules;
}
KWIN_PROCEDURE( CheckIgnoreFocusStealingProcedure, Client, cl->ignore_focus_stealing = options->checkIgnoreFocusStealing( cl ));
KWIN_PROCEDURE( CheckIgnoreFocusStealingProcedure, cl->ignore_focus_stealing = options->checkIgnoreFocusStealing( cl ));
inline Window Client::moveResizeGrabWindow() const
{
@ -739,7 +894,22 @@ inline void Client::removeRule( Rules* rule )
client_rules.remove( rule );
}
KWIN_COMPARE_PREDICATE( WrapperIdMatchPredicate, Client, Window, cl->wrapperId() == value );
#ifdef NDEBUG
inline
kndbgstream& operator<<( kndbgstream& stream, const Client* ) { return stream; }
inline
kndbgstream& operator<<( kndbgstream& stream, const ClientList& ) { return stream; }
inline
kndbgstream& operator<<( kndbgstream& stream, const ConstClientList& ) { return stream; }
#else
kdbgstream& operator<<( kdbgstream& stream, const Client* );
kdbgstream& operator<<( kdbgstream& stream, const ClientList& );
kdbgstream& operator<<( kdbgstream& stream, const ConstClientList& );
#endif
KWIN_COMPARE_PREDICATE( WindowMatchPredicate, Window, cl->window() == value );
KWIN_COMPARE_PREDICATE( FrameIdMatchPredicate, Window, cl->frameId() == value );
KWIN_COMPARE_PREDICATE( WrapperIdMatchPredicate, Window, cl->wrapperId() == value );
} // namespace

View File

@ -850,6 +850,8 @@ void Client::updateWindowRules()
{
if( !isManaged()) // not fully setup yet
return;
if( workspace()->rulesUpdatesDisabled())
return;
client_rules.update( this );
}
@ -1007,6 +1009,14 @@ void Workspace::rulesUpdated()
rulesUpdatedTimer.start( 1000 );
}
void Workspace::disableRulesUpdates( bool disable )
{
rules_updates_disabled = disable;
if( !disable )
foreach( Client* c, clients )
c->updateWindowRules();
}
#endif
} // namespace

37
sm.cpp
View File

@ -11,6 +11,7 @@ License. See the file "COPYING" for the exact licensing terms.
#include "sm.h"
//#include <kdebug.h>
#include <unistd.h>
#include <stdlib.h>
#include <pwd.h>
@ -22,7 +23,6 @@ License. See the file "COPYING" for the exact licensing terms.
#include "client.h"
#include <QSocketNotifier>
#include <qsessionmanager.h>
#include <kdebug.h>
namespace KWinInternal
{
@ -256,28 +256,6 @@ bool Workspace::sessionInfoWindowTypeMatch( Client* c, SessionInfo* info )
return info->windowType == c->windowType();
}
// maybe needed later
#if 0
// KMainWindow's without name() given have WM_WINDOW_ROLE in the form
// of <appname>-mainwindow#<number>
// when comparing them for fake session info, it's probably better to check
// them without the trailing number
bool Workspace::windowRoleMatch( const QByteArray& role1, const QByteArray& role2 )
{
if( role1.isEmpty() && role2.isEmpty())
return true;
int pos1 = role1.find( '#' );
int pos2 = role2.find( '#' );
bool ret;
if( pos1 < 0 || pos2 < 0 || pos1 != pos2 )
ret = role1 == role2;
else
ret = qstrncmp( role1, role2, pos1 ) == 0;
kDebug() << "WR:" << role1 << ":" << pos1 << ":" << role2 << ":" << pos2 << ":::" << ret << endl;
return ret;
}
#endif
static const char* const window_type_names[] =
{
"Unknown", "Normal" , "Desktop", "Dock", "Toolbar", "Menu", "Dialog",
@ -315,11 +293,21 @@ NET::WindowType Workspace::txtToWindowType( const char* txt )
// but Qt doesn't have API for saying when session saved finished (either
// successfully, or was canceled). Therefore, create another connection
// to session manager, that will provide this information.
static void save_yourself( SmcConn conn_P, SmPointer ptr, int, Bool, int, Bool )
// Similarly the remember feature of window-specific settings should be disabled
// during KDE shutdown when windows may move e.g. because of Kicker going away
// (struts changing). When session saving starts, it can be cancelled, in which
// case the shutdown_cancelled callback is invoked, or it's a checkpoint that
// is immediatelly followed by save_complete, or finally it's a shutdown that
// is immediatelly followed by die callback. So getting save_yourself with shutdown
// set disables window-specific settings remembering, getting shutdown_cancelled
// re-enables, otherwise KWin will go away after die.
static void save_yourself( SmcConn conn_P, SmPointer ptr, int, Bool shutdown, int, Bool )
{
SessionSaveDoneHelper* session = reinterpret_cast< SessionSaveDoneHelper* >( ptr );
if( conn_P != session->connection())
return;
if( shutdown )
Workspace::self()->disableRulesUpdates( true );
SmcSaveYourselfDone( conn_P, True );
}
@ -345,6 +333,7 @@ static void shutdown_cancelled( SmcConn conn_P, SmPointer ptr )
SessionSaveDoneHelper* session = reinterpret_cast< SessionSaveDoneHelper* >( ptr );
if( conn_P != session->connection())
return;
Workspace::self()->disableRulesUpdates( false ); // re-enable
// no need to differentiate between successful finish and cancel
session->saveDone();
}

View File

@ -43,10 +43,6 @@ License. See the file "COPYING" for the exact licensing terms.
#include "group.h"
#include "rules.h"
#include "kwinadaptor.h"
#include "unmanaged.h"
#include "scene.h"
#include "deleted.h"
#include "effects.h"
#include <X11/extensions/shape.h>
#include <X11/keysym.h>
@ -80,6 +76,7 @@ Workspace::Workspace( bool restore )
active_popup_client( NULL ),
desktop_widget (0),
temporaryRulesMessages( "_KDE_NET_WM_TEMPORARY_RULES", NULL, false ),
rules_updates_disabled( false ),
active_client (0),
last_active_client (0),
most_recently_raised (0),
@ -98,7 +95,6 @@ Workspace::Workspace( bool restore )
popupinfo (0),
popup (0),
advanced_popup (0),
trans_popup (0),
desk_popup (0),
desk_popup_index (0),
keys (0),
@ -128,16 +124,12 @@ Workspace::Workspace( bool restore )
topmenu_space( NULL ),
set_active_client_recursion( 0 ),
block_stacking_updates( 0 ),
forced_global_mouse_grab( false ),
cm_selection( NULL ),
compositeRate( 0 ),
overlay( None ),
transSlider( NULL ),
transButton( NULL )
forced_global_mouse_grab( false )
{
(void) new KWinAdaptor( this );
QDBusConnection::sessionBus().registerObject("/KWin", this);
QDBusConnection dbus = QDBusConnection::sessionBus();
dbus.registerObject("/KWin", this);
dbus.connect(QString(), "/KWin", "org.kde.KWin", "reloadConfig", this, SLOT(slotReloadConfig()));
_self = this;
mgr = new PluginMgr;
root = rootWindow();
@ -178,12 +170,10 @@ Workspace::Workspace( bool restore )
ColormapChangeMask |
SubstructureRedirectMask |
SubstructureNotifyMask |
FocusChangeMask | // for NotifyDetailNone
ExposureMask
FocusChangeMask // for NotifyDetailNone
);
Extensions::init();
setupCompositing();
Shape::init();
// compatibility
long data = 1;
@ -289,6 +279,7 @@ void Workspace::init()
NET::WM2ExtendedStrut |
NET::WM2KDETemporaryRules |
NET::WM2ShowingDesktop |
NET::WM2DesktopLayout |
0
,
NET::ActionMove |
@ -332,7 +323,6 @@ void Workspace::init()
connect(&reconfigureTimer, SIGNAL(timeout()), this,
SLOT(slotReconfigure()));
connect( &updateToolWindowsTimer, SIGNAL( timeout()), this, SLOT( slotUpdateToolWindows()));
connect( &compositeTimer, SIGNAL( timeout()), SLOT( performCompositing()));
connect(KGlobalSettings::self(), SIGNAL(appearanceChanged()), this,
SLOT(slotReconfigure()));
@ -370,10 +360,7 @@ void Workspace::init()
XWindowAttributes attr;
XGetWindowAttributes(display(), wins[i], &attr);
if (attr.override_redirect )
{
createUnmanaged( wins[ i ] );
continue;
}
if( topmenu_space && topmenu_space->winId() == wins[ i ] )
continue;
if (attr.map_state != IsUnmapped)
@ -435,7 +422,6 @@ void Workspace::init()
Workspace::~Workspace()
{
finishCompositing();
blockStackingUpdates( true );
// TODO grabXServer();
// use stacking_order, so that kwin --replace keeps stacking order
@ -445,12 +431,12 @@ Workspace::~Workspace()
{
// only release the window
(*it)->releaseWindow( true );
// no removeClient() is called !
// No removeClient() is called, it does more than just removing.
// However, remove from some lists to e.g. prevent performTransiencyCheck()
// from crashing.
clients.remove( *it );
desktops.remove( *it );
}
for( UnmanagedList::ConstIterator it = unmanaged.begin();
it != unmanaged.end();
++it )
(*it)->release();
delete desktop_widget;
delete tab_box;
delete popupinfo;
@ -494,28 +480,6 @@ Client* Workspace::createClient( Window w, bool is_mapped )
return NULL;
}
addClient( c, Allowed );
if( scene )
scene->windowAdded( c );
if( effects )
effects->windowAdded( c->effectWindow());
return c;
}
Unmanaged* Workspace::createUnmanaged( Window w )
{
if( w == overlay )
return NULL;
Unmanaged* c = new Unmanaged( this );
if( !c->track( w ))
{
Unmanaged::deleteUnmanaged( c, Allowed );
return NULL;
}
addUnmanaged( c, Allowed );
if( scene )
scene->windowAdded( c );
if( effects )
effects->windowAdded( c->effectWindow());
return c;
}
@ -556,13 +520,7 @@ void Workspace::addClient( Client* c, allowed_t )
updateStackingOrder( true ); // propagate new client
if( c->isUtility() || c->isMenu() || c->isToolbar())
updateToolWindows( true );
if( tab_grab )
tab_box->reset( true );
}
void Workspace::addUnmanaged( Unmanaged* c, allowed_t )
{
unmanaged.append( c );
checkNonExistentClients();
}
/*
@ -583,12 +541,6 @@ void Workspace::removeClient( Client* c, allowed_t )
if( c->isNormalWindow())
Notify::raise( Notify::Delete );
if( tab_grab )
{
if( tab_box->currentClient() == c )
tab_box->nextPrev( true );
}
Q_ASSERT( clients.contains( c ) || desktops.contains( c ));
clients.removeAll( c );
desktops.removeAll( c );
@ -619,34 +571,12 @@ void Workspace::removeClient( Client* c, allowed_t )
updateStackingOrder( true );
if( tab_grab )
tab_box->reset( true );
if (tab_grab)
tab_box->repaint();
updateClientArea();
}
void Workspace::removeUnmanaged( Unmanaged* c, allowed_t )
{
assert( unmanaged.contains( c ));
unmanaged.removeAll( c );
}
void Workspace::addDeleted( Deleted* c, allowed_t )
{
assert( !deleted.contains( c ));
deleted.append( c );
}
void Workspace::removeDeleted( Deleted* c, allowed_t )
{
assert( deleted.contains( c ));
if( scene )
scene->windowDeleted( c );
if( effects )
effects->windowDeleted( c->effectWindow());
deleted.removeAll( c );
}
void Workspace::updateFocusChains( Client* c, FocusChainChange change )
{
if( !c->wantsTabFocus()) // doesn't want tab focus, remove
@ -672,7 +602,13 @@ void Workspace::updateFocusChains( Client* c, FocusChainChange change )
focus_chain[ i ].prepend( c );
}
else if( !focus_chain[ i ].contains( c ))
focus_chain[ i ].prepend( c ); // otherwise add as the last one
{ // add it after the active one
if( active_client != NULL && active_client != c
&& !focus_chain[ i ].isEmpty() && focus_chain[ i ].last() == active_client )
focus_chain[ i ].insert( focus_chain[ i ].size() - 1, c );
else
focus_chain[ i ].append( c ); // otherwise add as the first one
}
}
}
else //now only on desktop, remove it anywhere else
@ -692,7 +628,13 @@ void Workspace::updateFocusChains( Client* c, FocusChainChange change )
focus_chain[ i ].prepend( c );
}
else if( !focus_chain[ i ].contains( c ))
focus_chain[ i ].prepend( c );
{ // add it after the active one
if( active_client != NULL && active_client != c
&& !focus_chain[ i ].isEmpty() && focus_chain[ i ].last() == active_client )
focus_chain[ i ].insert( focus_chain[ i ].size() - 1, c );
else
focus_chain[ i ].append( c ); // otherwise add as the first one
}
}
else
focus_chain[ i ].removeAll( c );
@ -709,7 +651,13 @@ void Workspace::updateFocusChains( Client* c, FocusChainChange change )
global_focus_chain.prepend( c );
}
else if( !global_focus_chain.contains( c ))
global_focus_chain.prepend( c );
{ // add it after the active one
if( active_client != NULL && active_client != c
&& !global_focus_chain.isEmpty() && global_focus_chain.last() == active_client )
global_focus_chain.insert( global_focus_chain.size() - 1, c );
else
global_focus_chain.append( c ); // otherwise add as the first one
}
}
void Workspace::updateCurrentTopMenu()
@ -927,6 +875,11 @@ void Workspace::updateColormap()
}
}
void Workspace::slotReloadConfig()
{
reconfigure();
}
void Workspace::reconfigure()
{
reconfigureTimer.start( 200 );
@ -943,7 +896,7 @@ void Workspace::slotSettingsChanged(int category)
/*!
Reread settings
*/
KWIN_PROCEDURE( CheckBorderSizesProcedure, Client, cl->checkBorderSizes() );
KWIN_PROCEDURE( CheckBorderSizesProcedure, cl->checkBorderSizes() );
void Workspace::slotReconfigure()
{
@ -1000,11 +953,6 @@ void Workspace::slotReconfigure()
updateTopMenuGeometry();
updateCurrentTopMenu();
}
if( options->useTranslucency )
setupCompositing();
else
finishCompositing();
loadWindowRules();
for( ClientList::Iterator it = clients.begin();
@ -1287,15 +1235,16 @@ bool Workspace::setCurrentDesktop( int new_desktop )
// and active_client is on_all_desktops and under mouse (hence == old_active_client),
// conserve focus (thanks to Volker Schatz <V.Schatz at thphys.uni-heidelberg.de>)
else if( active_client && active_client->isShown( true ) && active_client->isOnCurrentDesktop())
c= active_client;
c = active_client;
if( c == NULL && !desktops.isEmpty())
c = findDesktop( true, currentDesktop());
if( c != active_client )
setActiveClient( NULL, Allowed );
if ( c )
requestFocus( c );
else if( !desktops.isEmpty() )
requestFocus( findDesktop( true, currentDesktop()));
else
focusToNull();
@ -1317,10 +1266,6 @@ bool Workspace::setCurrentDesktop( int new_desktop )
if( old_desktop != 0 ) // not for the very first time
popupinfo->showInfo( desktopName(currentDesktop()) );
if( effects != NULL && old_desktop != 0 )
effects->desktopChanged( old_desktop );
return true;
}
@ -1553,25 +1498,26 @@ void Workspace::sendClientToDesktop( Client* c, int desk, bool dont_activate )
updateClientArea();
}
void Workspace::setDesktopLayout(int o, int x, int y)
void Workspace::setDesktopLayout(NET::Orientation o, int x, int y,NET::DesktopLayoutCorner c)
{
layoutOrientation = (Qt::Orientation) o;
Q_UNUSED( c ); // I don't find this worth bothering, feel free to
layoutOrientation = ( o == NET::OrientationHorizontal ? Qt::Horizontal : Qt::Vertical );
layoutX = x;
layoutY = y;
}
void Workspace::calcDesktopLayout(int &x, int &y) const
{
x = layoutX;
x = layoutX; // <= 0 means compute it from the other and total number of desktops
y = layoutY;
if ((x == -1) && (y > 0))
if((x <= 0) && (y > 0))
x = (numberOfDesktops()+y-1) / y;
else if ((y == -1) && (x > 0))
else if((y <=0) && (x > 0))
y = (numberOfDesktops()+x-1) / x;
if (x == -1)
if(x <=0)
x = 1;
if (y == -1)
if (y <= 0)
y = 1;
}
@ -1703,7 +1649,7 @@ void Workspace::slotGrabWindow()
QPixmap snapshot = QPixmap::grabWindow( active_client->frameId() );
//No XShape - no work.
if( Extensions::shapeAvailable())
if( Shape::available())
{
//As the first step, get the mask from XShape.
int count, order;
@ -1904,7 +1850,7 @@ bool Workspace::keyPressMouseEmulation( XKeyEvent& ev )
bool is_alt = km & Mod1Mask;
bool is_shift = km & ShiftMask;
int delta = is_control?1:is_alt?32:8;
QPoint pos = cursorPos();
QPoint pos = QCursor::pos();
switch ( kc )
{
@ -2056,8 +2002,7 @@ void Workspace::createBorderWindows()
XSetWindowAttributes attributes;
unsigned long valuemask;
attributes.override_redirect = True;
attributes.event_mask = (EnterWindowMask | LeaveWindowMask |
VisibilityChangeMask);
attributes.event_mask = ( EnterWindowMask | LeaveWindowMask );
valuemask= (CWOverrideRedirect | CWEventMask | CWCursor );
attributes.cursor = XCreateFontCursor(display(),
XC_sb_up_arrow);
@ -2449,7 +2394,7 @@ void Workspace::helperDialog( const QString& message, const Client* c )
{
KConfig cfg( "kwin_dialogsrc" );
KConfigGroup cg(&cfg, "Notification Messages" ); // this depends on KMessageBox
if( !cg.readEntry( type, QVariant(true )).toBool()) // has don't show again checked
if( !cg.readEntry( type, true )) // has don't show again checked
return; // save launching kdialog
proc << "--dontagain" << "kwin_dialogsrc:" + type;
}

View File

@ -18,8 +18,6 @@ License. See the file "COPYING" for the exact licensing terms.
#include <QCursor>
#include <netwm.h>
#include <kxmessages.h>
#include <qdatetime.h>
#include <kmanagerselection.h>
#include "utils.h"
#include "kdecoration.h"
@ -79,7 +77,7 @@ class Workspace : public QObject, public KDecorationDefines
virtual ~Workspace();
static Workspace * self() { return _self; }
bool workspaceEvent( XEvent * );
KDecoration* createDecoration( KDecorationBridge* bridge );
@ -89,9 +87,6 @@ class Workspace : public QObject, public KDecorationDefines
template< typename T > Client* findClient( T predicate );
template< typename T1, typename T2 > void forEachClient( T1 procedure, T2 predicate );
template< typename T > void forEachClient( T procedure );
template< typename T > Unmanaged* findUnmanaged( T predicate );
template< typename T1, typename T2 > void forEachUnmanaged( T1 procedure, T2 predicate );
template< typename T > void forEachUnmanaged( T procedure );
QRect clientArea( clientAreaOption, const QPoint& p, int desktop ) const;
QRect clientArea( clientAreaOption, const Client* c ) const;
@ -170,17 +165,12 @@ class Workspace : public QObject, public KDecorationDefines
QWidget* desktopWidget();
// for TabBox
Client* currentTabBoxClient() const;
ClientList currentTabBoxClientList() const;
int currentTabBoxDesktop() const;
Client* nextFocusChainClient(Client*) const;
Client* previousFocusChainClient(Client*) const;
Client* nextStaticClient(Client*) const;
Client* previousStaticClient(Client*) const;
int nextDesktopFocusChain( int iDesktop ) const;
int previousDesktopFocusChain( int iDesktop ) const;
void refTabBox();
void unrefTabBox();
void closeTabBox();
/**
@ -191,7 +181,7 @@ class Workspace : public QObject, public KDecorationDefines
ClientList ensureStackingOrder( const ClientList& clients ) const;
Client* topClientOnDesktop( int desktop, bool unconstrained = false ) const;
Client* topClientOnDesktop( int desktop, bool unconstrained = false, bool only_normal = true ) const;
Client* findDesktop( bool topmost, int desktop ) const;
void sendClientToDesktop( Client* c, int desktop, bool dont_activate );
void windowToPreviousDesktop( Client* c );
@ -200,10 +190,6 @@ class Workspace : public QObject, public KDecorationDefines
// KDE4 remove me - and it's also in the DCOP interface :(
void showWindowMenuAt( unsigned long id, int x, int y );
void loadEffect( const QString& name );
void unloadEffect( const QString& name );
/**
* Shows the menu operations menu for the client and makes it active if
* it's not already.
@ -227,6 +213,8 @@ class Workspace : public QObject, public KDecorationDefines
WindowRules findWindowRules( const Client*, bool );
void rulesUpdated();
void discardUsedWindowRules( Client* c, bool withdraw );
void disableRulesUpdates( bool disable );
bool rulesUpdatesDisabled() const;
// dcop interface
void cascadeDesktop();
@ -238,7 +226,7 @@ class Workspace : public QObject, public KDecorationDefines
void circulateDesktopApplications();
QString desktopName( int desk ) const;
void setDesktopLayout(int o, int x, int y);
void setDesktopLayout(NET::Orientation o, int x, int y, NET::DesktopLayoutCorner c);
void setShowingDesktop( bool showing );
void resetShowingDesktop( bool keep_hidden );
bool showingDesktop() const;
@ -248,17 +236,14 @@ class Workspace : public QObject, public KDecorationDefines
void sendPingToWindow( Window w, Time timestamp ); // called from Client::pingWindow()
void sendTakeActivity( Client* c, Time timestamp, long flags ); // called from Client::takeActivity()
void removeClient( Client*, allowed_t ); // only called from Client::destroyClient() or Client::releaseWindow()
// only called from Client::destroyClient() or Client::releaseWindow()
void removeClient( Client*, allowed_t );
void setActiveClient( Client*, allowed_t );
Group* findGroup( Window leader ) const;
void addGroup( Group* group, allowed_t );
void removeGroup( Group* group, allowed_t );
Group* findClientLeaderGroup( const Client* c ) const;
void removeUnmanaged( Unmanaged*, allowed_t ); // only called from Unmanaged::release()
void removeDeleted( Deleted*, allowed_t );
void addDeleted( Deleted*, allowed_t );
bool checkStartupNotification( Window w, KStartupInfoId& id, KStartupInfoData& data );
void focusToNull(); // SELI public?
@ -293,17 +278,6 @@ class Workspace : public QObject, public KDecorationDefines
void requestDelayFocus( Client* );
void toggleTopDockShadows(bool on);
void addRepaint( const QRect& r );
void addRepaint( int x, int y, int w, int h );
void addRepaintFull();
// creates XComposite overlay window, call initOverlay() afterwards
bool createOverlay();
// init overlay and the destination window in it
void setupOverlay( Window window );
// destroys XComposite overlay window
void destroyOverlay();
Window overlayWindow();
public slots:
void refresh();
@ -434,14 +408,15 @@ class Workspace : public QObject, public KDecorationDefines
void cleanupTemporaryRules();
void writeWindowRules();
void slotBlockShortcuts(int data);
void setPopupClientOpacity( QAction* action );
void setupCompositing();
void performCompositing();
void lostCMSelection();
void slotReloadConfig();
// kompmgr
void setPopupClientOpacity(int v);
void resetClientOpacity();
void setTransButtonText(int value);
// end
protected:
bool keyPressMouseEmulation( XKeyEvent& ev );
bool netCheck( XEvent* e );
private:
void init();
@ -485,8 +460,6 @@ class Workspace : public QObject, public KDecorationDefines
// this is the right way to create a new client
Client* createClient( Window w, bool is_mapped );
void addClient( Client* c, allowed_t );
Unmanaged* createUnmanaged( Window w );
void addUnmanaged( Unmanaged* c, allowed_t );
Window findSpecialEventWindow( XEvent* e );
@ -528,9 +501,6 @@ class Workspace : public QObject, public KDecorationDefines
void closeActivePopup();
void updateClientArea( bool force );
void finishCompositing();
bool windowRepaintsPending() const;
SystemTrayWindowList systemTrayWins;
@ -551,6 +521,7 @@ class Workspace : public QObject, public KDecorationDefines
QList<Rules*> rules;
KXMessages temporaryRulesMessages;
QTimer rulesUpdatedTimer;
bool rules_updates_disabled;
static const char* windowTypeToTxt( NET::WindowType type );
static NET::WindowType txtToWindowType( const char* txt );
static bool sessionInfoWindowTypeMatch( Client* c, SessionInfo* info );
@ -567,12 +538,10 @@ class Workspace : public QObject, public KDecorationDefines
ClientList clients;
ClientList desktops;
UnmanagedList unmanaged;
DeletedList deleted;
ClientList unconstrained_stacking_order;
ClientList stacking_order;
QVector< ClientList > focus_chain;
ClientList unconstrained_stacking_order; // topmost last
ClientList stacking_order; // topmost last
QVector< ClientList > focus_chain; // currently ative last
ClientList global_focus_chain; // this one is only for things like tabbox's MRU
ClientList should_get_focus; // last is most recent
ClientList attention_chain;
@ -606,7 +575,6 @@ class Workspace : public QObject, public KDecorationDefines
QMenu *popup;
QMenu *advanced_popup;
QMenu *trans_popup;
QMenu *desk_popup;
int desk_popup_index;
@ -690,14 +658,12 @@ class Workspace : public QObject, public KDecorationDefines
bool forced_global_mouse_grab;
friend class StackingUpdatesBlocker;
KSelectionOwner* cm_selection;
QTimer compositeTimer;
QTime lastCompositePaint;
int compositeRate;
QRegion repaints_region;
Window overlay; // XComposite overlay window
//kompmgr
QSlider *transSlider;
QPushButton *transButton;
private:
friend bool performTransiencyCheck();
};
// helper for Workspace::blockStackingUpdates() being called in pairs (true/false)
@ -840,9 +806,10 @@ inline bool Workspace::globalShortcutsDisabled() const
return global_shortcuts_disabled || global_shortcuts_disabled_for_client;
}
inline Window Workspace::overlayWindow()
inline
bool Workspace::rulesUpdatesDisabled() const
{
return overlay;
return rules_updates_disabled;
}
template< typename T >
@ -872,27 +839,7 @@ inline void Workspace::forEachClient( T procedure )
return forEachClient( procedure, TruePredicate());
}
template< typename T >
inline Unmanaged* Workspace::findUnmanaged( T predicate )
{
return findUnmanagedInList( unmanaged, predicate );
}
template< typename T1, typename T2 >
inline void Workspace::forEachUnmanaged( T1 procedure, T2 predicate )
{
for ( UnmanagedList::ConstIterator it = unmanaged.begin(); it != unmanaged.end(); ++it)
if ( predicate( const_cast< const Unmanaged* >( *it)))
procedure( *it );
}
template< typename T >
inline void Workspace::forEachUnmanaged( T procedure )
{
return forEachUnmanaged( procedure, TruePredicate());
}
KWIN_COMPARE_PREDICATE( ClientMatchPredicate, Client, const Client*, cl == value );
KWIN_COMPARE_PREDICATE( ClientMatchPredicate, const Client*, cl == value );
inline bool Workspace::hasClient( const Client* c )
{
return findClient( ClientMatchPredicate( c ));