From 038667db7a7038600e2a15b9410bd64fa5042934 Mon Sep 17 00:00:00 2001 From: Lucas Murray Date: Thu, 18 Dec 2008 13:50:57 +0000 Subject: [PATCH] SVN_SILENT Standardize coding style on client.* and workspace.* svn path=/trunk/KDE/kdebase/workspace/; revision=898612 --- client.cpp | 854 ++++++++++++------------- client.h | 206 +++--- workspace.cpp | 1689 +++++++++++++++++++++++++------------------------ workspace.h | 367 +++++------ 4 files changed, 1567 insertions(+), 1549 deletions(-) diff --git a/client.cpp b/client.cpp index 8f47973da5..7206c7c741 100644 --- a/client.cpp +++ b/client.cpp @@ -50,79 +50,71 @@ along with this program. If not, see . #include #endif -// put all externs before the namespace statement to allow the linker +// Put all externs before the namespace statement to allow the linker // to resolve them properly namespace KWin { -/* +// Creating a client: +// - only by calling Workspace::createClient() +// - it creates a new client and calls manage() for it +// +// Destroying a client: +// - destroyClient() - only when the window itself has been destroyed +// - releaseWindow() - the window is kept, only the client itself is destroyed - Creating a client: - - only by calling Workspace::createClient() - - it creates a new client and calls manage() for it - - Destroying a client: - - destroyClient() - only when the window itself has been destroyed - - releaseWindow() - the window is kept, only the client itself is destroyed - -*/ - - -/*! - \class Client client.h - - \brief The Client class encapsulates a window decoration frame. - -*/ - -/*! - This ctor is "dumb" - it only initializes data. All the real initialization - is done in manage(). +/** + * \class Client client.h + * \brief The Client class encapsulates a window decoration frame. */ -Client::Client( Workspace *ws ) - : Toplevel( ws ), - client( None ), - wrapper( None ), - decoration( NULL ), - bridge( new Bridge( this )), - move_faked_activity( false ), - move_resize_grab_window( None ), - move_resize_has_keyboard_grab( false ), - transient_for( NULL ), - transient_for_id( None ), - original_transient_for_id( None ), - autoRaiseTimer( NULL ), - shadeHoverTimer( NULL ), - delayedMoveResizeTimer( NULL ), - in_group( NULL ), - window_group( None ), - in_layer( UnknownLayer ), - ping_timer( NULL ), - process_killer( NULL ), - user_time( CurrentTime ), // not known yet - allowed_actions( 0 ), - block_geometry_updates( 0 ), - pending_geometry_update( PendingGeometryNone ), - shade_geometry_change( false ), -#ifdef HAVE_XSYNC - sync_counter( None ), - sync_alarm( None ), -#endif - sync_timeout( NULL ), - sync_resize_pending( false ), - border_left( 0 ), - border_right( 0 ), - border_top( 0 ), - border_bottom( 0 ), - sm_stacking_order( -1 ), - demandAttentionKNotifyTimer( NULL ) -// SELI do all as initialization - { - // set the initial mapping state +/** + * This ctor is "dumb" - it only initializes data. All the real initialization + * is done in manage(). + */ +Client::Client( Workspace* ws ) + : Toplevel( ws ) + , client( None ) + , wrapper( None ) + , decoration( NULL ) + , bridge( new Bridge( this )) + , move_faked_activity( false ) + , move_resize_grab_window( None ) + , move_resize_has_keyboard_grab( false ) + , transient_for( NULL ) + , transient_for_id( None ) + , original_transient_for_id( None ) + , autoRaiseTimer( NULL ) + , shadeHoverTimer( NULL ) + , delayedMoveResizeTimer( NULL ) + , in_group( NULL ) + , window_group( None ) + , in_layer( UnknownLayer ) + , ping_timer( NULL ) + , process_killer( NULL ) + , user_time( CurrentTime ) // Not known yet + , allowed_actions( 0 ) + , block_geometry_updates( 0 ) + , pending_geometry_update( PendingGeometryNone ) + , shade_geometry_change( false ) +#ifdef HAVE_XSYNC + , sync_counter( None ) + , sync_alarm( None ) +#endif + , sync_timeout( NULL ) + , sync_resize_pending( false ) + , border_left( 0 ) + , border_right( 0 ) + , border_top( 0 ) + , border_bottom( 0 ) + , sm_stacking_order( -1 ) + , demandAttentionKNotifyTimer( NULL ) + { // TODO: Do all as initialization + + // Set the initial mapping state mapping_state = Withdrawn; - desk = 0; // no desktop yet + desk = 0; // No desktop yet mode = PositionCenter; buttonDown = false; @@ -161,20 +153,20 @@ Client::Client( Workspace *ws ) max_mode = MaximizeRestore; maxmode_restore = MaximizeRestore; - + cmap = None; - - geom = QRect( 0, 0, 100, 100 ); // so that decorations don't start with size being (0,0) + + geom = QRect( 0, 0, 100, 100 ); // So that decorations don't start with size being (0,0) client_size = QSize( 100, 100 ); #if defined(HAVE_XSYNC) || defined(HAVE_XDAMAGE) ready_for_painting = false; // wait for first damage or sync reply #endif - // SELI initialize xsizehints?? + // SELI TODO: Initialize xsizehints?? } -/*! - "Dumb" destructor. +/** + * "Dumb" destructor. */ Client::~Client() { @@ -185,21 +177,21 @@ Client::~Client() assert(!moveResizeMode); assert( client == None ); assert( wrapper == None ); -// assert( frameId() == None ); + //assert( frameId() == None ); assert( decoration == NULL ); assert( block_geometry_updates == 0 ); assert( !check_active_modal ); delete bridge; } -// use destroyClient() or releaseWindow(), Client instances cannot be deleted directly +// Use destroyClient() or releaseWindow(), Client instances cannot be deleted directly void Client::deleteClient( Client* c, allowed_t ) { delete c; } -/*! - Releases the window. The client has done its job and the window is still existing. +/** + * Releases the window. The client has done its job and the window is still existing. */ void Client::releaseWindow( bool on_shutdown ) { @@ -212,7 +204,7 @@ void Client::releaseWindow( bool on_shutdown ) scene->windowClosed( this, del ); } finishCompositing(); - workspace()->discardUsedWindowRules( this, true ); // remove ForceTemporarily rules + workspace()->discardUsedWindowRules( this, true ); // Remove ForceTemporarily rules StackingUpdatesBlocker blocker( workspace()); if (moveResizeMode) leaveMoveResize(); @@ -220,25 +212,24 @@ void Client::releaseWindow( bool on_shutdown ) ++block_geometry_updates; if( isOnCurrentDesktop() && isShown( true )) addWorkspaceRepaint( geometry()); - // grab X during the release to make removing of properties, setting to withdrawn state + // Grab X during the release to make removing of properties, setting to withdrawn state // and repareting to root an atomic operation (http://lists.kde.org/?l=kde-devel&m=116448102901184&w=2) grabXServer(); exportMappingState( WithdrawnState ); - setModal( false ); // otherwise its mainwindow wouldn't get focus - hidden = true; // so that it's not considered visible anymore (can't use hideClient(), it would set flags) + setModal( false ); // Otherwise its mainwindow wouldn't get focus + hidden = true; // So that it's not considered visible anymore (can't use hideClient(), it would set flags) if( !on_shutdown ) workspace()->clientHidden( this ); - XUnmapWindow( display(), frameId()); // destroying decoration would cause ugly visual effect + XUnmapWindow( display(), frameId()); // Destroying decoration would cause ugly visual effect destroyDecoration(); cleanGrouping(); if( !on_shutdown ) { workspace()->removeClient( this, Allowed ); - // only when the window is being unmapped, not when closing down KWin - // (NETWM sections 5.5,5.7) + // Only when the window is being unmapped, not when closing down KWin (NETWM sections 5.5,5.7) info->setDesktop( 0 ); desk = 0; - info->setState( 0, info->state()); // reset all state flags + info->setState( 0, info->state()); // Reset all state flags } XDeleteProperty( display(), client, atoms->kde_net_wm_user_creation_time); XDeleteProperty( display(), client, atoms->net_frame_extents ); @@ -247,22 +238,18 @@ void Client::releaseWindow( bool on_shutdown ) XRemoveFromSaveSet( display(), client ); XSelectInput( display(), client, NoEventMask ); if( on_shutdown ) - { // map the window, so it can be found after another WM is started + // Map the window, so it can be found after another WM is started XMapWindow( display(), client ); - // TODO preserve minimized, shaded etc. state? - } - else - { - // Make sure it's not mapped if the app unmapped it (#65279). The app - // may do map+unmap before we initially map the window by calling rawShow() from manage(). + // TODO: Preserve minimized, shaded etc. state? + else // Make sure it's not mapped if the app unmapped it (#65279). The app + // may do map+unmap before we initially map the window by calling rawShow() from manage(). XUnmapWindow( display(), client ); - } client = None; XDestroyWindow( display(), wrapper ); wrapper = None; XDestroyWindow( display(), frameId()); -// frame = None; - --block_geometry_updates; // don't use GeometryUpdatesBlocker, it would now set the geometry + //frame = None; + --block_geometry_updates; // Don't use GeometryUpdatesBlocker, it would now set the geometry disownDataPassedToDeleted(); del->unrefWindow(); checkNonExistentClients(); @@ -270,8 +257,10 @@ void Client::releaseWindow( bool on_shutdown ) ungrabXServer(); } -// like releaseWindow(), but this one is called when the window has been already destroyed -// (e.g. the application closed it) +/** + * Like releaseWindow(), but this one is called when the window has been already destroyed + * (E.g. The application closed it) + */ void Client::destroyClient() { assert( !deleting ); @@ -283,7 +272,7 @@ void Client::destroyClient() scene->windowClosed( this, del ); } finishCompositing(); - workspace()->discardUsedWindowRules( this, true ); // remove ForceTemporarily rules + workspace()->discardUsedWindowRules( this, true ); // Remove ForceTemporarily rules StackingUpdatesBlocker blocker( workspace()); if (moveResizeMode) leaveMoveResize(); @@ -292,7 +281,7 @@ void Client::destroyClient() if( isOnCurrentDesktop() && isShown( true )) addWorkspaceRepaint( geometry()); setModal( false ); - hidden = true; // so that it's not considered visible anymore + hidden = true; // So that it's not considered visible anymore workspace()->clientHidden( this ); destroyDecoration(); cleanGrouping(); @@ -301,8 +290,8 @@ void Client::destroyClient() XDestroyWindow( display(), wrapper ); wrapper = None; XDestroyWindow( display(), frameId()); -// frame = None; - --block_geometry_updates; // don't use GeometryUpdatesBlocker, it would now set the geometry + //frame = None; + --block_geometry_updates; // Don't use GeometryUpdatesBlocker, it would now set the geometry disownDataPassedToDeleted(); del->unrefWindow(); checkNonExistentClients(); @@ -311,19 +300,19 @@ void Client::destroyClient() void Client::updateDecoration( bool check_workspace_pos, bool force ) { - if( !force && (( decoration == NULL && noBorder()) - || ( decoration != NULL && !noBorder()))) + if( !force && + (( decoration == NULL && noBorder() ) || ( decoration != NULL && !noBorder() ))) return; bool do_show = false; QRect oldgeom = geometry(); blockGeometryUpdates( true ); if( force ) destroyDecoration(); - if( !noBorder()) + if( !noBorder() ) { - setMask( QRegion()); // reset shape mask + setMask( QRegion()); // Reset shape mask decoration = workspace()->createDecoration( bridge ); - // TODO check decoration's minimum size? + // TODO: Check decoration's minimum size? decoration->init(); decoration->widget()->installEventFilter( this ); XReparentWindow( display(), decoration->widget()->winId(), frameId(), 0, 0 ); @@ -362,7 +351,7 @@ void Client::destroyDecoration() decoration = NULL; QPoint grav = calculateGravitation( true ); border_left = border_right = border_top = border_bottom = 0; - setMask( QRegion()); // reset shape mask + setMask( QRegion()); // Reset shape mask int save_workarea_diff_x = workarea_diff_x; int save_workarea_diff_y = workarea_diff_y; plainResize( sizeForClientSize( clientSize()), ForceGeometrySet ); @@ -384,8 +373,8 @@ bool Client::checkBorderSizes( bool also_resize ) return false; int new_left, new_right, new_top, new_bottom; decoration->borders( new_left, new_right, new_top, new_bottom ); - if( new_left == border_left && new_right == border_right - && new_top == border_top && new_bottom == border_bottom ) + if( new_left == border_left && new_right == border_right && + new_top == border_top && new_bottom == border_bottom ) return false; if( !also_resize ) { @@ -402,7 +391,7 @@ bool Client::checkBorderSizes( bool also_resize ) border_top = new_top; border_bottom = new_bottom; move( calculateGravitation( false )); - plainResize( sizeForClientSize( clientSize()), ForceGeometrySet ); + plainResize( sizeForClientSize( clientSize() ), ForceGeometrySet ); checkWorkspacePosition(); return true; } @@ -429,7 +418,7 @@ void Client::detectNoBorder() case NET::Splash : noborder = true; app_noborder = true; - break; + break; case NET::Unknown : case NET::Normal : case NET::Toolbar : @@ -437,7 +426,7 @@ void Client::detectNoBorder() case NET::Dialog : case NET::Utility : noborder = false; - break; + break; default: abort(); } @@ -461,11 +450,13 @@ void Client::updateFrameExtents() info->setFrameExtents( strut ); } -// Resizes the decoration, and makes sure the decoration widget gets resize event -// even if the size hasn't changed. This is needed to make sure the decoration -// re-layouts (e.g. when options()->moveResizeMaximizedWindows() changes, -// the decoration may turn on/off some borders, but the actual size -// of the decoration stays the same). +/** + * Resizes the decoration, and makes sure the decoration widget gets resize event + * even if the size hasn't changed. This is needed to make sure the decoration + * re-layouts (e.g. when options()->moveResizeMaximizedWindows() changes, + * the decoration may turn on/off some borders, but the actual size + * of the decoration stays the same). + */ void Client::resizeDecoration( const QSize& s ) { if( decoration == NULL ) @@ -491,7 +482,7 @@ bool Client::userCanSetNoBorder() const void Client::setNoBorder( bool set ) { - if( !userCanSetNoBorder()) + if( !userCanSetNoBorder() ) return; set = rules()->checkNoBorder( set ); if( noborder == set ) @@ -503,26 +494,26 @@ void Client::setNoBorder( bool set ) void Client::updateShape() { - // workaround for #19644 - shaped windows shouldn't have decoration - if( shape()) - { - if( !app_noborder ) // only when shape is detected for the first time, - { // still let the user to override + if( shape() ) + { // Workaround for #19644 - Shaped windows shouldn't have decoration + if( !app_noborder ) + { // Only when shape is detected for the first time, still let the user to override app_noborder = true; noborder = true; updateDecoration( true ); } } - if( shape() && noBorder()) + if( shape() && noBorder() ) XShapeCombineShape( display(), frameId(), ShapeBounding, clientPos().x(), clientPos().y(), window(), ShapeBounding, ShapeSet ); + // Decoration mask (i.e. 'else' here) setting is done in setMask() // when the decoration calls it or when the decoration is created/destroyed updateInputShape(); if( compositing()) { addRepaintFull(); - addWorkspaceRepaint( geometry()); // in case shape change removes part of this window + addWorkspaceRepaint( geometry()); // In case shape change removes part of this window } if( scene != NULL ) scene->windowGeometryShapeChanged( this ); @@ -534,7 +525,7 @@ static Window shape_helper_window = None; void Client::updateInputShape() { - if( hiddenPreview()) // sets it to none, don't change + if( hiddenPreview() ) // Sets it to none, don't change return; if( Extensions::shapeInputAvailable()) { // There appears to be no way to find out if a window has input @@ -546,21 +537,19 @@ void Client::updateInputShape() // that after the second step there's a hole in the input shape // until the real shape of the client is added and that can make // the window lose focus (which is a problem with mouse focus policies) - // TODO it seems there is, after all - XShapeGetRectangles() - but maybe this is better + // TODO: It seems there is, after all - XShapeGetRectangles() - but maybe this is better if( shape_helper_window == None ) shape_helper_window = XCreateSimpleWindow( display(), rootWindow(), 0, 0, 1, 1, 0, 0, 0 ); XResizeWindow( display(), shape_helper_window, width(), height()); XShapeCombineShape( display(), shape_helper_window, ShapeInput, 0, 0, - frameId(), ShapeBounding, ShapeSet ); + frameId(), ShapeBounding, ShapeSet ); XShapeCombineShape( display(), shape_helper_window, ShapeInput, - clientPos().x(), clientPos().y(), - window(), ShapeBounding, ShapeSubtract ); + clientPos().x(), clientPos().y(), window(), ShapeBounding, ShapeSubtract ); XShapeCombineShape( display(), shape_helper_window, ShapeInput, - clientPos().x(), clientPos().y(), - window(), ShapeInput, ShapeUnion ); + clientPos().x(), clientPos().y(), window(), ShapeInput, ShapeUnion ); XShapeCombineShape( display(), frameId(), ShapeInput, 0, 0, - shape_helper_window, ShapeInput, ShapeSet ); + shape_helper_window, ShapeInput, ShapeSet ); } } @@ -570,62 +559,56 @@ void Client::setMask( const QRegion& reg, int mode ) return; _mask = reg; Window shape_window = frameId(); - if( shape()) - { - // the same way of applying a shape without strange intermediate states like above + if( shape() ) + { // The same way of applying a shape without strange intermediate states like above if( shape_helper_window == None ) shape_helper_window = XCreateSimpleWindow( display(), rootWindow(), 0, 0, 1, 1, 0, 0, 0 ); shape_window = shape_helper_window; } - if( reg.isEmpty()) - XShapeCombineMask( display(), shape_window, ShapeBounding, 0, 0, - None, ShapeSet ); + if( reg.isEmpty() ) + XShapeCombineMask( display(), shape_window, ShapeBounding, 0, 0, None, ShapeSet ); else if( mode == X::Unsorted ) - XShapeCombineRegion( display(), shape_window, ShapeBounding, 0, 0, - reg.handle(), ShapeSet ); + XShapeCombineRegion( display(), shape_window, ShapeBounding, 0, 0, reg.handle(), ShapeSet ); else { QVector< QRect > rects = reg.rects(); - XRectangle* xrects = new XRectangle[ rects.count() ]; - for( int i = 0; - i < rects.count(); - ++i ) + XRectangle* xrects = new XRectangle[rects.count()]; + for( int i = 0; i < rects.count(); ++i ) { - xrects[ i ].x = rects[ i ].x(); - xrects[ i ].y = rects[ i ].y(); - xrects[ i ].width = rects[ i ].width(); - xrects[ i ].height = rects[ i ].height(); + xrects[i].x = rects[i].x(); + xrects[i].y = rects[i].y(); + xrects[i].width = rects[i].width(); + xrects[i].height = rects[i].height(); } XShapeCombineRectangles( display(), shape_window, ShapeBounding, 0, 0, xrects, rects.count(), ShapeSet, mode ); delete[] xrects; } - if( shape()) - { // the rest of the applyign using a temporary window + if( shape() ) + { // The rest of the applyign using a temporary window XRectangle rec = { 0, 0, clientSize().width(), clientSize().height() }; XShapeCombineRectangles( display(), shape_helper_window, ShapeBounding, - clientPos().x(), clientPos().y(), &rec, 1, ShapeSubtract, Unsorted ); + clientPos().x(), clientPos().y(), &rec, 1, ShapeSubtract, Unsorted ); XShapeCombineShape( display(), shape_helper_window, ShapeBounding, - clientPos().x(), clientPos().y(), - window(), ShapeBounding, ShapeUnion ); + clientPos().x(), clientPos().y(), window(), ShapeBounding, ShapeUnion ); XShapeCombineShape( display(), frameId(), ShapeBounding, 0, 0, - shape_helper_window, ShapeBounding, ShapeSet ); + shape_helper_window, ShapeBounding, ShapeSet ); } if( scene != NULL ) scene->windowGeometryShapeChanged( this ); if( effects != NULL ) - static_cast(effects)->windowGeometryShapeChanged( effectWindow(), geometry()); + static_cast( effects )->windowGeometryShapeChanged( effectWindow(), geometry() ); updateShape(); } QRegion Client::mask() const { - if( _mask.isEmpty()) - return QRegion( 0, 0, width(), height()); + if( _mask.isEmpty() ) + return QRegion( 0, 0, width(), height() ); return _mask; } - + void Client::hideClient( bool hide ) { if( hidden == hide ) @@ -633,44 +616,42 @@ void Client::hideClient( bool hide ) hidden = hide; updateVisibility(); } - -/* - Returns whether the window is minimizable or not + +/** + * Returns whether the window is minimizable or not */ bool Client::isMinimizable() const { - if( isSpecialWindow()) + if( isSpecialWindow() ) return false; - if( isTransient()) - { // #66868 - let other xmms windows be minimized when the mainwindow is minimized + if( isTransient() ) + { // #66868 - Let other xmms windows be minimized when the mainwindow is minimized bool shown_mainwindow = false; ClientList mainclients = mainClients(); for( ClientList::ConstIterator it = mainclients.constBegin(); - it != mainclients.constEnd(); - ++it ) - { + it != mainclients.constEnd(); + ++it ) if( (*it)->isShown( true )) shown_mainwindow = true; - } if( !shown_mainwindow ) return true; } - // this is here because kicker's taskbar doesn't provide separate entries + // This is here because kicker's taskbar doesn't provide separate entries // for windows with an explicitly given parent - // TODO perhaps this should be redone + // TODO: perhaps this should be redone if( transientFor() != NULL ) return false; - if( !wantsTabFocus()) // SELI - NET::Utility? why wantsTabFocus() - skiptaskbar? ? + if( !wantsTabFocus() ) // SELI, TODO: - NET::Utility? why wantsTabFocus() - skiptaskbar? ? return false; return true; } -/*! - Minimizes this client plus its transients +/** + * Minimizes this client plus its transients */ void Client::minimize( bool avoid_animation ) { - if ( !isMinimizable() || isMinimized()) + if( !isMinimizable() || isMinimized() ) return; Notify::raise( Notify::Minimize ); @@ -682,7 +663,7 @@ void Client::minimize( bool avoid_animation ) workspace()->updateMinimizedOfTransients( this ); updateWindowRules(); workspace()->updateFocusChains( this, Workspace::FocusChainMakeLast ); - if( effects && !avoid_animation ) // TODO shouldn't it tell effects at least about the change? + if( effects && !avoid_animation ) // TODO: Shouldn't it tell effects at least about the change? static_cast(effects)->windowMinimized( effectWindow()); } @@ -698,7 +679,7 @@ void Client::unminimize( bool avoid_animation ) workspace()->updateMinimizedOfTransients( this ); updateWindowRules(); if( effects && !avoid_animation ) - static_cast(effects)->windowUnminimized( effectWindow()); + static_cast( effects )->windowUnminimized( effectWindow() ); } QRect Client::iconGeometry() const @@ -708,8 +689,7 @@ QRect Client::iconGeometry() const if( geom.isValid() ) return geom; else - { - // Check all mainwindows of this window (recursively) + { // Check all mainwindows of this window (recursively) foreach( Client* mainwin, mainClients() ) { geom = mainwin->iconGeometry(); @@ -738,36 +718,36 @@ void Client::setShade( ShadeMode mode ) shade_mode = mode; if( was_shade == isShade()) { - if( decoration != NULL ) // decoration may want to update after e.g. hover-shade changes + if( decoration != NULL ) // Decoration may want to update after e.g. hover-shade changes decoration->shadeChange(); - return; // no real change in shaded state + return; // No real change in shaded state } if( shade_mode == ShadeNormal ) { - if ( isShown( true ) && isOnCurrentDesktop()) - Notify::raise( Notify::ShadeUp ); + if( isShown( true ) && isOnCurrentDesktop() ) + Notify::raise( Notify::ShadeUp ); } else if( shade_mode == ShadeNone ) { - if( isShown( true ) && isOnCurrentDesktop()) - Notify::raise( Notify::ShadeDown ); + if( isShown( true ) && isOnCurrentDesktop() ) + Notify::raise( Notify::ShadeDown ); } assert( decoration != NULL ); // noborder windows can't be shaded GeometryUpdatesBlocker blocker( this ); - // decorations may turn off some borders when shaded + // Decorations may turn off some borders when shaded decoration->borders( border_left, border_right, border_top, border_bottom ); -// TODO all this unmapping, resizing etc. feels too much duplicated from elsewhere + // TODO: All this unmapping, resizing etc. feels too much duplicated from elsewhere if ( isShade()) { // shade_mode == ShadeNormal - addWorkspaceRepaint( geometry()); - // shade + addWorkspaceRepaint( geometry() ); + // Shade shade_geometry_change = true; - QSize s( sizeForClientSize( QSize( clientSize()))); + QSize s( sizeForClientSize( QSize( clientSize() ))); s.setHeight( border_top + border_bottom ); - XSelectInput( display(), wrapper, ClientWinMask ); // avoid getting UnmapNotify + XSelectInput( display(), wrapper, ClientWinMask ); // Avoid getting UnmapNotify XUnmapWindow( display(), wrapper ); XUnmapWindow( display(), client ); XSelectInput( display(), wrapper, ClientWinMask | SubstructureNotifyMask ); @@ -784,13 +764,13 @@ void Client::setShade( ShadeMode mode ) else { shade_geometry_change = true; - QSize s( sizeForClientSize( clientSize())); + QSize s( sizeForClientSize( clientSize() )); shade_geometry_change = false; plainResize( s ); if( shade_mode == ShadeHover || shade_mode == ShadeActivated ) setActive( true ); - XMapWindow( display(), wrapperId()); - XMapWindow( display(), window()); + XMapWindow( display(), wrapperId() ); + XMapWindow( display(), window() ); if ( isActive() ) workspace()->requestFocus( this ); } @@ -824,8 +804,7 @@ void Client::cancelShadeHoverTimer() } void Client::toggleShade() - { - // if the mode is ShadeHover or ShadeActive, cancel shade too + { // If the mode is ShadeHover or ShadeActive, cancel shade too setShade( shade_mode == ShadeNone ? ShadeNormal : ShadeNone ); } @@ -836,14 +815,14 @@ void Client::updateVisibility() if( hidden ) { info->setState( NET::Hidden, NET::Hidden ); - setSkipTaskbar( true, false ); // also hide from taskbar + setSkipTaskbar( true, false ); // Also hide from taskbar if( compositing() && options->hiddenPreviews == HiddenPreviewsAlways ) internalKeep( Allowed ); else internalHide( Allowed ); return; } - setSkipTaskbar( original_skip_taskbar, false ); // reset from 'hidden' + setSkipTaskbar( original_skip_taskbar, false ); // Reset from 'hidden' if( minimized ) { info->setState( NET::Hidden, NET::Hidden ); @@ -864,9 +843,9 @@ void Client::updateVisibility() } bool belongs_to_desktop = false; for( ClientList::ConstIterator it = group()->members().constBegin(); - it != group()->members().constEnd(); - ++it ) - if( (*it)->isDesktop()) + it != group()->members().constEnd(); + ++it ) + if( (*it)->isDesktop() ) { belongs_to_desktop = true; break; @@ -876,11 +855,11 @@ void Client::updateVisibility() internalShow( Allowed ); } -/*! - Sets the client window's mapping state. Possible values are - WithdrawnState, IconicState, NormalState. +/** + * Sets the client window's mapping state. Possible values are + * WithdrawnState, IconicState, NormalState. */ -void Client::exportMappingState(int s) +void Client::exportMappingState( int s ) { assert( client != None ); assert( !deleting || s == WithdrawnState ); @@ -895,7 +874,7 @@ void Client::exportMappingState(int s) data[0] = (unsigned long) s; data[1] = (unsigned long) None; XChangeProperty(display(), window(), atoms->wm_state, atoms->wm_state, 32, - PropModeReplace, (unsigned char *)data, 2); + PropModeReplace, (unsigned char*)( data ), 2); } void Client::internalShow( allowed_t ) @@ -921,14 +900,14 @@ void Client::internalHide( allowed_t ) unmap( Allowed ); if( old == Kept ) updateHiddenPreview(); - addWorkspaceRepaint( geometry()); + addWorkspaceRepaint( geometry() ); workspace()->clientHidden( this ); workspace()->checkUnredirect(); } void Client::internalKeep( allowed_t ) { - assert( compositing()); + assert( compositing() ); if( mapping_state == Kept ) return; MappingState old = mapping_state; @@ -936,15 +915,15 @@ void Client::internalKeep( allowed_t ) if( old == Unmapped || old == Withdrawn ) map( Allowed ); updateHiddenPreview(); - addWorkspaceRepaint( geometry()); + addWorkspaceRepaint( geometry() ); workspace()->clientHidden( this ); workspace()->checkUnredirect(); } -/*! - Maps (shows) the client. Note that it is mapping state of the frame, - not necessarily the client window itself (i.e. a shaded window is here - considered mapped, even though it is in IconicState). +/** + * Maps (shows) the client. Note that it is mapping state of the frame, + * not necessarily the client window itself (i.e. a shaded window is here + * considered mapped, even though it is in IconicState). */ void Client::map( allowed_t ) { @@ -954,7 +933,7 @@ void Client::map( allowed_t ) if( compositing() ) discardWindowPixmap(); if( decoration != NULL ) - decoration->widget()->show(); // not really necessary, but let it know the state + decoration->widget()->show(); // Not really necessary, but let it know the state XMapWindow( display(), frameId()); if( !isShade()) { @@ -966,9 +945,9 @@ void Client::map( allowed_t ) exportMappingState( IconicState ); } -/*! - Unmaps the client. Again, this is about the frame. -*/ +/** + * Unmaps the client. Again, this is about the frame. + */ void Client::unmap( allowed_t ) { // Here it may look like a race condition, as some other client might try to unmap @@ -977,31 +956,33 @@ void Client::unmap( allowed_t ) // which won't be missed, so this shouldn't be a problem. The chance the real UnmapNotify // will be missed is also very minimal, so I don't think it's needed to grab the server // here. - XSelectInput( display(), wrapper, ClientWinMask ); // avoid getting UnmapNotify - XUnmapWindow( display(), frameId()); + XSelectInput( display(), wrapper, ClientWinMask ); // Avoid getting UnmapNotify + XUnmapWindow( display(), frameId() ); XUnmapWindow( display(), wrapper ); XUnmapWindow( display(), client ); XSelectInput( display(), wrapper, ClientWinMask | SubstructureNotifyMask ); if( decoration != NULL ) - decoration->widget()->hide(); // not really necessary, but let it know the state + decoration->widget()->hide(); // Not really necessary, but let it know the state exportMappingState( IconicState ); } -// XComposite doesn't keep window pixmaps of unmapped windows, which means -// there wouldn't be any previews of windows that are minimized or on another -// virtual desktop. Therefore rawHide() actually keeps such windows mapped. -// However special care needs to be taken so that such windows don't interfere. -// Therefore they're put very low in the stacking order and they have input shape -// set to none, which hopefully is enough. If there's no input shape available, -// then it's hoped that there will be some other desktop above it *shrug*. -// Using normal shape would be better, but that'd affect other things, e.g. painting -// of the actual preview. +/** + * XComposite doesn't keep window pixmaps of unmapped windows, which means + * there wouldn't be any previews of windows that are minimized or on another + * virtual desktop. Therefore rawHide() actually keeps such windows mapped. + * However special care needs to be taken so that such windows don't interfere. + * Therefore they're put very low in the stacking order and they have input shape + * set to none, which hopefully is enough. If there's no input shape available, + * then it's hoped that there will be some other desktop above it *shrug*. + * Using normal shape would be better, but that'd affect other things, e.g. painting + * of the actual preview. + */ void Client::updateHiddenPreview() { - if( hiddenPreview()) + if( hiddenPreview() ) { workspace()->forceRestacking(); - if( Extensions::shapeInputAvailable()) + if( Extensions::shapeInputAvailable() ) XShapeCombineRectangles( display(), frameId(), ShapeInput, 0, 0, NULL, 0, ShapeSet, Unsorted ); } else @@ -1011,12 +992,12 @@ void Client::updateHiddenPreview() } } -void Client::sendClientMessage(Window w, Atom a, Atom protocol, long data1, long data2, long data3) +void Client::sendClientMessage( Window w, Atom a, Atom protocol, long data1, long data2, long data3 ) { XEvent ev; long mask; - memset(&ev, 0, sizeof(ev)); + memset( &ev, 0, sizeof( ev )); ev.xclient.type = ClientMessage; ev.xclient.window = w; ev.xclient.message_type = a; @@ -1027,77 +1008,76 @@ void Client::sendClientMessage(Window w, Atom a, Atom protocol, long data1, long ev.xclient.data.l[3] = data2; ev.xclient.data.l[4] = data3; mask = 0L; - if (w == rootWindow()) - mask = SubstructureRedirectMask; /* magic! */ - XSendEvent(display(), w, False, mask, &ev); + if( w == rootWindow() ) + mask = SubstructureRedirectMask; // Magic! + XSendEvent( display(), w, False, mask, &ev ); } -/* - Returns whether the window may be closed (have a close button) +/** + * Returns whether the window may be closed (have a close button) */ bool Client::isCloseable() const { - return rules()->checkCloseable( motif_may_close && !isSpecialWindow()); + return rules()->checkCloseable( motif_may_close && !isSpecialWindow() ); } -/*! - Closes the window by either sending a delete_window message or - using XKill. +/** + * Closes the window by either sending a delete_window message or using XKill. */ void Client::closeWindow() { - if( !isCloseable()) + if( !isCloseable() ) return; + // Update user time, because the window may create a confirming dialog. - updateUserTime(); + updateUserTime(); + if ( Pdeletewindow ) { Notify::raise( Notify::Close ); sendClientMessage( window(), atoms->wm_protocols, atoms->wm_delete_window); pingWindow(); } - else - { - // client will not react on wm_delete_window. We have not choice - // but destroy his connection to the XServer. + else // Client will not react on wm_delete_window. We have not choice + // but destroy his connection to the XServer. killWindow(); - } } -/*! - Kills the window via XKill +/** + * Kills the window via XKill */ void Client::killWindow() { kDebug( 1212 ) << "Client::killWindow():" << caption(); - // not sure if we need an Notify::Kill or not.. until then, use + + // Not sure if we need an Notify::Kill or not.. until then, use // Notify::Close Notify::raise( Notify::Close ); - if( isDialog()) + if( isDialog() ) Notify::raise( Notify::TransDelete ); - if( isNormalWindow()) + if( isNormalWindow() ) Notify::raise( Notify::Delete ); killProcess( false ); - // always kill this client at the server - XKillClient(display(), window() ); + XKillClient(display(), window() ); // Always kill this client at the server destroyClient(); } -// send a ping to the window using _NET_WM_PING if possible -// if it doesn't respond within a reasonable time, it will be -// killed +/** + * Send a ping to the window using _NET_WM_PING if possible if it + * doesn't respond within a reasonable time, it will be killed. + */ void Client::pingWindow() { if( !Pping ) - return; // can't ping :( + return; // Can't ping :( if( options->killPingTimeout == 0 ) - return; // turned off + return; // Turned off if( ping_timer != NULL ) - return; // pinging already + return; // Pinging already ping_timer = new QTimer( this ); - connect( ping_timer, SIGNAL( timeout()), SLOT( pingTimeout())); + connect( ping_timer, SIGNAL( timeout() ), SLOT( pingTimeout() )); ping_timer->setSingleShot( true ); ping_timer->start( options->killPingTimeout ); ping_timestamp = xTime(); @@ -1106,7 +1086,7 @@ void Client::pingWindow() void Client::gotPing( Time timestamp ) { - // just plain compare is not good enough because of 64bit and truncating and whatnot + // Just plain compare is not good enough because of 64bit and truncating and whatnot if( NET::timestampCompare( timestamp, ping_timestamp ) != 0 ) return; delete ping_timer; @@ -1114,10 +1094,10 @@ void Client::gotPing( Time timestamp ) if( process_killer != NULL ) { process_killer->kill(); - // recycle when the process manager has noticed that the process exited + // Recycle when the process manager has noticed that the process exited // a delete process_killer here sometimes causes a hang in waitForFinished - connect(process_killer, SIGNAL(finished(int, QProcess::ExitStatus)), process_killer, - SLOT(deleteLater())); + connect(process_killer, SIGNAL( finished(int, QProcess::ExitStatus) ), + process_killer, SLOT( deleteLater() )); process_killer = NULL; } } @@ -1137,16 +1117,16 @@ void Client::killProcess( bool ask, Time timestamp ) Q_ASSERT( !ask || timestamp != CurrentTime ); QByteArray machine = wmClientMachine( true ); pid_t pid = info->pid(); - if( pid <= 0 || machine.isEmpty()) // needed properties missing + if( pid <= 0 || machine.isEmpty()) // Needed properties missing return; kDebug( 1212 ) << "Kill process:" << pid << "(" << machine << ")"; if( !ask ) { if( machine != "localhost" ) { - QStringList lst; - lst << machine << "kill" << QString::number( pid ); - QProcess::startDetached("xon",lst); + QStringList lst; + lst << machine << "kill" << QString::number( pid ); + QProcess::startDetached( "xon",lst ); } else ::kill( pid, SIGTERM ); @@ -1154,10 +1134,10 @@ void Client::killProcess( bool ask, Time timestamp ) else { process_killer = new QProcess( this ); - connect( process_killer, SIGNAL( error( QProcess::ProcessError )), SLOT( processKillerExited())); - connect( process_killer, SIGNAL( finished( int, QProcess::ExitStatus )), SLOT( processKillerExited())); + connect( process_killer, SIGNAL( error(QProcess::ProcessError) ), SLOT( processKillerExited() )); + connect( process_killer, SIGNAL( finished(int, QProcess::ExitStatus) ), SLOT( processKillerExited() )); process_killer->start( KStandardDirs::findExe( "kwin_killer_helper" ), - QStringList() << "--pid" << QByteArray().setNum( (unsigned)pid ) << "--hostname" << machine + QStringList() << "--pid" << QByteArray().setNum( unsigned( pid )) << "--hostname" << machine << "--windowname" << caption() << "--applicationname" << resourceClass() << "--wid" << QString::number( window() ) @@ -1180,10 +1160,10 @@ void Client::setSkipTaskbar( bool b, bool from_outside ) b = rules()->checkSkipTaskbar( b ); original_skip_taskbar = b; } - if ( b == skipTaskbar() ) + if( b == skipTaskbar() ) return; skip_taskbar = b; - info->setState( b?NET::SkipTaskbar:0, NET::SkipTaskbar ); + info->setState( b ? NET::SkipTaskbar : 0, NET::SkipTaskbar ); updateWindowRules(); if( was_wants_tab_focus != wantsTabFocus()) workspace()->updateFocusChains( this, @@ -1193,10 +1173,10 @@ void Client::setSkipTaskbar( bool b, bool from_outside ) void Client::setSkipPager( bool b ) { b = rules()->checkSkipPager( b ); - if ( b == skipPager() ) + if( b == skipPager() ) return; skip_pager = b; - info->setState( b?NET::SkipPager:0, NET::SkipPager ); + info->setState( b ? NET::SkipPager : 0, NET::SkipPager ); updateWindowRules(); } @@ -1207,13 +1187,13 @@ void Client::setModal( bool m ) modal = m; if( !modal ) return; - // changing modality for a mapped window is weird (?) + // Changing modality for a mapped window is weird (?) // _NET_WM_STATE_MODAL should possibly rather be _NET_WM_WINDOW_TYPE_MODAL_DIALOG } void Client::setDesktop( int desktop ) { - if( desktop != NET::OnAllDesktops ) // do range check + if( desktop != NET::OnAllDesktops ) // Do range check desktop = qMax( 1, qMin( workspace()->numberOfDesktops(), desktop )); desktop = qMin( workspace()->numberOfDesktops(), rules()->checkDesktop( desktop )); if( desk == desktop ) @@ -1223,7 +1203,7 @@ void Client::setDesktop( int desktop ) info->setDesktop( desktop ); if(( was_desk == NET::OnAllDesktops ) != ( desktop == NET::OnAllDesktops )) { // onAllDesktops changed - if ( isShown( true )) + if( isShown( true )) Notify::raise( isOnAllDesktops() ? Notify::OnAllDesktops : Notify::NotOnAllDesktops ); workspace()->updateOnAllDesktopsOfTransients( this ); } @@ -1234,11 +1214,11 @@ void Client::setDesktop( int desktop ) updateWindowRules(); } -/*! - 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. +/** + * 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. */ int Client::desktop() const { @@ -1247,8 +1227,8 @@ int Client::desktop() const void Client::setOnAllDesktops( bool b ) { - if(( b && isOnAllDesktops()) - || ( !b && !isOnAllDesktops())) + if(( b && isOnAllDesktops() ) || + ( !b && !isOnAllDesktops() )) return; if( b ) setDesktop( NET::OnAllDesktops ); @@ -1256,7 +1236,9 @@ void Client::setOnAllDesktops( bool b ) setDesktop( workspace()->currentDesktop()); } -// performs activation and/or raising of the window +/** + * Performs activation and/or raising of the window + */ void Client::takeActivity( int flags, bool handled, allowed_t ) { if( !handled || !Ptakeactivity ) @@ -1271,76 +1253,75 @@ void Client::takeActivity( int flags, bool handled, allowed_t ) #ifndef NDEBUG static Time previous_activity_timestamp; static Client* previous_client; -#if 0 - if( previous_activity_timestamp == xTime() && previous_client != this ) - { - kDebug( 1212 ) << "Repeated use of the same X timestamp for activity"; - kDebug( 1212 ) << kBacktrace(); - } -#endif + + //if( previous_activity_timestamp == xTime() && previous_client != this ) + // { + // kDebug( 1212 ) << "Repeated use of the same X timestamp for activity"; + // kDebug( 1212 ) << kBacktrace(); + // } + previous_activity_timestamp = xTime(); previous_client = this; #endif + workspace()->sendTakeActivity( this, xTime(), flags ); } -// performs the actual focusing of the window using XSetInputFocus and WM_TAKE_FOCUS +/** + * Performs the actual focusing of the window using XSetInputFocus and WM_TAKE_FOCUS + */ void Client::takeFocus( allowed_t ) { #ifndef NDEBUG static Time previous_focus_timestamp; static Client* previous_client; -#if 0 - if( previous_focus_timestamp == xTime() && previous_client != this ) - { - kDebug( 1212 ) << "Repeated use of the same X timestamp for focus"; - kDebug( 1212 ) << kBacktrace(); - } -#endif + + //if( previous_focus_timestamp == xTime() && previous_client != this ) + // { + // kDebug( 1212 ) << "Repeated use of the same X timestamp for focus"; + // kDebug( 1212 ) << kBacktrace(); + // } + previous_focus_timestamp = xTime(); previous_client = this; #endif - if ( rules()->checkAcceptFocus( input )) - { + if( rules()->checkAcceptFocus( input )) XSetInputFocus( display(), window(), RevertToPointerRoot, xTime() ); - } - if ( Ptakefocus ) - sendClientMessage(window(), atoms->wm_protocols, atoms->wm_take_focus); + if( Ptakefocus ) + sendClientMessage( window(), atoms->wm_protocols, atoms->wm_take_focus ); workspace()->setShouldGetFocus( this ); } -/*! - Returns whether the window provides context help or not. If it does, - you should show a help menu item or a help button like '?' and call - contextHelp() if this is invoked. - - \sa contextHelp() +/** + * Returns whether the window provides context help or not. If it does, + * you should show a help menu item or a help button like '?' and call + * contextHelp() if this is invoked. + * + * \sa contextHelp() */ bool Client::providesContextHelp() const { return Pcontexthelp; } - -/*! - Invokes context help on the window. Only works if the window - actually provides context help. - - \sa providesContextHelp() +/** + * Invokes context help on the window. Only works if the window + * actually provides context help. + * + * \sa providesContextHelp() */ void Client::showContextHelp() { - if ( Pcontexthelp ) + if( Pcontexthelp ) { - sendClientMessage(window(), atoms->wm_protocols, atoms->net_wm_context_help); - QWhatsThis::enterWhatsThisMode(); // SELI? + sendClientMessage( window(), atoms->wm_protocols, atoms->net_wm_context_help ); + QWhatsThis::enterWhatsThisMode(); // SELI TODO: ? } } - -/*! - Fetches the window's caption (WM_NAME property). It will be - stored in the client's caption(). +/** + * Fetches the window's caption (WM_NAME property). It will be + * stored in the client's caption(). */ void Client::fetchName() { @@ -1349,12 +1330,12 @@ void Client::fetchName() QString Client::readName() const { - if ( info->name() && info->name()[ 0 ] != '\0' ) + if( info->name() && info->name()[0] != '\0' ) return QString::fromUtf8( info->name() ); - else + else return KWindowSystem::readNameProperty( window(), XA_WM_NAME ); } - + KWIN_COMPARE_PREDICATE( FetchNameInternalPredicate, Client, const Client*, (!cl->isSpecialWindow() || cl->isToolbar()) && cl != value && cl->caption() == value->caption()); // The list is taken from http://www.unicode.org/reports/tr9/ @@ -1368,31 +1349,29 @@ QChar PDF(0x202C); void Client::setCaption( const QString& _s, bool force ) { - QString s = _s; - if ( s != cap_normal || force ) + QString s = _s; + if( s != cap_normal || force ) { bool reset_name = force; - for( int i = 0; - i < s.length(); - ++i ) - if( !s[ i ].isPrint()) - s[ i ] = QChar( ' ' ); + for( int i = 0; i < s.length(); ++i ) + if( !s[i].isPrint() ) + s[i] = QChar( ' ' ); cap_normal = s; - bool was_suffix = ( !cap_suffix.isEmpty()); + bool was_suffix = ( !cap_suffix.isEmpty() ); QString machine_suffix; if( wmClientMachine( false ) != "localhost" && !isLocalMachine( wmClientMachine( false ))) - { // how come doen't it compile in one line? what am i missing...? - // machine_suffix = " <@" + wmClientMachine( true ) + '>' + LRM; + { // How come doen't it compile in one line? what am i missing...? + // machine_suffix = " <@" + wmClientMachine( true ) + '>' + LRM; machine_suffix = " <@" + wmClientMachine( true ) + '>'; - // this is used to fix issue: http://bugs.kde.org/show_bug.cgi?id=154840 + // This is used to fix issue: http://bugs.kde.org/show_bug.cgi?id=154840 machine_suffix = machine_suffix + LRM; - } + } QString shortcut_suffix = !shortcut().isEmpty() ? ( " {" + shortcut().toString() + '}' ) : QString(); cap_suffix = machine_suffix + shortcut_suffix; - if ( ( !isSpecialWindow() || isToolbar()) && workspace()->findClient( FetchNameInternalPredicate( this ))) + if(( !isSpecialWindow() || isToolbar() ) && workspace()->findClient( FetchNameInternalPredicate( this ))) { int i = 2; - do + do { cap_suffix = machine_suffix + " <" + QString::number(i) + '>' + LRM + shortcut_suffix; i++; @@ -1400,17 +1379,17 @@ void Client::setCaption( const QString& _s, bool force ) info->setVisibleName( caption().toUtf8() ); reset_name = false; } - if(( was_suffix && cap_suffix.isEmpty() - || reset_name )) // if it was new window, it may have old value still set, if the window is reused - { - info->setVisibleName( "" ); // remove - info->setVisibleIconName( "" ); // remove + if(( was_suffix && cap_suffix.isEmpty() ) || reset_name ) + { // If it was new window, it may have old value still set, if the window is reused + info->setVisibleName( "" ); + info->setVisibleIconName( "" ); } - else if( !cap_suffix.isEmpty() && !cap_iconic.isEmpty()) // keep the same suffix in iconic name if it's set + else if( !cap_suffix.isEmpty() && !cap_iconic.isEmpty()) + // Keep the same suffix in iconic name if it's set info->setVisibleIconName( ( cap_iconic + cap_suffix ).toUtf8() ); if( isManaged() && decoration != NULL ) - decoration->captionChange(); + decoration->captionChange(); } } @@ -1422,25 +1401,26 @@ void Client::updateCaption() void Client::fetchIconicName() { QString s; - if ( info->iconName() && info->iconName()[ 0 ] != '\0' ) + if( info->iconName() && info->iconName()[0] != '\0' ) s = QString::fromUtf8( info->iconName() ); - else + else s = KWindowSystem::readNameProperty( window(), XA_WM_ICON_NAME ); - if ( s != cap_iconic ) + if( s != cap_iconic ) { - bool was_set = !cap_iconic.isEmpty(); + bool was_set = !cap_iconic.isEmpty(); cap_iconic = s; if( !cap_suffix.isEmpty()) - { - if( !cap_iconic.isEmpty()) // keep the same suffix in iconic name if it's set - info->setVisibleIconName( ( s + cap_suffix ).toUtf8() ); - else if( was_set ) - info->setVisibleIconName( "" ); //remove - } + { + if( !cap_iconic.isEmpty()) // Keep the same suffix in iconic name if it's set + info->setVisibleIconName( ( s + cap_suffix ).toUtf8() ); + else if( was_set ) + info->setVisibleIconName( "" ); + } } } -/*!\reimp +/** + * \reimp */ QString Client::caption( bool full ) const { @@ -1449,22 +1429,22 @@ QString Client::caption( bool full ) const void Client::getWMHints() { - XWMHints *hints = XGetWMHints(display(), window() ); + XWMHints* hints = XGetWMHints( display(), window() ); input = true; window_group = None; urgency = false; - if ( hints ) + if( hints ) { if( hints->flags & InputHint ) input = hints->input; if( hints->flags & WindowGroupHint ) window_group = hints->window_group; - urgency = ( hints->flags & UrgencyHint ) ? true : false; // true/false needed, it's uint bitfield + urgency = !!( hints->flags & UrgencyHint ); // Need boolean, it's a uint bitfield XFree( (char*)hints ); } checkGroup(); updateUrgency(); - updateAllowedActions(); // group affects isMinimizable() + updateAllowedActions(); // Group affects isMinimizable() } void Client::getMotifHints() @@ -1476,28 +1456,29 @@ void Client::getMotifHints() noborder = true; app_noborder = true; } - if( !hasNETSupport()) // NETWM apps should set type and size constraints - { - motif_may_resize = mresize; // this should be set using minsize==maxsize, but oh well + if( !hasNETSupport() ) + { // NETWM apps should set type and size constraints + motif_may_resize = mresize; // This should be set using minsize==maxsize, but oh well motif_may_move = mmove; } else motif_may_resize = motif_may_move = true; - // mminimize; - ignore, bogus - e.g. shading or sending to another desktop is "minimizing" too - // mmaximize; - ignore, bogus - maximizing is basically just resizing - motif_may_close = mclose; // motif apps like to crash when they set this hint and WM closes them anyway - if( isManaged()) - updateDecoration( true ); // check if noborder state has changed + + // mminimize; - Ignore, bogus - E.g. shading or sending to another desktop is "minimizing" too + // mmaximize; - Ignore, bogus - Maximizing is basically just resizing + motif_may_close = mclose; // Motif apps like to crash when they set this hint and WM closes them anyway + if( isManaged() ) + updateDecoration( true ); // Check if noborder state has changed } void Client::readIcons( Window win, QPixmap* icon, QPixmap* miniicon ) - { - // get the icons, allow scaling + { + // Get the icons, allow scaling if( icon != NULL ) *icon = KWindowSystem::icon( win, 32, 32, true, KWindowSystem::NETWM | KWindowSystem::WMHints ); if( miniicon != NULL ) { - if( icon == NULL || !icon->isNull()) + if( icon == NULL || !icon->isNull() ) *miniicon = KWindowSystem::icon( win, 16, 16, true, KWindowSystem::NETWM | KWindowSystem::WMHints ); else *miniicon = QPixmap(); @@ -1506,26 +1487,26 @@ void Client::readIcons( Window win, QPixmap* icon, QPixmap* miniicon ) void Client::getIcons() { - // first read icons from the window itself + // First read icons from the window itself readIcons( window(), &icon_pix, &miniicon_pix ); - if( icon_pix.isNull()) - { // then try window group + if( icon_pix.isNull() ) + { // Then try window group icon_pix = group()->icon(); miniicon_pix = group()->miniIcon(); } - if( icon_pix.isNull() && isTransient()) - { // then mainclients + if( icon_pix.isNull() && isTransient() ) + { // Then mainclients ClientList mainclients = mainClients(); for( ClientList::ConstIterator it = mainclients.constBegin(); - it != mainclients.constEnd() && icon_pix.isNull(); - ++it ) + it != mainclients.constEnd() && icon_pix.isNull(); + ++it ) { icon_pix = (*it)->icon(); miniicon_pix = (*it)->miniIcon(); } } if( icon_pix.isNull()) - { // and if nothing else, load icon from classhint or xapp icon + { // And if nothing else, load icon from classhint or xapp icon icon_pix = KWindowSystem::icon( window(), 32, 32, true, KWindowSystem::ClassHint | KWindowSystem::XApp ); miniicon_pix = KWindowSystem::icon( window(), 16, 16, true, KWindowSystem::ClassHint | KWindowSystem::XApp ); } @@ -1535,7 +1516,7 @@ void Client::getIcons() void Client::getWindowProtocols() { - Atom *p; + Atom* p; int i,n; Pdeletewindow = 0; @@ -1544,28 +1525,30 @@ void Client::getWindowProtocols() Pcontexthelp = 0; Pping = 0; - if (XGetWMProtocols(display(), window(), &p, &n)) + if( XGetWMProtocols( display(), window(), &p, &n )) { - for (i = 0; i < n; i++) - if (p[i] == atoms->wm_delete_window) + for( i = 0; i < n; i++ ) + { + if( p[i] == atoms->wm_delete_window ) Pdeletewindow = 1; - else if (p[i] == atoms->wm_take_focus) + else if( p[i] == atoms->wm_take_focus ) Ptakefocus = 1; - else if (p[i] == atoms->net_wm_take_activity) + else if( p[i] == atoms->net_wm_take_activity ) Ptakeactivity = 1; - else if (p[i] == atoms->net_wm_context_help) + else if( p[i] == atoms->net_wm_context_help ) Pcontexthelp = 1; - else if (p[i] == atoms->net_wm_ping) + else if( p[i] == atoms->net_wm_ping ) Pping = 1; - if (n>0) - XFree(p); + } + if( n > 0 ) + XFree( p ); } } void Client::getSyncCounter() { #ifdef HAVE_XSYNC - if( !Extensions::syncAvailable()) + if( !Extensions::syncAvailable() ) return; Atom retType; @@ -1575,14 +1558,14 @@ void Client::getSyncCounter() unsigned char* propRet; int ret = XGetWindowProperty( display(), window(), atoms->net_wm_sync_request_counter, 0, 1, false, XA_CARDINAL, &retType, &formatRet, &nItemRet, &byteRet, &propRet ); - + if( ret == Success && formatRet == 32 ) { - sync_counter = *(long*)propRet; + sync_counter = *(long*)( propRet ); XSyncIntToValue( &sync_counter_value, 0 ); - XSyncValue zero; - XSyncIntToValue( &zero, 0 ); - XSyncSetCounter( display(), sync_counter, zero ); + XSyncValue zero; + XSyncIntToValue( &zero, 0 ); + XSyncSetCounter( display(), sync_counter, zero ); if( sync_alarm == None ) { XSyncAlarmAttributes attrs; @@ -1593,70 +1576,68 @@ void Client::getSyncCounter() XSyncIntToValue( &attrs.delta, 1 ); sync_alarm = XSyncCreateAlarm( display(), XSyncCACounter | XSyncCAValueType | XSyncCATestType | XSyncCADelta | XSyncCAValue, - &attrs ); + &attrs ); } } #endif } -// send the client a _NET_SYNC_REQUEST +/** + * Send the client a _NET_SYNC_REQUEST + */ void Client::sendSyncRequest() { #ifdef HAVE_XSYNC if( sync_counter == None ) return; - // we increment before the notify so that after the notify + // We increment before the notify so that after the notify // syncCounterSerial will equal the value we are expecting // in the acknowledgement int overflow; XSyncValue one; XSyncIntToValue( &one, 1 ); -#undef XSyncValueAdd // it causes a warning :-/ +#undef XSyncValueAdd // It causes a warning :-/ XSyncValueAdd( &sync_counter_value, sync_counter_value, one, &overflow ); - // send the message to client + // Send the message to client XEvent ev; ev.xclient.type = ClientMessage; ev.xclient.window = window(); ev.xclient.format = 32; ev.xclient.message_type = atoms->wm_protocols; - ev.xclient.data.l[ 0 ] = atoms->net_wm_sync_request; - ev.xclient.data.l[ 1 ] = xTime(); - ev.xclient.data.l[ 2 ] = XSyncValueLow32( sync_counter_value ); - ev.xclient.data.l[ 3 ] = XSyncValueHigh32( sync_counter_value ); - ev.xclient.data.l[ 4 ] = 0; + ev.xclient.data.l[0] = atoms->net_wm_sync_request; + ev.xclient.data.l[1] = xTime(); + ev.xclient.data.l[2] = XSyncValueLow32( sync_counter_value ); + ev.xclient.data.l[3] = XSyncValueHigh32( sync_counter_value ); + ev.xclient.data.l[4] = 0; XSendEvent( display(), window(), False, NoEventMask, &ev ); - XSync(display(),false); + XSync( display(), false ); #endif } - bool Client::wantsTabFocus() const { - return ( isNormalWindow() || isDialog()) && wantsInput(); + return ( isNormalWindow() || isDialog() ) && wantsInput(); } - bool Client::wantsInput() const { return rules()->checkAcceptFocus( input || Ptakefocus ); } bool Client::isSpecialWindow() const - { - return isDesktop() || isDock() || isSplash() || isTopMenu() - || isToolbar(); // TODO + { // TODO + return isDesktop() || isDock() || isSplash() || isTopMenu() || isToolbar(); } -/*! - Sets an appropriate cursor shape for the logical mouse position \a m - +/** + * Sets an appropriate cursor shape for the logical mouse position \a m */ void Client::updateCursor() { Position m = mode; - if( !isResizable() || isShade()) + if( !isResizable() || isShade() ) m = PositionCenter; QCursor c; switch( m ) @@ -1689,7 +1670,7 @@ void Client::updateCursor() cursor = c; if( decoration != NULL ) decoration->widget()->setCursor( cursor ); - XDefineCursor( display(), frameId(), cursor.handle()); + XDefineCursor( display(), frameId(), cursor.handle() ); if( moveResizeMode ) // XDefineCursor doesn't change cursor if there's pointer grab active XChangeActivePointerGrab( display(), ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask, @@ -1709,27 +1690,27 @@ void Client::updateAllowedActions( bool force ) return; unsigned long old_allowed_actions = allowed_actions; allowed_actions = 0; - if( isMovable()) + if( isMovable() ) allowed_actions |= NET::ActionMove; - if( isResizable()) + if( isResizable() ) allowed_actions |= NET::ActionResize; - if( isMinimizable()) + if( isMinimizable() ) allowed_actions |= NET::ActionMinimize; - if( isShadeable()) + if( isShadeable() ) allowed_actions |= NET::ActionShade; - // sticky state not supported - if( isMaximizable()) + // Sticky state not supported + if( isMaximizable() ) allowed_actions |= NET::ActionMax; - if( userCanSetFullScreen()) + if( userCanSetFullScreen() ) allowed_actions |= NET::ActionFullScreen; - allowed_actions |= NET::ActionChangeDesktop; // always (pagers shouldn't show Docks etc.) - if( isCloseable()) + allowed_actions |= NET::ActionChangeDesktop; // Always (Pagers shouldn't show Docks etc.) + if( isCloseable() ) allowed_actions |= NET::ActionClose; if( old_allowed_actions == allowed_actions ) return; - // TODO this could be delayed and compressed - it's only for pagers etc. anyway + // TODO: This could be delayed and compressed - It's only for pagers etc. anyway info->setAllowedActions( allowed_actions ); - // TODO this should also tell the decoration, so that it can update the buttons + // TODO: This should also tell the decoration, so that it can update the buttons } void Client::autoRaise() @@ -1737,7 +1718,7 @@ void Client::autoRaise() workspace()->raiseClient( this ); cancelAutoRaise(); } - + void Client::cancelAutoRaise() { delete autoRaiseTimer; @@ -1746,13 +1727,14 @@ void Client::cancelAutoRaise() void Client::debug( kdbgstream& stream ) const { - stream << "\'ID:" << window() << ";WMCLASS:" << resourceClass() << ":" << resourceName() << ";Caption:" << caption() << "\'"; + stream << "\'ID:" << window() << ";WMCLASS:" << resourceClass() << ":" + << resourceName() << ";Caption:" << caption() << "\'"; } -QPixmap * kwin_get_menu_pix_hack() +QPixmap* kwin_get_menu_pix_hack() { static QPixmap p; - if ( p.isNull() ) + if( p.isNull() ) p = SmallIcon( "bx2" ); return &p; } diff --git a/client.h b/client.h index f825c5129e..ade93a1e1e 100644 --- a/client.h +++ b/client.h @@ -46,6 +46,8 @@ along with this program. If not, see . #include #endif +// TODO: Cleanup the order of things in this .h file + class QProcess; class QTimer; class KStartupInfoData; @@ -62,7 +64,7 @@ class Client { Q_OBJECT public: - Client( Workspace *ws ); + Client( Workspace* ws ); Window wrapperId() const; Window decorationId() const; @@ -71,10 +73,10 @@ class Client bool isTransient() const; bool groupTransient() const; bool wasOriginallyGroupTransient() const; - ClientList mainClients() const; // call once before loop , is not indirect - ClientList allMainClients() const; // call once before loop , is indirect + ClientList mainClients() const; // Call once before loop , is not indirect + ClientList allMainClients() const; // Call once before loop , is indirect bool hasTransient( const Client* c, bool indirect ) const; - const ClientList& transients() const; // is not indirect + const ClientList& transients() const; // Is not indirect void checkTransient( Window w ); Client* findModal( bool allow_itself = false ); const Group* group() const; @@ -88,16 +90,18 @@ class Client void updateWindowRules(); void updateFullscreenMonitors( NETFullscreenMonitors topology ); - // 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 + /** + * 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; QSize minSize() const; QSize maxSize() const; - virtual QPoint clientPos() const; // inside of geometry() + virtual QPoint clientPos() const; // Inside of geometry() virtual QSize clientSize() const; bool windowEvent( XEvent* e ); @@ -110,12 +114,13 @@ class Client void releaseWindow( bool on_shutdown = false ); void destroyClient(); - enum Sizemode // how to resize the window in order to obey constains (mainly aspect ratios) + /// How to resize the window in order to obey constains (mainly aspect ratios) + enum Sizemode { SizemodeAny, - SizemodeFixedW, // try not to affect width - SizemodeFixedH, // try not to affect height - SizemodeMax // try not to make it larger in either direction + SizemodeFixedW, ///< Try not to affect width + SizemodeFixedH, ///< Try not to affect height + SizemodeMax ///< Try not to make it larger in either direction }; QSize adjustedSize( const QSize&, Sizemode mode = SizemodeAny ) const; QSize adjustedSize() const; @@ -129,13 +134,13 @@ class Client virtual int desktop() const; void setDesktop( int ); void setOnAllDesktops( bool set ); - - // !isMinimized() && not hidden, i.e. normally visible on some virtual desktop - bool isShown( bool shaded_is_shown ) const; - bool isHiddenInternal() const; // for compositing - bool isShade() const; // true only for ShadeNormal - ShadeMode shadeMode() const; // prefer isShade() + /// Is not minimized and not hidden. I.e. normally visible on some virtual desktop. + bool isShown( bool shaded_is_shown ) const; + bool isHiddenInternal() const; // For compositing + + bool isShade() const; // True only for ShadeNormal + ShadeMode shadeMode() const; // Prefer isShade() void setShade( ShadeMode mode ); bool isShadeable() const; @@ -153,7 +158,7 @@ class Client bool isFullScreenable( bool fullscreen_hack = false ) const; bool isActiveFullScreen() const; bool userCanSetFullScreen() const; - QRect geometryFSRestore() const { return geom_fs_restore; } // only for session saving + QRect geometryFSRestore() const { return geom_fs_restore; } // Only for session saving int fullScreenMode() const { return fullscreen_mode; } // only for session saving bool noBorder() const; @@ -178,16 +183,16 @@ class Client void setModal( bool modal ); bool isModal() const; - // auxiliary functions, depend on the windowType + // Auxiliary functions, depend on the windowType bool wantsTabFocus() const; bool wantsInput() const; bool isResizable() const; bool isMovable() const; bool isMovableAcrossScreens() const; - bool isCloseable() const; // may be closed by the user (may have a close button) + 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) + void takeActivity( int flags, bool handled, allowed_t ); // Takes ActivityFlags as arg (in utils.h) void takeFocus( allowed_t ); void demandAttention( bool set = true ); @@ -199,15 +204,15 @@ class Client void repaintDecoration(); 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 ); - void move( const QPoint & p, ForceGeometry_t force = NormalGeometrySet ); - // plainResize() simply resizes + void move( const QPoint& p, ForceGeometry_t force = NormalGeometrySet ); + /// plainResize() simply resizes void plainResize( int w, int h, ForceGeometry_t force = NormalGeometrySet ); void plainResize( const QSize& s, ForceGeometry_t force = NormalGeometrySet ); - // resizeWithChecks() resizes according to gravity, and checks workarea position + /// resizeWithChecks() resizes according to gravity, and checks workarea position void resizeWithChecks( int w, int h, ForceGeometry_t force = NormalGeometrySet ); void resizeWithChecks( const QSize& s, ForceGeometry_t force = NormalGeometrySet ); void keepInArea( QRect area, bool partial = false ); @@ -221,17 +226,17 @@ class Client KShortcut shortcut() const; void setShortcut( const QString& cut ); - bool performMouseCommand( Options::MouseCommand, const QPoint &globalPos, bool handled = false ); + bool performMouseCommand( Options::MouseCommand, const QPoint& globalPos, bool handled = false ); QRect adjustedClientArea( const QRect& desktop, const QRect& area ) const; Colormap colormap() const; - // updates visibility depending on being shaded, virtual desktop, etc. + /// Updates visibility depending on being shaded, virtual desktop, etc. void updateVisibility(); - // hides a client - basically like minimize, but without effects, it's simply hidden + /// Hides a client - Basically like minimize, but without effects, it's simply hidden void hideClient( bool hide ); - bool hiddenPreview() const; // window is mapped in order to get a window pixmap + bool hiddenPreview() const; ///< Window is mapped in order to get a window pixmap virtual void setupCompositing(); virtual void finishCompositing(); @@ -247,8 +252,9 @@ class Client void NETMoveResize( int x_root, int y_root, NET::Direction direction ); void NETMoveResizeWindow( int flags, int x, int y, int width, int height ); - void restackWindow( Window above, int detail, NET::RequestSource source, Time timestamp, bool send_event = false ); - + void restackWindow( Window above, int detail, NET::RequestSource source, Time timestamp, + bool send_event = false ); + void gotPing( Time timestamp ); void checkWorkspacePosition(); @@ -257,7 +263,7 @@ class Client bool hasUserTimeSupport() const; bool ignoreFocusStealing() const; - // does 'delete c;' + /// Does 'delete c;' static void deleteClient( Client* c, allowed_t ); static bool belongToSameApplication( const Client* c1, const Client* c2, bool active_hack = false ); @@ -284,7 +290,7 @@ class Client { return moveResizeMode && mode != PositionCenter; } - + // Decorations <-> Effects QList shadowQuads( ShadowType type ) const; double shadowOpacity( ShadowType type ) const; @@ -302,22 +308,22 @@ class Client friend class Bridge; // FRAME virtual void processMousePressEvent( QMouseEvent* e ); - private: // TODO cleanup the order of things in the .h file - // use Workspace::createClient() - virtual ~Client(); // use destroyClient() or releaseWindow() + private: + // Use Workspace::createClient() + virtual ~Client(); ///< Use destroyClient() or releaseWindow() Position mousePosition( const QPoint& ) const; void updateCursor(); - // transparent stuff + // Transparent stuff void drawbound( const QRect& geom ); void clearbound(); void doDrawbound( const QRect& geom, bool clear ); - // handlers for X11 events + // Handlers for X11 events bool mapRequestEvent( XMapRequestEvent* e ); - void unmapNotifyEvent( XUnmapEvent*e ); - void destroyNotifyEvent( XDestroyWindowEvent*e ); + void unmapNotifyEvent( XUnmapEvent* e ); + void destroyNotifyEvent( XDestroyWindowEvent* e ); void configureRequestEvent( XConfigureRequestEvent* e ); virtual void propertyNotifyEvent( XPropertyEvent* e ); void clientMessageEvent( XClientMessageEvent* e ); @@ -347,14 +353,14 @@ class Client void delayedSetShortcut(); private: - void exportMappingState( int s ); // ICCCM 4.1.3.1, 4.1.4 , NETWM 2.5.1 - bool isManaged() const; // returns false if this client is not yet managed + void exportMappingState( int s ); // ICCCM 4.1.3.1, 4.1.4, NETWM 2.5.1 + bool isManaged() const; ///< Returns false if this client is not yet managed void updateAllowedActions( bool force = false ); QSize sizeForClientSize( const QSize&, Sizemode mode = SizemodeAny, bool noframe = false ) const; QRect fullscreenMonitorsArea( NETFullscreenMonitors topology ) const; void changeMaximize( bool horizontal, bool vertical, bool adjust ); void checkMaximizeGeometry(); - int checkFullScreenHack( const QRect& geom ) const; // 0 - none, 1 - one xinerama screen, 2 - full area + int checkFullScreenHack( const QRect& geom ) const; // 0 - None, 1 - One xinerama screen, 2 - Full area void updateFullScreenHack( const QRect& geom ); void getWmNormalHints(); void getMotifHints(); @@ -397,7 +403,7 @@ class Client static void sendClientMessage( Window w, Atom a, Atom protocol, long data1 = 0, long data2 = 0, long data3 = 0 ); - void embedClient( Window w, const XWindowAttributes &attr ); + void embedClient( Window w, const XWindowAttributes& attr ); void detectNoBorder(); void destroyDecoration(); void updateFrameExtents(); @@ -415,7 +421,7 @@ class Client bool session ) const; Time readUserCreationTime() const; void startupIdChanged(); - + Window client; Window wrapper; KDecoration* decoration; @@ -433,14 +439,14 @@ class Client QPoint invertedMoveOffset; QRect moveResizeGeom; QRect initialMoveResizeGeom; - XSizeHints xSizeHint; + XSizeHints xSizeHint; void sendSyntheticConfigureNotify(); enum MappingState { - Withdrawn, // not handled, as per ICCCM WithdrawnState - Mapped, // the frame is mapped - Unmapped, // the frame is not mapped - Kept // the frame should be unmapped, but is kept (for compositing) + Withdrawn, ///< Not handled, as per ICCCM WithdrawnState + Mapped, ///< The frame is mapped + Unmapped, ///< The frame is not mapped + Kept ///< The frame should be unmapped, but is kept (For compositing) }; MappingState mapping_state; void readTransient(); @@ -454,31 +460,31 @@ class Client Client* transient_for; Window transient_for_id; Window original_transient_for_id; - ClientList transients_list; // SELI make this ordered in stacking order? + ClientList transients_list; // SELI TODO: Make this ordered in stacking order? ShadeMode shade_mode; - 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 skip_taskbar :1; - uint original_skip_taskbar :1; // unaffected by KWin - uint Pdeletewindow :1; // does the window understand the DeleteWindow protocol? - uint Ptakefocus :1;// does the window understand the TakeFocus protocol? - uint Ptakeactivity : 1; // does it support _NET_WM_TAKE_ACTIVITY - uint Pcontexthelp : 1; // does the window understand the ContextHelp protocol? - uint Pping : 1; // does it support _NET_WM_PING? - uint input :1; // does the window want input in its wm_hints + 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 skip_taskbar : 1; + uint original_skip_taskbar : 1; ///< Unaffected by KWin + uint Pdeletewindow : 1; ///< Does the window understand the DeleteWindow protocol? + uint Ptakefocus : 1;///< Does the window understand the TakeFocus protocol? + uint Ptakeactivity : 1; ///< Does it support _NET_WM_TAKE_ACTIVITY + uint Pcontexthelp : 1; ///< Does the window understand the ContextHelp protocol? + uint Pping : 1; ///< Does it support _NET_WM_PING? + uint input : 1; ///< Does the window want input in its wm_hints uint skip_pager : 1; uint motif_may_resize : 1; - uint motif_may_move :1; + uint motif_may_move : 1; uint motif_may_close : 1; - uint keep_below : 1; // NET::KeepBelow + uint keep_below : 1; ///< NET::KeepBelow uint minimized : 1; - uint hidden : 1; // forcibly hidden by calling hide() - uint modal : 1; // NET::Modal + uint hidden : 1; ///< Forcibly hidden by calling hide() + uint modal : 1; ///< NET::Modal uint noborder : 1; - uint app_noborder : 1; // the app requested no border using something (window type, motif hints) - uint urgency : 1; // XWMHints, UrgencyHint - uint ignore_focus_stealing : 1; // don't apply focus stealing prevention to this client + uint app_noborder : 1; ///< The app requested no border using something (window type, motif hints) + uint urgency : 1; ///< XWMHints, UrgencyHint + uint ignore_focus_stealing : 1; ///< Don't apply focus stealing prevention to this client uint demands_attention : 1; WindowRules client_rules; void getWMHints(); @@ -487,9 +493,13 @@ class Client QPixmap icon_pix; QPixmap miniicon_pix; QCursor cursor; - // FullScreenHack - non-NETWM fullscreen (noborder,size of desktop) - // DON'T reorder - saved to config files !!! - enum FullScreenMode { FullScreenNone, FullScreenNormal, FullScreenHack }; + // DON'T reorder - Saved to config files !!! + enum FullScreenMode + { + FullScreenNone, + FullScreenNormal, + FullScreenHack ///< Non-NETWM fullscreen (noborder and size of desktop) + }; FullScreenMode fullscreen_mode; MaximizeMode max_mode; QRect geom_restore; @@ -510,8 +520,13 @@ class Client Time user_time; unsigned long allowed_actions; QSize client_size; - int block_geometry_updates; // >0 - new geometry is remembered, but not actually set - enum PendingGeometry_t { PendingGeometryNone, PendingGeometryNormal, PendingGeometryForced }; + int block_geometry_updates; // > 0 = New geometry is remembered, but not actually set + enum PendingGeometry_t + { + PendingGeometryNone, + PendingGeometryNormal, + PendingGeometryForced + }; PendingGeometry_t pending_geometry_update; QRect geom_before_block; bool shade_geometry_change; @@ -524,7 +539,7 @@ class Client bool sync_resize_pending; int border_left, border_right, border_top, border_bottom; QRegion _mask; - static bool check_active_modal; // see Client::checkActiveModal() + static bool check_active_modal; ///< \see Client::checkActiveModal() KShortcut _shortcut; int sm_stacking_order; friend struct FetchNameInternalPredicate; @@ -536,7 +551,9 @@ class Client friend bool performTransiencyCheck(); }; -// helper for Client::blockGeometryUpdates() being called in pairs (true/false) +/** + * Helper for Client::blockGeometryUpdates() being called in pairs (true/false) + */ class GeometryUpdatesBlocker { public: @@ -544,23 +561,27 @@ class GeometryUpdatesBlocker : cl( c ) { cl->blockGeometryUpdates( true ); } ~GeometryUpdatesBlocker() { cl->blockGeometryUpdates( false ); } + private: Client* cl; }; - -// NET WM Protocol handler class +/** + * NET WM Protocol handler class + */ class WinInfo : public NETWinInfo2 { private: - typedef KWin::Client Client; // because of NET::Client + typedef KWin::Client Client; // Because of NET::Client + public: WinInfo( Client* c, Display * display, Window window, - Window rwin, const unsigned long pr[], int pr_size ); + Window rwin, const unsigned long pr[], int pr_size ); virtual void changeDesktop(int desktop); virtual void changeFullscreenMonitors(NETFullscreenMonitors topology); virtual void changeState( unsigned long state, unsigned long mask ); void disable(); + private: Client * m_client; }; @@ -590,7 +611,7 @@ inline bool Client::groupTransient() const return transient_for_id == rootWindow(); } -// needed because verifyTransientFor() may set transient_for_id to root window, +// Needed because verifyTransientFor() may set transient_for_id to root window, // if the original value has a problem (window doesn't exist, etc.) inline bool Client::wasOriginallyGroupTransient() const { @@ -617,8 +638,7 @@ inline Group* Client::group() return in_group; } -inline -bool Client::isMinimized() const +inline bool Client::isMinimized() const { return minimized; } @@ -628,26 +648,22 @@ inline bool Client::isActive() const return active; } -inline -bool Client::isShown( bool shaded_is_shown ) const +inline bool Client::isShown( bool shaded_is_shown ) const { return !isMinimized() && ( !isShade() || shaded_is_shown ) && !hidden; } -inline -bool Client::isHiddenInternal() const +inline bool Client::isHiddenInternal() const { return hidden; } -inline -bool Client::isShade() const +inline bool Client::isShade() const { return shade_mode == ShadeNormal; } -inline -ShadeMode Client::shadeMode() const +inline ShadeMode Client::shadeMode() const { return shade_mode; } @@ -747,7 +763,7 @@ inline void Client::setGeometry( const QRect& r, ForceGeometry_t force ) setGeometry( r.x(), r.y(), r.width(), r.height(), force ); } -inline void Client::move( const QPoint & p, ForceGeometry_t force ) +inline void Client::move( const QPoint& p, ForceGeometry_t force ) { move( p.x(), p.y(), force ); } @@ -766,7 +782,7 @@ inline bool Client::hasUserTimeSupport() const { return info->userTime() != -1U; } - + inline bool Client::ignoreFocusStealing() const { return ignore_focus_stealing; diff --git a/workspace.cpp b/workspace.cpp index 2aacce58ad..150beecd6c 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -73,141 +73,146 @@ namespace KWin extern int screen_number; -Workspace *Workspace::_self = 0; +Workspace* Workspace::_self = 0; +//----------------------------------------------------------------------------- // Rikkus: This class is too complex. It needs splitting further. // It's a nightmare to understand, especially with so few comments :( - +// // Matthias: Feel free to ask me questions about it. Feel free to add // comments. I dissagree that further splittings makes it easier. 2500 // lines are not too much. It's the task that is complex, not the // code. +//----------------------------------------------------------------------------- + Workspace::Workspace( bool restore ) - : QObject (0), - current_desktop (0), - number_of_desktops(0), - active_popup( NULL ), - active_popup_client( NULL ), - temporaryRulesMessages( "_KDE_NET_WM_TEMPORARY_RULES", NULL, false ), - rules_updates_disabled( false ), - active_client (0), - last_active_client (0), - most_recently_raised (0), - movingClient(0), - pending_take_activity ( NULL ), - active_screen (0), - delayfocus_client (0), - force_restacking( false ), - x_stacking_dirty( true ), - showing_desktop( false ), - block_showing_desktop( 0 ), - was_user_interaction (false), - session_saving (false), - control_grab (false), - tab_grab (false), - mouse_emulation (false), - block_focus (0), - tab_box (0), - popupinfo (0), - popup (0), - advanced_popup (0), - trans_popup (0), - desk_popup (0), - keys (0), - client_keys ( NULL ), - client_keys_dialog ( NULL ), - client_keys_client ( NULL ), - disable_shortcuts_keys ( NULL ), - global_shortcuts_disabled( false ), - global_shortcuts_disabled_for_client( false ), - workspaceInit (true), - startup(0), - layoutOrientation(Qt::Vertical), - layoutX(-1), - layoutY(2), - managing_topmenus( false ), - topmenu_selection( NULL ), - topmenu_watcher( NULL ), - topmenu_height( 0 ), - topmenu_space( NULL ), - set_active_client_recursion( 0 ), - block_stacking_updates( 0 ), - forced_global_mouse_grab( false ), - cm_selection( NULL ), - compositingSuspended( false ), - compositeRate( 0 ), - overlay( None ), - overlay_visible( true ), - overlay_shown( false ), - transSlider( NULL ), - transButton( NULL ), - forceUnredirectCheck( true ) + : QObject( 0 ) + , current_desktop( 0 ) + , number_of_desktops( 0 ) + , active_popup( NULL ) + , active_popup_client( NULL ) + , temporaryRulesMessages( "_KDE_NET_WM_TEMPORARY_RULES", NULL, false ) + , rules_updates_disabled( false ) + , active_client( 0 ) + , last_active_client( 0 ) + , most_recently_raised( 0 ) + , movingClient( 0 ) + , pending_take_activity( NULL ) + , active_screen( 0 ) + , delayfocus_client( 0 ) + , force_restacking( false ) + , x_stacking_dirty( true ) + , showing_desktop( false ) + , block_showing_desktop( 0 ) + , was_user_interaction( false ) + , session_saving( false ) + , control_grab( false ) + , tab_grab( false ) + , mouse_emulation( false ) + , block_focus( 0 ) + , tab_box( 0 ) + , popupinfo( 0 ) + , popup( 0 ) + , advanced_popup( 0 ) + , trans_popup( 0 ) + , desk_popup( 0 ) + , keys( 0 ) + , client_keys( NULL ) + , client_keys_dialog( NULL ) + , client_keys_client( NULL ) + , disable_shortcuts_keys( NULL ) + , global_shortcuts_disabled( false ) + , global_shortcuts_disabled_for_client( false ) + , workspaceInit( true ) + , startup( 0 ) + , layoutOrientation( Qt::Vertical ) + , layoutX( -1 ) + , layoutY( 2 ) + , managing_topmenus( false ) + , topmenu_selection( NULL ) + , topmenu_watcher( NULL ) + , topmenu_height( 0 ) + , topmenu_space( NULL ) + , set_active_client_recursion( 0 ) + , block_stacking_updates( 0 ) + , forced_global_mouse_grab( false ) + , cm_selection( NULL ) + , compositingSuspended( false ) + , compositeRate( 0 ) + , overlay( None ) + , overlay_visible( true ) + , overlay_shown( false ) + , transSlider( NULL ) + , transButton( NULL ) + , forceUnredirectCheck( true ) { (void) new KWinAdaptor( this ); + QDBusConnection dbus = QDBusConnection::sessionBus(); - dbus.registerObject("/KWin", this); - dbus.connect(QString(), "/KWin", "org.kde.KWin", "reloadConfig", this, SLOT(slotReloadConfig())); - dbus.connect(QString(), "/KWin", "org.kde.KWin", "reinitCompositing", this, SLOT(slotReinitCompositing())); + dbus.registerObject( "/KWin", this ); + dbus.connect( QString(), "/KWin", "org.kde.KWin", "reloadConfig", + this, SLOT( slotReloadConfig() )); + dbus.connect( QString(), "/KWin", "org.kde.KWin", "reinitCompositing", + this, SLOT( slotReinitCompositing() )); + _self = this; mgr = new PluginMgr; QX11Info info; - default_colormap = DefaultColormap(display(), info.screen() ); + default_colormap = DefaultColormap( display(), info.screen() ); installed_colormap = default_colormap; - for( int i = 0; - i < ELECTRIC_COUNT; - ++i ) + for( int i = 0; i < ELECTRIC_COUNT; ++i ) { - electric_reserved[ i ] = 0; - electric_windows[ i ] = None; + electric_reserved[i] = 0; + electric_windows[i] = None; } - connect( &temporaryRulesMessages, SIGNAL( gotMessage( const QString& )), - this, SLOT( gotTemporaryRulesMessage( const QString& ))); - connect( &rulesUpdatedTimer, SIGNAL( timeout()), this, SLOT( writeWindowRules())); - connect( &unredirectTimer, SIGNAL( timeout()), this, SLOT( delayedCheckUnredirect())); + connect( &temporaryRulesMessages, SIGNAL( gotMessage(const QString&) ), + this, SLOT( gotTemporaryRulesMessage(const QString&) )); + connect( &rulesUpdatedTimer, SIGNAL( timeout() ), this, SLOT( writeWindowRules() )); + connect( &unredirectTimer, SIGNAL( timeout() ), this, SLOT( delayedCheckUnredirect() )); unredirectTimer.setSingleShot( true ); - updateXTime(); // needed for proper initialization of user_time in Client ctor + updateXTime(); // Needed for proper initialization of user_time in Client ctor delayFocusTimer = 0; - if ( restore ) - loadSessionInfo(); + if( restore ) + loadSessionInfo(); loadWindowRules(); - // call this before XSelectInput() on the root window + // Call this before XSelectInput() on the root window startup = new KStartupInfo( KStartupInfo::DisableKWinModule | KStartupInfo::AnnounceSilenceChanges, this ); - // select windowmanager privileges - XSelectInput(display(), rootWindow(), - KeyPressMask | - PropertyChangeMask | - ColormapChangeMask | - SubstructureRedirectMask | - SubstructureNotifyMask | - FocusChangeMask | // for NotifyDetailNone - ExposureMask - ); + // Select windowmanager privileges + XSelectInput( display(), rootWindow(), + KeyPressMask | + PropertyChangeMask | + ColormapChangeMask | + SubstructureRedirectMask | + SubstructureNotifyMask | + FocusChangeMask | // For NotifyDetailNone + ExposureMask + ); Extensions::init(); setupCompositing(); - // compatibility + // Compatibility long data = 1; XChangeProperty( - display(), - rootWindow(), - atoms->kwin_running, - atoms->kwin_running, - 32, - PropModeAppend, - (unsigned char*) &data, - 1 - ); + display(), + rootWindow(), + atoms->kwin_running, + atoms->kwin_running, + 32, + PropModeAppend, + (unsigned char*)( &data ), + 1 + ); client_keys = new KActionCollection( this ); initShortcuts(); @@ -216,32 +221,32 @@ Workspace::Workspace( bool restore ) init(); - connect( Kephal::Screens::self(), SIGNAL( screenAdded( Kephal::Screen *)), SLOT( desktopResized())); - connect( Kephal::Screens::self(), SIGNAL( screenRemoved(int)), SLOT( desktopResized())); - connect( Kephal::Screens::self(), SIGNAL( screenResized( Kephal::Screen *, QSize, QSize)), SLOT( desktopResized())); - connect( Kephal::Screens::self(), SIGNAL( screenMoved( Kephal::Screen *, QPoint, QPoint)), SLOT( desktopResized())); + connect( Kephal::Screens::self(), SIGNAL( screenAdded(Kephal::Screen*) ), SLOT( desktopResized() )); + connect( Kephal::Screens::self(), SIGNAL( screenRemoved(int) ), SLOT( desktopResized() )); + connect( Kephal::Screens::self(), SIGNAL( screenResized(Kephal::Screen*, QSize, QSize) ), SLOT( desktopResized() )); + connect( Kephal::Screens::self(), SIGNAL( screenMoved(Kephal::Screen*, QPoint, QPoint) ), SLOT( desktopResized() )); } void Workspace::init() { if( options->electricBorders() == Options::ElectricAlways ) - reserveElectricBorderSwitching( true ); + reserveElectricBorderSwitching( true ); updateElectricBorders(); -// not used yet -// topDock = 0L; -// maximizedWindowCounter = 0; + // Not used yet + //topDock = 0L; + //maximizedWindowCounter = 0; supportWindow = new QWidget( NULL, Qt::X11BypassWindowManagerHint ); - XLowerWindow( display(), supportWindow->winId()); // see usage in layers.cpp + XLowerWindow( display(), supportWindow->winId() ); // See usage in layers.cpp XSetWindowAttributes attr; attr.override_redirect = 1; null_focus_window = XCreateWindow( display(), rootWindow(), -1,-1, 1, 1, 0, CopyFromParent, InputOnly, CopyFromParent, CWOverrideRedirect, &attr ); - XMapWindow(display(), null_focus_window); + XMapWindow( display(), null_focus_window ); - unsigned long protocols[ 5 ] = + unsigned long protocols[5] = { NET::Supported | NET::SupportingWMCheck | @@ -277,17 +282,17 @@ void Workspace::init() NET::TopMenuMask | NET::UtilityMask | NET::SplashMask | - // No compositing window types here unless we support them also as managed window types + // No compositing window types here unless we support them also as managed window types 0 , NET::Modal | -// NET::Sticky | // large desktops not supported (and probably never will be) + //NET::Sticky | // Large desktops not supported (and probably never will be) NET::MaxVert | NET::MaxHoriz | NET::Shaded | NET::SkipTaskbar | NET::KeepAbove | -// NET::StaysOnTop | the same like KeepAbove + //NET::StaysOnTop | // The same like KeepAbove NET::SkipPager | NET::Hidden | NET::FullScreen | @@ -311,7 +316,7 @@ void Workspace::init() NET::ActionResize | NET::ActionMinimize | NET::ActionShade | -// NET::ActionStick | // Sticky state is not supported + //NET::ActionStick | // Sticky state is not supported NET::ActionMaxVert | NET::ActionMaxHoriz | NET::ActionFullScreen | @@ -321,16 +326,15 @@ void Workspace::init() , }; - QX11Info info; - rootInfo = new RootInfo( this, display(), supportWindow->winId(), "KWin", - protocols, 5, info.screen() ); + QX11Info info; + rootInfo = new RootInfo( this, display(), supportWindow->winId(), "KWin", protocols, 5, info.screen() ); loadDesktopSettings(); updateDesktopLayout(); - // extra NETRootInfo instance in Client mode is needed to get the values of the properties + // Extra NETRootInfo instance in Client mode is needed to get the values of the properties NETRootInfo client_info( display(), NET::ActiveWindow | NET::CurrentDesktop ); int initial_desktop; - if( !kapp->isSessionRestored()) + if( !kapp->isSessionRestored() ) initial_desktop = client_info.currentDesktop(); else { @@ -340,71 +344,69 @@ void Workspace::init() if( !setCurrentDesktop( initial_desktop )) setCurrentDesktop( 1 ); - // now we know how many desktops we'll, thus, we initialize the positioning object - initPositioning = new Placement(this); + // Now we know how many desktops we'll have, thus we initialize the positioning object + initPositioning = new Placement( this ); reconfigureTimer.setSingleShot( true ); updateToolWindowsTimer.setSingleShot( true ); - connect(&reconfigureTimer, SIGNAL(timeout()), this, - SLOT(slotReconfigure())); - connect( &updateToolWindowsTimer, SIGNAL( timeout()), this, SLOT( slotUpdateToolWindows())); - connect( &compositeTimer, SIGNAL( timeout()), SLOT( performCompositing())); + 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(reconfigure())); - connect(KGlobalSettings::self(), SIGNAL(settingsChanged(int)), this, - SLOT(slotSettingsChanged(int))); - connect(KGlobalSettings::self(), SIGNAL(blockShortcuts(int)), this, - SLOT(slotBlockShortcuts(int))); + connect( KGlobalSettings::self(), SIGNAL( appearanceChanged() ), this, SLOT( reconfigure() )); + connect( KGlobalSettings::self(), SIGNAL( settingsChanged(int) ), this, SLOT( slotSettingsChanged(int) )); + connect( KGlobalSettings::self(), SIGNAL( blockShortcuts(int) ), this, SLOT( slotBlockShortcuts(int) )); active_client = NULL; rootInfo->setActiveWindow( None ); focusToNull(); - if( !kapp->isSessionRestored()) - ++block_focus; // because it will be set below + if( !kapp->isSessionRestored() ) + ++block_focus; // Because it will be set below - char nm[ 100 ]; + char nm[100]; sprintf( nm, "_KDE_TOPMENU_OWNER_S%d", DefaultScreen( display())); Atom topmenu_atom = XInternAtom( display(), nm, False ); topmenu_selection = new KSelectionOwner( topmenu_atom ); topmenu_watcher = new KSelectionWatcher( topmenu_atom ); -// TODO grabXServer(); - where exactly put this? topmenu selection claiming down belong must be before + //TODO: grabXServer(); // Where exactly put this? topmenu selection claiming down belong must be before - { // begin updates blocker block + { // Begin updates blocker block StackingUpdatesBlocker blocker( this ); if( options->topMenuEnabled() && topmenu_selection->claim( false )) - setupTopMenuHandling(); // this can call updateStackingOrder() + setupTopMenuHandling(); // This can call updateStackingOrder() else lostTopMenuSelection(); unsigned int i, nwins; - Window root_return, parent_return, *wins; - XQueryTree(display(), rootWindow(), &root_return, &parent_return, &wins, &nwins); - for (i = 0; i < nwins; i++) + Window root_return, parent_return; + Window* wins; + XQueryTree( display(), rootWindow(), &root_return, &parent_return, &wins, &nwins ); + for( i = 0; i < nwins; i++ ) { XWindowAttributes attr; - XGetWindowAttributes(display(), wins[i], &attr); - if (attr.override_redirect ) + XGetWindowAttributes( display(), wins[i], &attr ); + if( attr.override_redirect ) { - createUnmanaged( wins[ i ] ); + createUnmanaged( wins[i] ); continue; } - if( topmenu_space && topmenu_space->winId() == wins[ i ] ) + if( topmenu_space && topmenu_space->winId() == wins[i] ) continue; - if (attr.map_state != IsUnmapped) + if( attr.map_state != IsUnmapped ) createClient( wins[i], true ); } - if ( wins ) - XFree((void *) wins); - // propagate clients, will really happen at the end of the updates blocker block + if( wins ) + XFree( (void*)( wins )); + + // Propagate clients, will really happen at the end of the updates blocker block updateStackingOrder( true ); updateClientArea(); - // NETWM spec says we have to set it to (0,0) if we don't support it - NETPoint* viewports = new NETPoint[ number_of_desktops ]; + // NETWM spec says we have to set it to (0,0) if we don't support it + NETPoint* viewports = new NETPoint[number_of_desktops]; rootInfo->setDesktopViewport( number_of_desktops, *viewports ); delete[] viewports; QRect geom = Kephal::ScreenUtils::desktopGeometry(); @@ -414,42 +416,45 @@ void Workspace::init() rootInfo->setDesktopGeometry( -1, desktop_geometry ); setShowingDesktop( false ); - } // end updates blocker block + } // End updates blocker block Client* new_active_client = NULL; - if( !kapp->isSessionRestored()) + if( !kapp->isSessionRestored() ) { --block_focus; - new_active_client = findClient( WindowMatchPredicate( client_info.activeWindow())); + new_active_client = findClient( WindowMatchPredicate( client_info.activeWindow() )); } if( new_active_client == NULL - && activeClient() == NULL && should_get_focus.count() == 0 ) // no client activated in manage() - { + && activeClient() == NULL && should_get_focus.count() == 0 ) + { // No client activated in manage() if( new_active_client == NULL ) new_active_client = topClientOnDesktop( currentDesktop(), -1 ); if( new_active_client == NULL && !desktops.isEmpty() ) - new_active_client = findDesktop( true, currentDesktop()); + new_active_client = findDesktop( true, currentDesktop() ); } if( new_active_client != NULL ) activateClient( new_active_client ); - // SELI TODO this won't work with unreasonable focus policies, + // SELI TODO: This won't work with unreasonable focus policies, // and maybe in rare cases also if the selected client doesn't // want focus workspaceInit = false; -// TODO ungrabXServer() + + // TODO: ungrabXServer() } Workspace::~Workspace() { finishCompositing(); blockStackingUpdates( true ); -// TODO grabXServer(); - // use stacking_order, so that kwin --replace keeps stacking order + + // TODO: grabXServer(); + + // Use stacking_order, so that kwin --replace keeps stacking order for( ClientList::ConstIterator it = stacking_order.constBegin(); - it != stacking_order.constEnd(); - ++it ) + it != stacking_order.constEnd(); + ++it ) { - // only release the window + // Only release the window (*it)->releaseWindow( true ); // No removeClient() is called, it does more than just removing. // However, remove from some lists to e.g. prevent performTransiencyCheck() @@ -458,13 +463,13 @@ Workspace::~Workspace() desktops.removeAll( *it ); } for( UnmanagedList::ConstIterator it = unmanaged.constBegin(); - it != unmanaged.constEnd(); - ++it ) + it != unmanaged.constEnd(); + ++it ) (*it)->release(); delete tab_box; delete popupinfo; discardPopup(); - XDeleteProperty(display(), rootWindow(), atoms->kwin_running); + XDeleteProperty( display(), rootWindow(), atoms->kwin_running ); writeWindowRules(); KGlobal::config()->sync(); @@ -478,15 +483,17 @@ Workspace::~Workspace() delete topmenu_selection; delete topmenu_space; delete client_keys_dialog; - while( !rules.isEmpty()) + while( !rules.isEmpty() ) { delete rules.front(); rules.pop_front(); } - foreach ( SessionInfo* s, session ) - delete s; + foreach( SessionInfo* s, session ) + delete s; XDestroyWindow( display(), null_focus_window ); -// TODO ungrabXServer(); + + // TODO: ungrabXServer(); + _self = 0; } @@ -503,7 +510,7 @@ Client* Workspace::createClient( Window w, bool is_mapped ) if( scene ) scene->windowAdded( c ); if( effects ) - static_cast(effects)->windowAdded( c->effectWindow()); + static_cast( effects )->windowAdded( c->effectWindow() ); return c; } @@ -521,47 +528,47 @@ Unmanaged* Workspace::createUnmanaged( Window w ) if( scene ) scene->windowAdded( c ); if( effects ) - static_cast(effects)->windowAdded( c->effectWindow()); + static_cast( effects )->windowAdded( c->effectWindow() ); return c; } void Workspace::addClient( Client* c, allowed_t ) { - Group* grp = findGroup( c->window()); + Group* grp = findGroup( c->window() ); if( grp != NULL ) grp->gotLeader( c ); - if ( c->isDesktop() ) + if( c->isDesktop() ) { desktops.append( c ); - if( active_client == NULL && should_get_focus.isEmpty() && c->isOnCurrentDesktop()) - requestFocus( c ); // CHECKME? make sure desktop is active after startup if there's no other window active + if( active_client == NULL && should_get_focus.isEmpty() && c->isOnCurrentDesktop() ) + requestFocus( c ); // TODO: Make sure desktop is active after startup if there's no other window active } else { - updateFocusChains( c, FocusChainUpdate ); // add to focus chain if not already there + updateFocusChains( c, FocusChainUpdate ); // Add to focus chain if not already there clients.append( c ); } if( !unconstrained_stacking_order.contains( c )) - unconstrained_stacking_order.append( c ); // raise if it hasn't got any stacking position yet - if( !stacking_order.contains( c )) // it'll be updated later, and updateToolWindows() requires + unconstrained_stacking_order.append( c ); // Raise if it hasn't got any stacking position yet + if( !stacking_order.contains( c )) // It'll be updated later, and updateToolWindows() requires stacking_order.append( c ); // c to be in stacking_order if( c->isTopMenu()) addTopMenu( c ); x_stacking_dirty = true; - updateClientArea(); // this cannot be in manage(), because the client got added only now + updateClientArea(); // This cannot be in manage(), because the client got added only now updateClientLayer( c ); if( c->isDesktop()) { raiseClient( c ); - // if there's no active client, make this desktop the active one + // If there's no active client, make this desktop the active one if( activeClient() == NULL && should_get_focus.count() == 0 ) - activateClient( findDesktop( true, currentDesktop())); + activateClient( findDesktop( true, currentDesktop() )); } c->checkActiveModal(); - checkTransients( c->window()); // SELI does this really belong here? - updateStackingOrder( true ); // propagate new client - if( c->isUtility() || c->isMenu() || c->isToolbar()) + checkTransients( c->window() ); // SELI TODO: Does this really belong here? + updateStackingOrder( true ); // Propagate new client + if( c->isUtility() || c->isMenu() || c->isToolbar() ) updateToolWindows( true ); checkNonExistentClients(); if( tab_grab ) @@ -574,8 +581,8 @@ void Workspace::addUnmanaged( Unmanaged* c, allowed_t ) x_stacking_dirty = true; } -/* - Destroys the client \a c +/** + * Destroys the client \a c */ void Workspace::removeClient( Client* c, allowed_t ) { @@ -584,10 +591,10 @@ void Workspace::removeClient( Client* c, allowed_t ) if( client_keys_client == c ) setupWindowShortcutDone( false ); - if( !c->shortcut().isEmpty()) + if( !c->shortcut().isEmpty() ) { - c->setShortcut( QString() ); // remove from client_keys - clientShortcutUpdated( c ); // needed, since this is otherwise delayed by setShortcut() and wouldn't run + c->setShortcut( QString() ); // Remove from client_keys + clientShortcutUpdated( c ); // Needed, since this is otherwise delayed by setShortcut() and wouldn't run } if( c->isDialog()) @@ -595,11 +602,8 @@ 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 ); - } + if( tab_grab && tab_box->currentClient() == c ) + tab_box->nextPrev( true ); Q_ASSERT( clients.contains( c ) || desktops.contains( c )); clients.removeAll( c ); @@ -607,24 +611,22 @@ void Workspace::removeClient( Client* c, allowed_t ) unconstrained_stacking_order.removeAll( c ); stacking_order.removeAll( c ); x_stacking_dirty = true; - for( int i = 1; - i <= numberOfDesktops(); - ++i ) - focus_chain[ i ].removeAll( c ); + for( int i = 1; i <= numberOfDesktops(); ++i ) + focus_chain[i].removeAll( c ); global_focus_chain.removeAll( c ); attention_chain.removeAll( c ); showing_desktop_clients.removeAll( c ); - if( c->isTopMenu()) + if( c->isTopMenu() ) removeTopMenu( c ); Group* group = findGroup( c->window()); if( group != NULL ) group->lostLeader(); - if ( c == most_recently_raised ) + if( c == most_recently_raised ) most_recently_raised = 0; should_get_focus.removeAll( c ); Q_ASSERT( c != active_client ); - if ( c == last_active_client ) + if( c == last_active_client ) last_active_client = 0; if( c == pending_take_activity ) pending_take_activity = NULL; @@ -659,72 +661,70 @@ void Workspace::removeDeleted( Deleted* c, allowed_t ) if( scene ) scene->windowDeleted( c ); if( effects ) - static_cast(effects)->windowDeleted( c->effectWindow()); + static_cast( effects )->windowDeleted( c->effectWindow() ); deleted.removeAll( c ); x_stacking_dirty = true; } void Workspace::updateFocusChains( Client* c, FocusChainChange change ) { - if( !c->wantsTabFocus()) // doesn't want tab focus, remove + if( !c->wantsTabFocus() ) // Doesn't want tab focus, remove { - for( int i=1; - i<= numberOfDesktops(); - ++i ) - focus_chain[i].removeAll(c); + for( int i = 1; i <= numberOfDesktops(); ++i ) + focus_chain[i].removeAll( c ); global_focus_chain.removeAll( c ); return; } - if(c->desktop() == NET::OnAllDesktops) - { //now on all desktops, add it to focus_chains it is not already in - for( int i=1; i<= numberOfDesktops(); i++) - { // making first/last works only on current desktop, don't affect all desktops + if( c->desktop() == NET::OnAllDesktops ) + { // Now on all desktops, add it to focus_chains it is not already in + for( int i = 1; i <= numberOfDesktops(); i++) + { // Making first/last works only on current desktop, don't affect all desktops if( i == currentDesktop() && ( change == FocusChainMakeFirst || change == FocusChainMakeLast )) { - focus_chain[ i ].removeAll( c ); + focus_chain[i].removeAll( c ); if( change == FocusChainMakeFirst ) - focus_chain[ i ].append( c ); + focus_chain[i].append( c ); else - focus_chain[ i ].prepend( c ); + focus_chain[i].prepend( c ); } - else if( !focus_chain[ i ].contains( 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 if( !focus_chain[i].contains( 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 + focus_chain[i].append( c ); // Otherwise add as the first one } } } - else //now only on desktop, remove it anywhere else + else // Now only on desktop, remove it anywhere else { - for( int i=1; i<= numberOfDesktops(); i++) + for( int i = 1; i <= numberOfDesktops(); i++) { - if( i == c->desktop()) + if( i == c->desktop() ) { if( change == FocusChainMakeFirst ) { - focus_chain[ i ].removeAll( c ); - focus_chain[ i ].append( c ); + focus_chain[i].removeAll( c ); + focus_chain[i].append( c ); } else if( change == FocusChainMakeLast ) { - focus_chain[ i ].removeAll( c ); - focus_chain[ i ].prepend( c ); + focus_chain[i].removeAll( c ); + focus_chain[i].prepend( c ); } - else if( !focus_chain[ i ].contains( 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 if( !focus_chain[i].contains( 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 + focus_chain[i].append( c ); // Otherwise add as the first one } } else - focus_chain[ i ].removeAll( c ); + focus_chain[i].removeAll( c ); } } if( change == FocusChainMakeFirst ) @@ -738,129 +738,130 @@ void Workspace::updateFocusChains( Client* c, FocusChainChange change ) global_focus_chain.prepend( c ); } else if( !global_focus_chain.contains( c )) - { // add it after the active one - if( active_client != NULL && active_client != c - && !global_focus_chain.isEmpty() && global_focus_chain.last() == active_client ) + { // 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 + global_focus_chain.append( c ); // Otherwise add as the first one } } void Workspace::updateCurrentTopMenu() { - if( !managingTopMenus()) + if( !managingTopMenus() ) return; // toplevel menubar handling Client* menubar = 0; bool block_desktop_menubar = false; if( active_client ) { - // show the new menu bar first... + // Show the new menu bar first... Client* menu_client = active_client; - for(;;) + for( ;; ) { - if( menu_client->isFullScreen()) + if( menu_client->isFullScreen() ) block_desktop_menubar = true; for( ClientList::ConstIterator it = menu_client->transients().constBegin(); - it != menu_client->transients().constEnd(); - ++it ) - if( (*it)->isTopMenu()) + it != menu_client->transients().constEnd(); + ++it ) + if( (*it)->isTopMenu() ) { menubar = *it; break; } - if( menubar != NULL || !menu_client->isTransient()) + if( menubar != NULL || !menu_client->isTransient() ) break; if( menu_client->isModal() || menu_client->transientFor() == NULL ) - break; // don't use mainwindow's menu if this is modal or group transient + break; // Don't use mainwindow's menu if this is modal or group transient menu_client = menu_client->transientFor(); } if( !menubar ) - { // try to find any topmenu from the application (#72113) + { // Try to find any topmenu from the application (#72113) for( ClientList::ConstIterator it = active_client->group()->members().constBegin(); - it != active_client->group()->members().constEnd(); - ++it ) - if( (*it)->isTopMenu()) + it != active_client->group()->members().constEnd(); + ++it ) + if( (*it)->isTopMenu() ) { menubar = *it; break; } } } - if( !menubar && !block_desktop_menubar && options->desktopTopMenu()) + if( !menubar && !block_desktop_menubar && options->desktopTopMenu() ) { // Find the menubar of the desktop - Client* desktop = findDesktop( true, currentDesktop()); + Client* desktop = findDesktop( true, currentDesktop() ); if( desktop != NULL ) { for( ClientList::ConstIterator it = desktop->transients().constBegin(); - it != desktop->transients().constEnd(); - ++it ) - if( (*it)->isTopMenu()) + it != desktop->transients().constEnd(); + ++it ) + if( (*it)->isTopMenu() ) { menubar = *it; break; } } - // TODO to be cleaned app with window grouping + // TODO: To be cleaned app with window grouping // Without qt-copy patch #0009, the topmenu and desktop are not in the same group, // thus the topmenu is not transient for it :-/. if( menubar == NULL ) { for( ClientList::ConstIterator it = topmenus.constBegin(); - it != topmenus.constEnd(); - ++it ) - if( (*it)->wasOriginallyGroupTransient()) // kdesktop's topmenu has WM_TRANSIENT_FOR - { // set pointing to the root window - menubar = *it; // to recognize it here - break; // Also, with the xroot hack in kdesktop, - } // there's no NET::Desktop window to be transient for + it != topmenus.constEnd(); + ++it ) + // kdesktop's topmenu has WM_TRANSIENT_FOR set pointing to the root window + // to recognize it here. Also, with the xroot hack in kdesktop, there's + // no NET::Desktop window to be transient for. + if( (*it)->wasOriginallyGroupTransient() ) + { + menubar = *it; + break; + } } } -// kDebug(1212) << "CURRENT TOPMENU:" << menubar << ":" << active_client; - if ( menubar ) + //kDebug( 1212 ) << "CURRENT TOPMENU:" << menubar << ":" << active_client; + if( menubar ) { - if( active_client && !menubar->isOnDesktop( active_client->desktop())) - menubar->setDesktop( active_client->desktop()); + if( active_client && !menubar->isOnDesktop( active_client->desktop() )) + menubar->setDesktop( active_client->desktop() ); menubar->hideClient( false ); topmenu_space->hide(); - // make it appear like it's been raised manually - it's in the Dock layer anyway, + // Make it appear like it's been raised manually - it's in the Dock layer anyway, // and not raising it could mess up stacking order of topmenus within one application, // and thus break raising of mainclients in raiseClient() unconstrained_stacking_order.removeAll( menubar ); unconstrained_stacking_order.append( menubar ); } else if( !block_desktop_menubar ) - { // no topmenu active - show the space window, so that there's not empty space + { // No topmenu active - show the space window, so that there's not empty space topmenu_space->show(); } - // ... then hide the other ones. Avoids flickers. - for ( ClientList::ConstIterator it = clients.constBegin(); it != clients.constEnd(); ++it) - { + // ... Then hide the other ones. Avoids flickers. + for( ClientList::ConstIterator it = clients.constBegin(); it != clients.constEnd(); ++it ) if( (*it)->isTopMenu() && (*it) != menubar ) (*it)->hideClient( true ); - } } void Workspace::updateToolWindows( bool also_hide ) { - // TODO what if Client's transiency/group changes? should this be called too? (I'm paranoid, am I not?) + // TODO: What if Client's transiency/group changes? should this be called too? (I'm paranoid, am I not?) if( !options->hideUtilityWindowsForInactive ) { for( ClientList::ConstIterator it = clients.constBegin(); - it != clients.constEnd(); - ++it ) + it != clients.constEnd(); + ++it ) (*it)->hideClient( false ); return; } const Group* group = NULL; const Client* client = active_client; -// Go up in transiency hiearchy, if the top is found, only tool transients for the top mainwindow -// will be shown; if a group transient is group, all tools in the group will be shown + // Go up in transiency hiearchy, if the top is found, only tool transients for the top mainwindow + // will be shown; if a group transient is group, all tools in the group will be shown while( client != NULL ) { if( !client->isTransient()) @@ -872,23 +873,23 @@ void Workspace::updateToolWindows( bool also_hide ) } client = client->transientFor(); } - // use stacking order only to reduce flicker, it doesn't matter if block_stacking_updates == 0, - // i.e. if it's not up to date + // Use stacking order only to reduce flicker, it doesn't matter if block_stacking_updates == 0, + // I.e. if it's not up to date - // SELI but maybe it should - what if a new client has been added that's not in stacking order yet? + // SELI TODO: But maybe it should - what if a new client has been added that's not in stacking order yet? ClientList to_show, to_hide; for( ClientList::ConstIterator it = stacking_order.constBegin(); - it != stacking_order.constEnd(); - ++it ) + it != stacking_order.constEnd(); + ++it ) { - if( (*it)->isUtility() || (*it)->isMenu() || (*it)->isToolbar()) + if( (*it)->isUtility() || (*it)->isMenu() || (*it)->isToolbar() ) { bool show = true; - if( !(*it)->isTransient()) + if( !(*it)->isTransient() ) { - if( (*it)->group()->members().count() == 1 ) // has its own group, keep always visible + if( (*it)->group()->members().count() == 1 ) // Has its own group, keep always visible show = true; - else if( client != NULL && (*it)->group() == client->group()) + else if( client != NULL && (*it)->group() == client->group() ) show = true; else show = false; @@ -905,15 +906,15 @@ void Workspace::updateToolWindows( bool also_hide ) if( !show && also_hide ) { const ClientList mainclients = (*it)->mainClients(); - // don't hide utility windows which are standalone(?) or + // Don't hide utility windows which are standalone(?) or // have e.g. kicker as mainwindow if( mainclients.isEmpty()) show = true; for( ClientList::ConstIterator it2 = mainclients.constBegin(); - it2 != mainclients.constEnd(); - ++it2 ) + it2 != mainclients.constEnd(); + ++it2 ) { - if( (*it2)->isSpecialWindow()) + if( (*it2)->isSpecialWindow() ) show = true; } if( !show ) @@ -922,24 +923,23 @@ void Workspace::updateToolWindows( bool also_hide ) if( show ) to_show.append( *it ); } - } // first show new ones, then hide - for( int i = to_show.size() - 1; - i >= 0; - --i ) //from topmost - // TODO since this is in stacking order, the order of taskbar entries changes :( - to_show.at( i )->hideClient( false ); + } // First show new ones, then hide + for( int i = to_show.size() - 1; + i >= 0; + --i ) // From topmost + // TODO: Since this is in stacking order, the order of taskbar entries changes :( + to_show.at( i )->hideClient( false ); if( also_hide ) { for( ClientList::ConstIterator it = to_hide.constBegin(); - it != to_hide.constEnd(); - ++it ) // from bottommost + it != to_hide.constEnd(); + ++it ) // From bottommost (*it)->hideClient( true ); updateToolWindowsTimer.stop(); } else // setActiveClient() is after called with NULL client, quickly followed - { // by setting a new client, which would result in flickering + // by setting a new client, which would result in flickering updateToolWindowsTimer.start( 50 ); - } } void Workspace::slotUpdateToolWindows() @@ -947,59 +947,61 @@ void Workspace::slotUpdateToolWindows() updateToolWindows( true ); } -/*! - Updates the current colormap according to the currently active client +/** + * Updates the current colormap according to the currently active client */ void Workspace::updateColormap() { Colormap cmap = default_colormap; - if ( activeClient() && activeClient()->colormap() != None ) + if( activeClient() && activeClient()->colormap() != None ) cmap = activeClient()->colormap(); - if ( cmap != installed_colormap ) + if( cmap != installed_colormap ) { - XInstallColormap(display(), cmap ); + XInstallColormap( display(), cmap ); installed_colormap = cmap; } } void Workspace::slotReloadConfig() -{ - reconfigure(); -} + { + reconfigure(); + } void Workspace::reconfigure() { reconfigureTimer.start( 200 ); } -// This DBUS call is used by the compositing kcm. Since the reconfigure() -// DBUS call delays the actual reconfiguring, it is not possible to immediately -// call compositingActive(). Therefore the kcm will instead call this to ensure -// the reconfiguring has already happened. +/** + * This D-Bus call is used by the compositing kcm. Since the reconfigure() + * D-Bus call delays the actual reconfiguring, it is not possible to immediately + * call compositingActive(). Therefore the kcm will instead call this to ensure + * the reconfiguring has already happened. + */ bool Workspace::waitForCompositingSetup() { - if( !reconfigureTimer.isActive()) + if( !reconfigureTimer.isActive() ) return false; reconfigureTimer.stop(); slotReconfigure(); return compositingActive(); } -void Workspace::slotSettingsChanged(int category) +void Workspace::slotSettingsChanged( int category ) { - kDebug(1212) << "Workspace::slotSettingsChanged()"; + kDebug( 1212 ) << "Workspace::slotSettingsChanged()"; if( category == KGlobalSettings::SETTINGS_SHORTCUTS ) readShortcuts(); } -/*! - Reread settings +/** + * Reread settings */ -KWIN_PROCEDURE( CheckBorderSizesProcedure, Client, cl->checkBorderSizes( true ) ); +KWIN_PROCEDURE( CheckBorderSizesProcedure, Client, cl->checkBorderSizes( true )); void Workspace::slotReconfigure() { - kDebug(1212) << "Workspace::slotReconfigure()"; + kDebug( 1212 ) << "Workspace::slotReconfigure()"; reconfigureTimer.stop(); if( options->electricBorders() == Options::ElectricAlways ) @@ -1016,24 +1018,23 @@ void Workspace::slotReconfigure() updateToolWindows( true ); if( mgr->reset( changed )) - { // decorations need to be recreated -#if 0 // This actually seems to make things worse now - QWidget curtain; - curtain.setBackgroundMode( NoBackground ); - curtain.setGeometry( Kephal::ScreenUtils::desktopGeometry() ); - curtain.show(); -#endif + { // Decorations need to be recreated + + // This actually seems to make things worse now + //QWidget curtain; + //curtain.setBackgroundMode( NoBackground ); + //curtain.setGeometry( Kephal::ScreenUtils::desktopGeometry() ); + //curtain.show(); + for( ClientList::ConstIterator it = clients.constBegin(); - it != clients.constEnd(); - ++it ) - { + it != clients.constEnd(); + ++it ) (*it)->updateDecoration( true, true ); - } mgr->destroyPreviousPlugin(); } else { - forEachClient( CheckBorderSizesProcedure()); + forEachClient( CheckBorderSizesProcedure() ); foreach( Client* c, clients ) c->repaintDecoration(); } @@ -1042,39 +1043,39 @@ void Workspace::slotReconfigure() reserveElectricBorderSwitching( true ); updateElectricBorders(); - if( options->topMenuEnabled() && !managingTopMenus()) + if( options->topMenuEnabled() && !managingTopMenus() ) { if( topmenu_selection->claim( false )) setupTopMenuHandling(); else lostTopMenuSelection(); } - else if( !options->topMenuEnabled() && managingTopMenus()) + else if( !options->topMenuEnabled() && managingTopMenus() ) { topmenu_selection->release(); lostTopMenuSelection(); } - topmenu_height = 0; // invalidate used menu height - if( managingTopMenus()) + topmenu_height = 0; // Invalidate used menu height + if( managingTopMenus() ) { updateTopMenuGeometry(); updateCurrentTopMenu(); } if( options->useCompositing && !compositingSuspended ) - { + { setupCompositing(); if( effects ) // setupCompositing() may fail effects->reconfigure(); addRepaintFull(); - } + } else finishCompositing(); loadWindowRules(); for( ClientList::Iterator it = clients.begin(); - it != clients.end(); - ++it ) + it != clients.end(); + ++it ) { (*it)->setupWindowRules( true ); (*it)->applyWindowRules(); @@ -1091,9 +1092,8 @@ void Workspace::slotReinitCompositing() // Update any settings that can be set in the compositing kcm. updateElectricBorders(); - // Stop any current compositing + // Restart compositing finishCompositing(); - // And start new one setupCompositing(); if( effects ) // setupCompositing() may fail effects->reconfigure(); @@ -1103,25 +1103,24 @@ void Workspace::loadDesktopSettings() { KSharedConfig::Ptr c = KGlobal::config(); QString groupname; - if (screen_number == 0) + if( screen_number == 0 ) groupname = "Desktops"; else - groupname.sprintf("Desktops-screen-%d", screen_number); - KConfigGroup group(c,groupname); + groupname.sprintf( "Desktops-screen-%d", screen_number ); + KConfigGroup group( c, groupname ); - int n = group.readEntry("Number", 4); + int n = group.readEntry( "Number", 4 ); number_of_desktops = n; workarea.clear(); workarea.resize( n + 1 ); screenarea.clear(); rootInfo->setNumberOfDesktops( number_of_desktops ); desktop_focus_chain.resize( n ); - // make it +1, so that it can be accessed as [1..numberofdesktops] + // Make it +1, so that it can be accessed as [1..numberofdesktops] focus_chain.resize( n + 1 ); - for(int i = 1; i <= n; i++) + for( int i = 1; i <= n; i++ ) { - QString s = group.readEntry(QString("Name_%1").arg(i), - i18n("Desktop %1", i)); + QString s = group.readEntry( QString( "Name_%1" ).arg( i ), i18n( "Desktop %1", i )); rootInfo->setDesktopName( i, s.toUtf8().data() ); desktop_focus_chain[i-1] = i; } @@ -1134,29 +1133,29 @@ void Workspace::saveDesktopSettings() if (screen_number == 0) groupname = "Desktops"; else - groupname.sprintf("Desktops-screen-%d", screen_number); - KConfigGroup group(c,groupname); + groupname.sprintf( "Desktops-screen-%d", screen_number ); + KConfigGroup group( c, groupname ); - group.writeEntry("Number", number_of_desktops ); - for(int i = 1; i <= number_of_desktops; i++) + group.writeEntry( "Number", number_of_desktops ); + for( int i = 1; i <= number_of_desktops; i++ ) { QString s = desktopName( i ); - QString defaultvalue = i18n("Desktop %1", i); - if ( s.isEmpty() ) + QString defaultvalue = i18n( "Desktop %1", i ); + if( s.isEmpty() ) { s = defaultvalue; rootInfo->setDesktopName( i, s.toUtf8().data() ); } - if (s != defaultvalue) + if( s != defaultvalue ) { - group.writeEntry( QString("Name_%1").arg(i), s ); + group.writeEntry( QString( "Name_%1" ).arg( i ), s ); } else { - QString currentvalue = group.readEntry(QString("Name_%1").arg(i), QString()); - if (currentvalue != defaultvalue) - group.writeEntry( QString("Name_%1").arg(i), "" ); + QString currentvalue = group.readEntry( QString( "Name_%1" ).arg( i ), QString() ); + if( currentvalue != defaultvalue ) + group.writeEntry( QString( "Name_%1" ).arg( i ), "" ); } } @@ -1164,42 +1163,42 @@ void Workspace::saveDesktopSettings() group.sync(); } -QStringList Workspace::configModules(bool controlCenter) +QStringList Workspace::configModules( bool controlCenter ) { QStringList args; args << "kwindecoration"; - if (controlCenter) + if( controlCenter ) args << "kwinoptions"; - else if (KAuthorized::authorizeControlModule("kde-kwinoptions.desktop")) - args << "kwinactions" << "kwinfocus" << "kwinmoving" << "kwinadvanced" << "kwinrules" << "kwincompositing"; + else if( KAuthorized::authorizeControlModule( "kde-kwinoptions.desktop" )) + args << "kwinactions" << "kwinfocus" << "kwinmoving" << "kwinadvanced" + << "kwinrules" << "kwincompositing"; return args; } void Workspace::configureWM() { - QStringList args; - args << "--icon" << "preferences-system-windows" - << configModules(false) ; - KToolInvocation::kdeinitExec( "kcmshell4", args ); + QStringList args; + args << "--icon" << "preferences-system-windows" << configModules( false ); + KToolInvocation::kdeinitExec( "kcmshell4", args ); } -/*! - avoids managing a window with title \a title +/** + * Avoids managing a window with title \a title */ -void Workspace::doNotManage( const QString &title ) +void Workspace::doNotManage( const QString& title ) { doNotManageList.append( title ); } -/*! - Hack for java applets +/** + * Hack for java applets */ bool Workspace::isNotManaged( const QString& title ) { - for ( QStringList::Iterator it = doNotManageList.begin(); it != doNotManageList.end(); ++it ) + for( QStringList::Iterator it = doNotManageList.begin(); it != doNotManageList.end(); ++it ) { QRegExp r( (*it) ); - if (r.indexIn(title) != -1) + if( r.indexIn(title) != -1 ) { doNotManageList.erase( it ); return true; @@ -1208,8 +1207,8 @@ bool Workspace::isNotManaged( const QString& title ) return false; } -/*! - Refreshes all the client windows +/** + * Refreshes all the client windows */ void Workspace::refresh() { @@ -1220,13 +1219,13 @@ void Workspace::refresh() QApplication::flush(); } -/*! - During virt. desktop switching, desktop areas covered by windows that are - going to be hidden are first obscured by new windows with no background - ( i.e. transparent ) placed right below the windows. These invisible windows - are removed after the switch is complete. - Reduces desktop ( wallpaper ) repaints during desktop switching -*/ +/** + * During virt. desktop switching, desktop areas covered by windows that are + * going to be hidden are first obscured by new windows with no background + * ( i.e. transparent ) placed right below the windows. These invisible windows + * are removed after the switch is complete. + * Reduces desktop ( wallpaper ) repaints during desktop switching + */ class ObscuringWindows { public: @@ -1243,8 +1242,8 @@ unsigned int ObscuringWindows::max_cache_size = 0; void ObscuringWindows::create( Client* c ) { - if( compositing()) // not needed with compositing - return; + if( compositing() ) + return; // Not needed with compositing if( cached == 0 ) cached = new QList; Window obs_win; @@ -1252,7 +1251,7 @@ void ObscuringWindows::create( Client* c ) int mask = CWSibling | CWStackMode; if( cached->count() > 0 ) { - cached->removeAll( obs_win = cached->first()); + cached->removeAll( obs_win = cached->first() ); chngs.x = c->x(); chngs.y = c->y(); chngs.width = c->width(); @@ -1277,109 +1276,103 @@ void ObscuringWindows::create( Client* c ) ObscuringWindows::~ObscuringWindows() { - max_cache_size = qMax( ( int )max_cache_size, obscuring_windows.count() + 4 ) - 1; + max_cache_size = qMax( int( max_cache_size ), obscuring_windows.count() + 4 ) - 1; for( QList::ConstIterator it = obscuring_windows.constBegin(); - it != obscuring_windows.constEnd(); - ++it ) + it != obscuring_windows.constEnd(); + ++it ) { XUnmapWindow( display(), *it ); - if( cached->count() < ( int )max_cache_size ) + if( cached->count() < int( max_cache_size )) cached->prepend( *it ); else XDestroyWindow( display(), *it ); } } - -/*! - Sets the current desktop to \a new_desktop - - Shows/Hides windows according to the stacking order and finally - propages the new desktop to the world +/** + * Sets the current desktop to \a new_desktop + * + * Shows/Hides windows according to the stacking order and finally + * propages the new desktop to the world */ bool Workspace::setCurrentDesktop( int new_desktop ) { - if (new_desktop < 1 || new_desktop > number_of_desktops ) + if( new_desktop < 1 || new_desktop > number_of_desktops ) return false; closeActivePopup(); ++block_focus; -// TODO Q_ASSERT( block_stacking_updates == 0 ); // make sure stacking_order is up to date + // TODO: Q_ASSERT( block_stacking_updates == 0 ); // Make sure stacking_order is up to date StackingUpdatesBlocker blocker( this ); int old_desktop = current_desktop; - if (new_desktop != current_desktop) + if (new_desktop != current_desktop ) { ++block_showing_desktop; - /* - optimized Desktop switching: unmapping done from back to front - mapping done from front to back => less exposure events - */ + // Optimized Desktop switching: unmapping done from back to front + // mapping done from front to back => less exposure events Notify::raise((Notify::Event) (Notify::DesktopChange+new_desktop)); ObscuringWindows obs_wins; - current_desktop = new_desktop; // change the desktop (so that Client::updateVisibility() works) + current_desktop = new_desktop; // Change the desktop (so that Client::updateVisibility() works) - for ( ClientList::ConstIterator it = stacking_order.constBegin(); it != stacking_order.constEnd(); ++it) - if ( !(*it)->isOnDesktop( new_desktop ) && (*it) != movingClient ) + for( ClientList::ConstIterator it = stacking_order.constBegin(); + it != stacking_order.constEnd(); + ++it ) + if( !(*it)->isOnDesktop( new_desktop ) && (*it) != movingClient ) { if( (*it)->isShown( true ) && (*it)->isOnDesktop( old_desktop )) obs_wins.create( *it ); (*it)->updateVisibility(); } - rootInfo->setCurrentDesktop( current_desktop ); // now propagate the change, after hiding, before showing + // Now propagate the change, after hiding, before showing + rootInfo->setCurrentDesktop( current_desktop ); if( movingClient && !movingClient->isOnDesktop( new_desktop )) movingClient->setDesktop( new_desktop ); for( int i = stacking_order.size() - 1; i >= 0 ; --i ) - if ( stacking_order.at( i )->isOnDesktop( new_desktop ) ) + if( stacking_order.at( i )->isOnDesktop( new_desktop )) stacking_order.at( i )->updateVisibility(); --block_showing_desktop; - if( showingDesktop()) // do this only after desktop change to avoid flicker + if( showingDesktop() ) // Do this only after desktop change to avoid flicker resetShowingDesktop( false ); } - // restore the focus on this desktop + // Restore the focus on this desktop --block_focus; Client* c = 0; - if ( options->focusPolicyIsReasonable()) - { - // Search in focus chain - if ( movingClient != NULL && active_client == movingClient - && focus_chain[currentDesktop()].contains( active_client ) - && active_client->isShown( true ) && active_client->isOnCurrentDesktop()) - { - c = active_client; // the requestFocus below will fail, as the client is already active - } + if( options->focusPolicyIsReasonable() ) + { // Search in focus chain + if( movingClient != NULL && active_client == movingClient && + focus_chain[currentDesktop()].contains( active_client ) && + active_client->isShown( true ) && active_client->isOnCurrentDesktop()) + c = active_client; // The requestFocus below will fail, as the client is already active if( !c ) { - for( int i = focus_chain[ currentDesktop() ].size() - 1; - i >= 0; - --i ) + for( int i = focus_chain[currentDesktop()].size() - 1; i >= 0; --i ) { - if( focus_chain[ currentDesktop() ].at( i )->isShown( false ) - && focus_chain[ currentDesktop() ].at( i )->isOnCurrentDesktop()) + if( focus_chain[currentDesktop()].at( i )->isShown( false ) && + focus_chain[currentDesktop()].at( i )->isOnCurrentDesktop() ) { - c = focus_chain[ currentDesktop() ].at( i ); + c = focus_chain[currentDesktop()].at( i ); break; } } } } + // If "unreasonable focus policy" and active_client is on_all_desktops and + // under mouse (Hence == old_active_client), conserve focus. + // (Thanks to Volker Schatz ) + else if( active_client && active_client->isShown( true ) && active_client->isOnCurrentDesktop() ) + c = active_client; - //if "unreasonable focus policy" - // and active_client is on_all_desktops and under mouse (hence == old_active_client), - // conserve focus (thanks to Volker Schatz ) - else if( active_client && active_client->isShown( true ) && active_client->isOnCurrentDesktop()) - c = active_client; - - if( c == NULL && !desktops.isEmpty()) - c = findDesktop( true, currentDesktop()); + if( c == NULL && !desktops.isEmpty() ) + c = findDesktop( true, currentDesktop() ); if( c != active_client ) setActiveClient( NULL, Allowed ); @@ -1387,7 +1380,7 @@ bool Workspace::setCurrentDesktop( int new_desktop ) if ( c ) requestFocus( c ); else if( !desktops.isEmpty() ) - requestFocus( findDesktop( true, currentDesktop())); + requestFocus( findDesktop( true, currentDesktop() )); else focusToNull(); @@ -1396,40 +1389,44 @@ bool Workspace::setCurrentDesktop( int new_desktop ) // Update focus chain: // If input: chain = { 1, 2, 3, 4 } and currentDesktop() = 3, // Output: chain = { 3, 1, 2, 4 }. -// kDebug(1212) << QString("Switching to desktop #%1, at focus_chain index %2\n") -// .arg(currentDesktop()).arg(desktop_focus_chain.find( currentDesktop() )); + //kDebug(1212) << QString("Switching to desktop #%1, at focus_chain index %2\n") + // .arg(currentDesktop()).arg(desktop_focus_chain.find( currentDesktop() )); for( int i = desktop_focus_chain.indexOf( currentDesktop() ); i > 0; i-- ) desktop_focus_chain[i] = desktop_focus_chain[i-1]; desktop_focus_chain[0] = currentDesktop(); -// QString s = "desktop_focus_chain[] = { "; -// for( uint i = 0; i < desktop_focus_chain.size(); i++ ) -// s += QString::number(desktop_focus_chain[i]) + ", "; -// kDebug(1212) << s << "}\n"; + //QString s = "desktop_focus_chain[] = { "; + //for( uint i = 0; i < desktop_focus_chain.size(); i++ ) + // s += QString::number( desktop_focus_chain[i] ) + ", "; + //kDebug( 1212 ) << s << "}\n"; - if( old_desktop != 0 ) // not for the very first time - popupinfo->showInfo( desktopName(currentDesktop()) ); + if( old_desktop != 0 ) // Not for the very first time + popupinfo->showInfo( desktopName( currentDesktop() )); if( effects != NULL && old_desktop != 0 && old_desktop != new_desktop ) - static_cast(effects)->desktopChanged( old_desktop ); + static_cast( effects )->desktopChanged( old_desktop ); if( compositing()) addRepaintFull(); return true; } -// called only from DCOP +/** + * Called only from D-Bus + */ void Workspace::nextDesktop() { int desktop = currentDesktop() + 1; - setCurrentDesktop(desktop > numberOfDesktops() ? 1 : desktop); + setCurrentDesktop( desktop > numberOfDesktops() ? 1 : desktop ); } -// called only from DCOP +/** + * Called only from D-Bus + */ void Workspace::previousDesktop() { int desktop = currentDesktop() - 1; - setCurrentDesktop(desktop > 0 ? desktop : numberOfDesktops()); + setCurrentDesktop( desktop > 0 ? desktop : numberOfDesktops() ); } int Workspace::desktopToRight( int desktop, bool wrap ) const @@ -1437,31 +1434,31 @@ int Workspace::desktopToRight( int desktop, bool wrap ) const int x,y; Qt::Orientation orientation; calcDesktopLayout( &x, &y, &orientation ); - int dt = desktop-1; - if (orientation == Qt::Vertical) + int dt = desktop - 1; + if( orientation == Qt::Vertical ) { dt += y; - if ( dt >= numberOfDesktops() ) + if( dt >= numberOfDesktops() ) { - if ( wrap ) - dt -= numberOfDesktops(); + if( wrap ) + dt -= numberOfDesktops(); else - return desktop; + return desktop; } } else { - int d = (dt % x) + 1; - if ( d >= x ) + int d = ( dt % x ) + 1; + if( d >= x ) { - if ( wrap ) - d -= x; + if( wrap ) + d -= x; else - return desktop; + return desktop; } - dt = dt - (dt % x) + d; + dt = dt - ( dt % x ) + d; } - return dt+1; + return dt + 1; } int Workspace::desktopToLeft( int desktop, bool wrap ) const @@ -1469,31 +1466,31 @@ int Workspace::desktopToLeft( int desktop, bool wrap ) const int x,y; Qt::Orientation orientation; calcDesktopLayout( &x, &y, &orientation ); - int dt = desktop-1; - if (orientation == Qt::Vertical) + int dt = desktop - 1; + if( orientation == Qt::Vertical ) { dt -= y; - if ( dt < 0 ) + if( dt < 0 ) { - if ( wrap ) - dt += numberOfDesktops(); + if( wrap ) + dt += numberOfDesktops(); else - return desktop; + return desktop; } } else { - int d = (dt % x) - 1; - if ( d < 0 ) + int d = ( dt % x ) - 1; + if( d < 0 ) { - if ( wrap ) - d += x; + if( wrap ) + d += x; else - return desktop; + return desktop; } - dt = dt - (dt % x) + d; + dt = dt - ( dt % x ) + d; } - return dt+1; + return dt + 1; } int Workspace::desktopUp( int desktop, bool wrap ) const @@ -1501,31 +1498,31 @@ int Workspace::desktopUp( int desktop, bool wrap ) const int x,y; Qt::Orientation orientation; calcDesktopLayout( &x, &y, &orientation); - int dt = desktop-1; - if (orientation == Qt::Horizontal) + int dt = desktop - 1; + if( orientation == Qt::Horizontal ) { dt -= x; - if ( dt < 0 ) + if( dt < 0 ) { - if ( wrap ) - dt += numberOfDesktops(); + if( wrap ) + dt += numberOfDesktops(); else - return desktop; + return desktop; } } else { - int d = (dt % y) - 1; - if ( d < 0 ) + int d = ( dt % y ) - 1; + if( d < 0 ) { - if ( wrap ) - d += y; + if( wrap ) + d += y; else - return desktop; + return desktop; } - dt = dt - (dt % y) + d; + dt = dt - ( dt % y ) + d; } - return dt+1; + return dt + 1; } int Workspace::desktopDown( int desktop, bool wrap ) const @@ -1533,75 +1530,72 @@ int Workspace::desktopDown( int desktop, bool wrap ) const int x,y; Qt::Orientation orientation; calcDesktopLayout( &x, &y, &orientation); - int dt = desktop-1; - if (orientation == Qt::Horizontal) + int dt = desktop - 1; + if( orientation == Qt::Horizontal ) { dt += x; - if ( dt >= numberOfDesktops() ) + if( dt >= numberOfDesktops() ) { - if ( wrap ) - dt -= numberOfDesktops(); + if( wrap ) + dt -= numberOfDesktops(); else - return desktop; + return desktop; } } else { - int d = (dt % y) + 1; - if ( d >= y ) + int d = ( dt % y ) + 1; + if( d >= y ) { - if ( wrap ) - d -= y; + if( wrap ) + d -= y; else - return desktop; + return desktop; } - dt = dt - (dt % y) + d; + dt = dt - ( dt % y ) + d; } - return dt+1; + return dt + 1; } - -/*! - Sets the number of virtual desktops to \a n +/** + * Sets the number of virtual desktops to \a n */ void Workspace::setNumberOfDesktops( int n ) { - if ( n == number_of_desktops ) + if( n == number_of_desktops ) return; int old_number_of_desktops = number_of_desktops; number_of_desktops = n; - if( currentDesktop() > numberOfDesktops()) - setCurrentDesktop( numberOfDesktops()); + if( currentDesktop() > numberOfDesktops() ) + setCurrentDesktop( numberOfDesktops() ); - // if increasing the number, do the resizing now, - // otherwise after the moving of windows to still existing desktops + // If increasing the number, do the resizing now, otherwise + // after the moving of windows to still existing desktops if( old_number_of_desktops < number_of_desktops ) { rootInfo->setNumberOfDesktops( number_of_desktops ); - NETPoint* viewports = new NETPoint[ number_of_desktops ]; + NETPoint* viewports = new NETPoint[number_of_desktops]; rootInfo->setDesktopViewport( number_of_desktops, *viewports ); delete[] viewports; updateClientArea( true ); focus_chain.resize( number_of_desktops + 1 ); } - // if the number of desktops decreased, move all - // windows that would be hidden to the last visible desktop + // If the number of desktops decreased, move all windows + // that would be hidden to the last visible desktop if( old_number_of_desktops > number_of_desktops ) { for( ClientList::ConstIterator it = clients.constBegin(); - it != clients.constEnd(); - ++it) - { - if( !(*it)->isOnAllDesktops() && (*it)->desktop() > numberOfDesktops()) + it != clients.constEnd(); + ++it) + if( !(*it)->isOnAllDesktops() && (*it)->desktop() > numberOfDesktops() ) sendClientToDesktop( *it, numberOfDesktops(), true ); - } } if( old_number_of_desktops > number_of_desktops ) { rootInfo->setNumberOfDesktops( number_of_desktops ); - NETPoint* viewports = new NETPoint[ number_of_desktops ]; + NETPoint* viewports = new NETPoint[number_of_desktops]; rootInfo->setDesktopViewport( number_of_desktops, *viewports ); delete[] viewports; updateClientArea( true ); @@ -1612,41 +1606,39 @@ void Workspace::setNumberOfDesktops( int n ) // Resize and reset the desktop focus chain. desktop_focus_chain.resize( n ); - for( int i = 0; i < (int)desktop_focus_chain.size(); i++ ) + for( int i = 0; i < int( desktop_focus_chain.size() ); i++ ) desktop_focus_chain[i] = i+1; } -/*! - Sends client \a c to desktop \a desk. - - Takes care of transients as well. +/** + * Sends client \a c to desktop \a desk. + * + * Takes care of transients as well. */ void Workspace::sendClientToDesktop( Client* c, int desk, bool dont_activate ) { bool was_on_desktop = c->isOnDesktop( desk ) || c->isOnAllDesktops(); c->setDesktop( desk ); - if ( c->desktop() != desk ) // no change or desktop forced + if( c->desktop() != desk ) // No change or desktop forced return; desk = c->desktop(); // Client did range checking - if ( c->isOnDesktop( currentDesktop() ) ) + if( c->isOnDesktop( currentDesktop() )) { - if ( c->wantsTabFocus() && options->focusPolicyIsReasonable() - && !was_on_desktop // for stickyness changes - && !dont_activate ) + if( c->wantsTabFocus() && options->focusPolicyIsReasonable() && + !was_on_desktop && // for stickyness changes + !dont_activate ) requestFocus( c ); else restackClientUnderActive( c ); } else - { raiseClient( c ); - } - ClientList transients_stacking_order = ensureStackingOrder( c->transients()); + ClientList transients_stacking_order = ensureStackingOrder( c->transients() ); for( ClientList::ConstIterator it = transients_stacking_order.constBegin(); - it != transients_stacking_order.constEnd(); - ++it ) + it != transients_stacking_order.constEnd(); + ++it ) sendClientToDesktop( *it, desk, dont_activate ); updateClientArea(); } @@ -1671,8 +1663,10 @@ int Workspace::activeScreen() const return Kephal::ScreenUtils::screenId( cursorPos()); } -// check whether a client moved completely out of what's considered the active screen, -// if yes, set a new active screen +/** + * Check whether a client moved completely out of what's considered the active screen, + * if yes, set a new active screen. + */ void Workspace::checkActiveScreen( const Client* c ) { if( !options->xineramaEnabled ) @@ -1683,9 +1677,11 @@ void Workspace::checkActiveScreen( const Client* c ) active_screen = c->screen(); } -// called e.g. when a user clicks on a window, set active screen to be the screen -// where the click occurred -void Workspace::setActiveScreenMouse( const QPoint &mousepos ) +/** + * Called e.g. when a user clicks on a window, set active screen to be the screen + * where the click occurred + */ +void Workspace::setActiveScreenMouse( const QPoint& mousepos ) { if( !options->xineramaEnabled ) return; @@ -1699,7 +1695,7 @@ QRect Workspace::screenGeometry( int screen ) const return Kephal::ScreenUtils::screenGeometry( screen ); } -int Workspace::screenNumber( const QPoint &pos ) const +int Workspace::screenNumber( const QPoint& pos ) const { if( !options->xineramaEnabled ) return 0; @@ -1708,46 +1704,46 @@ int Workspace::screenNumber( const QPoint &pos ) const void Workspace::sendClientToScreen( Client* c, int screen ) { - if( c->screen() == screen ) // don't use isOnScreen(), that's true even when only partially + if( c->screen() == screen ) // Don't use isOnScreen(), that's true even when only partially return; GeometryUpdatesBlocker blocker( c ); QRect old_sarea = clientArea( MaximizeArea, c ); - QRect sarea = clientArea( MaximizeArea, screen, c->desktop()); + QRect sarea = clientArea( MaximizeArea, screen, c->desktop() ); c->setGeometry( sarea.x() - old_sarea.x() + c->x(), sarea.y() - old_sarea.y() + c->y(), - c->size().width(), c->size().height()); + c->size().width(), c->size().height() ); c->checkWorkspacePosition(); - ClientList transients_stacking_order = ensureStackingOrder( c->transients()); + ClientList transients_stacking_order = ensureStackingOrder( c->transients() ); for( ClientList::ConstIterator it = transients_stacking_order.constBegin(); - it != transients_stacking_order.constEnd(); - ++it ) + it != transients_stacking_order.constEnd(); + ++it ) sendClientToScreen( *it, screen ); - if( c->isActive()) + if( c->isActive() ) active_screen = screen; } void Workspace::updateDesktopLayout() { - // rootInfo->desktopLayoutCorner(); // I don't find this worth bothering, feel free to + //rootInfo->desktopLayoutCorner(); // I don't find this worth bothering, feel free to layoutOrientation = ( rootInfo->desktopLayoutOrientation() == NET::OrientationHorizontal ? Qt::Horizontal : Qt::Vertical ); layoutX = rootInfo->desktopLayoutColumnsRows().width(); layoutY = rootInfo->desktopLayoutColumnsRows().height(); - if( layoutX == 0 && layoutY == 0 ) // not given, set default layout + if( layoutX == 0 && layoutY == 0 ) // Not given, set default layout layoutY = 2; } -void Workspace::calcDesktopLayout(int* xp, int* yp, Qt::Orientation* orientation) const +void Workspace::calcDesktopLayout( int* xp, int* yp, Qt::Orientation* orientation ) const { int x = layoutX; // <= 0 means compute it from the other and total number of desktops int y = layoutY; - if((x <= 0) && (y > 0)) - x = (numberOfDesktops()+y-1) / y; - else if((y <=0) && (x > 0)) - y = (numberOfDesktops()+x-1) / x; + if(( x <= 0 ) && ( y > 0 )) + x = ( numberOfDesktops() + y - 1 ) / y; + else if(( y <= 0) && ( x > 0 )) + y = ( numberOfDesktops() + x - 1 ) / x; - if(x <=0) + if( x <= 0 ) x = 1; - if (y <= 0) + if( y <= 0 ) y = 1; *xp = x; *yp = y; @@ -1760,20 +1756,20 @@ void Workspace::killWindowId( Window window_to_kill ) return; Window window = window_to_kill; Client* client = NULL; - for(;;) + for( ;; ) { client = findClient( FrameIdMatchPredicate( window )); - if( client != NULL ) // found the client - break; + if( client != NULL ) + break; // Found the client Window parent, root; Window* children; unsigned int children_count; XQueryTree( display(), window, &root, &parent, &children, &children_count ); if( children != NULL ) XFree( children ); - if( window == root ) // we didn't find the client, probably an override-redirect window + if( window == root ) // We didn't find the client, probably an override-redirect window break; - window = parent; // go up + window = parent; // Go up } if( client != NULL ) client->killWindow(); @@ -1781,7 +1777,6 @@ void Workspace::killWindowId( Window window_to_kill ) XKillClient( display(), window_to_kill ); } - void Workspace::sendPingToWindow( Window window, Time timestamp ) { rootInfo->sendPing( window, timestamp ); @@ -1793,85 +1788,83 @@ void Workspace::sendTakeActivity( Client* c, Time timestamp, long flags ) pending_take_activity = c; } - -/*! - Takes a screenshot of the current window and puts it in the clipboard. -*/ +/** + * Takes a screenshot of the current window and puts it in the clipboard. + */ void Workspace::slotGrabWindow() { if ( active_client ) { QPixmap snapshot = QPixmap::grabWindow( active_client->frameId() ); - //No XShape - no work. - if( Extensions::shapeAvailable()) + // No XShape - no work. + if( Extensions::shapeAvailable() ) { - //As the first step, get the mask from XShape. + // As the first step, get the mask from XShape. int count, order; XRectangle* rects = XShapeGetRectangles( display(), active_client->frameId(), - ShapeBounding, &count, &order); - //The ShapeBounding region is the outermost shape of the window; - //ShapeBounding - ShapeClipping is defined to be the border. - //Since the border area is part of the window, we use bounding - // to limit our work region - if (rects) + ShapeBounding, &count, &order); + // The ShapeBounding region is the outermost shape of the window; + // ShapeBounding - ShapeClipping is defined to be the border. + // Since the border area is part of the window, we use bounding + // to limit our work region + if( rects ) { - //Create a QRegion from the rectangles describing the bounding mask. + // Create a QRegion from the rectangles describing the bounding mask. QRegion contents; - for (int pos = 0; pos < count; pos++) - contents += QRegion(rects[pos].x, rects[pos].y, - rects[pos].width, rects[pos].height); - XFree(rects); + for( int pos = 0; pos < count; pos++ ) + contents += QRegion( rects[pos].x, rects[pos].y, + rects[pos].width, rects[pos].height); + XFree( rects ); - //Create the bounding box. - QRegion bbox(0, 0, snapshot.width(), snapshot.height()); + // Create the bounding box. + QRegion bbox( 0, 0, snapshot.width(), snapshot.height() ); - //Get the masked away area. + // Get the masked away area. QRegion maskedAway = bbox - contents; QVector maskedAwayRects = maskedAway.rects(); - //Construct a bitmap mask from the rectangles - QBitmap mask( snapshot.width(), snapshot.height()); - QPainter p(&mask); - p.fillRect(0, 0, mask.width(), mask.height(), Qt::color1); - for (int pos = 0; pos < maskedAwayRects.count(); pos++) - p.fillRect(maskedAwayRects[pos], Qt::color0); + // Construct a bitmap mask from the rectangles + QBitmap mask( snapshot.width(), snapshot.height() ); + QPainter p( &mask ); + p.fillRect( 0, 0, mask.width(), mask.height(), Qt::color1 ); + for( int pos = 0; pos < maskedAwayRects.count(); pos++ ) + p.fillRect( maskedAwayRects[pos], Qt::color0 ); p.end(); - snapshot.setMask(mask); + snapshot.setMask( mask ); } } - QClipboard *cb = QApplication::clipboard(); + QClipboard* cb = QApplication::clipboard(); cb->setPixmap( snapshot ); } else slotGrabDesktop(); } -/*! - Takes a screenshot of the whole desktop and puts it in the clipboard. -*/ +/** + * Takes a screenshot of the whole desktop and puts it in the clipboard. + */ void Workspace::slotGrabDesktop() { QPixmap p = QPixmap::grabWindow( rootWindow() ); - QClipboard *cb = QApplication::clipboard(); + QClipboard* cb = QApplication::clipboard(); cb->setPixmap( p ); } - -/*! - Invokes keyboard mouse emulation +/** + * Invokes keyboard mouse emulation */ void Workspace::slotMouseEmulation() { - if ( mouse_emulation ) + if( mouse_emulation ) { ungrabXKeyboard(); mouse_emulation = false; return; } - if( grabXKeyboard()) + if( grabXKeyboard() ) { mouse_emulation = true; mouse_emulation_state = 0; @@ -1879,11 +1872,11 @@ void Workspace::slotMouseEmulation() } } -/*! - Returns the child window under the mouse and activates the - respective client if necessary. - - Auxiliary function for the mouse emulation system. +/** + * Returns the child window under the mouse and activates the + * respective client if necessary. + * + * Auxiliary function for the mouse emulation system. */ WId Workspace::getMouseEmulationWindow() { @@ -1896,32 +1889,32 @@ WId Workspace::getMouseEmulationWindow() do { w = child; - if (!c) + if( !c ) c = findClient( FrameIdMatchPredicate( w )); - XQueryPointer( display(), w, &root, &child, - &root_x, &root_y, &lx, &ly, &state ); - } while ( child != None && child != w ); + XQueryPointer( display(), w, &root, &child, &root_x, &root_y, &lx, &ly, &state ); + } while ( child != None && child != w ); - if ( c && !c->isActive() ) + if( c && !c->isActive() ) activateClient( c ); - return (WId) w; + return WId( w ); } -/*! - Sends a faked mouse event to the specified window. Returns the new button state. +/** + * Sends a faked mouse event to the specified window. Returns the new button state. */ -unsigned int Workspace::sendFakedMouseEvent( const QPoint &pos, WId w, MouseEmulation type, int button, unsigned int state ) +unsigned int Workspace::sendFakedMouseEvent( const QPoint& pos, WId w, MouseEmulation type, + int button, unsigned int state ) { if ( !w ) return state; QWidget* widget = QWidget::find( w ); - if ( (!widget || qobject_cast(widget)) && !findClient( WindowMatchPredicate( w )) ) + if(( !widget || qobject_cast( widget )) && !findClient( WindowMatchPredicate( w ))) { int x, y; Window xw; XTranslateCoordinates( display(), rootWindow(), w, pos.x(), pos.y(), &x, &y, &xw ); - if ( type == EmuMove ) - { // motion notify events + if( type == EmuMove ) + { // Motion notify events XEvent e; e.type = MotionNotify; e.xmotion.window = w; @@ -1952,9 +1945,9 @@ unsigned int Workspace::sendFakedMouseEvent( const QPoint &pos, WId w, MouseEmul e.xbutton.button = button; XSendEvent( display(), w, true, ButtonPressMask, &e ); - if ( type == EmuPress ) + if( type == EmuPress ) { - switch ( button ) + switch( button ) { case 2: state |= Button2Mask; @@ -1969,7 +1962,7 @@ unsigned int Workspace::sendFakedMouseEvent( const QPoint &pos, WId w, MouseEmul } else { - switch ( button ) + switch( button ) { case 2: state &= ~Button2Mask; @@ -1984,24 +1977,25 @@ unsigned int Workspace::sendFakedMouseEvent( const QPoint &pos, WId w, MouseEmul } } } + return state; } -/*! - Handles keypress event during mouse emulation +/** + * Handles keypress event during mouse emulation */ bool Workspace::keyPressMouseEmulation( XKeyEvent& ev ) { - int kc = XKeycodeToKeysym(display(), ev.keycode, 0); - int km = ev.state & (ControlMask | Mod1Mask | ShiftMask); + int kc = XKeycodeToKeysym( display(), ev.keycode, 0 ); + int km = ev.state & ( ControlMask | Mod1Mask | ShiftMask ); bool is_control = km & ControlMask; bool is_alt = km & Mod1Mask; bool is_shift = km & ShiftMask; - int delta = is_control?1:is_alt?32:8; + int delta = is_control ? 1 : ( is_alt ? 32 : 8 ); QPoint pos = cursorPos(); - switch ( kc ) + switch( kc ) { case XK_Left: case XK_KP_Left: @@ -2020,52 +2014,62 @@ bool Workspace::keyPressMouseEmulation( XKeyEvent& ev ) pos.ry() += delta; break; case XK_F1: - if ( !mouse_emulation_state ) + if( !mouse_emulation_state ) mouse_emulation_window = getMouseEmulationWindow(); - if ( (mouse_emulation_state & Button1Mask) == 0 ) - mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuPress, Button1, mouse_emulation_state ); - if ( !is_shift ) - mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button1, mouse_emulation_state ); + if(( mouse_emulation_state & Button1Mask ) == 0 ) + mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, + EmuPress, Button1, mouse_emulation_state ); + if( !is_shift ) + mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, + EmuRelease, Button1, mouse_emulation_state ); break; case XK_F2: - if ( !mouse_emulation_state ) + if( !mouse_emulation_state ) mouse_emulation_window = getMouseEmulationWindow(); - if ( (mouse_emulation_state & Button2Mask) == 0 ) - mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuPress, Button2, mouse_emulation_state ); - if ( !is_shift ) - mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button2, mouse_emulation_state ); + if(( mouse_emulation_state & Button2Mask ) == 0 ) + mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, + EmuPress, Button2, mouse_emulation_state ); + if( !is_shift ) + mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, + EmuRelease, Button2, mouse_emulation_state ); break; case XK_F3: - if ( !mouse_emulation_state ) + if( !mouse_emulation_state ) mouse_emulation_window = getMouseEmulationWindow(); - if ( (mouse_emulation_state & Button3Mask) == 0 ) - mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuPress, Button3, mouse_emulation_state ); - if ( !is_shift ) - mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button3, mouse_emulation_state ); + if(( mouse_emulation_state & Button3Mask ) == 0 ) + mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, + EmuPress, Button3, mouse_emulation_state ); + if( !is_shift ) + mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, + EmuRelease, Button3, mouse_emulation_state ); break; case XK_Return: case XK_space: case XK_KP_Enter: case XK_KP_Space: { - if ( !mouse_emulation_state ) - { - // nothing was pressed, fake a LMB click + if( !mouse_emulation_state ) + { // Nothing was pressed, fake a LMB click mouse_emulation_window = getMouseEmulationWindow(); - mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuPress, Button1, mouse_emulation_state ); - mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button1, mouse_emulation_state ); + mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, + EmuPress, Button1, mouse_emulation_state ); + mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, + EmuRelease, Button1, mouse_emulation_state ); } else - { // release all - if ( mouse_emulation_state & Button1Mask ) - mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button1, mouse_emulation_state ); - if ( mouse_emulation_state & Button2Mask ) - mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button2, mouse_emulation_state ); - if ( mouse_emulation_state & Button3Mask ) - mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button3, mouse_emulation_state ); + { // Release all + if( mouse_emulation_state & Button1Mask ) + mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, + EmuRelease, Button1, mouse_emulation_state ); + if( mouse_emulation_state & Button2Mask ) + mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, + EmuRelease, Button2, mouse_emulation_state ); + if( mouse_emulation_state & Button3Mask ) + mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, + EmuRelease, Button3, mouse_emulation_state ); } } - // fall through + // Fall through case XK_Escape: ungrabXKeyboard(); mouse_emulation = false; @@ -2075,13 +2079,16 @@ bool Workspace::keyPressMouseEmulation( XKeyEvent& ev ) } QCursor::setPos( pos ); - if ( mouse_emulation_state ) - mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuMove, 0, mouse_emulation_state ); - return true; + if( mouse_emulation_state ) + mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, + EmuMove, 0, mouse_emulation_state ); + return true; } -//Delayed focus functions +/** + * Delayed focus functions + */ void Workspace::delayFocus() { requestFocus( delayfocus_client ); @@ -2104,12 +2111,14 @@ void Workspace::cancelDelayFocus() delayFocusTimer = 0; } +//----------------------------------------------------------------------------- // Electric Borders -//========================================================================// -// Electric Border Window management. Electric borders allow a user -// to change the virtual desktop or activate another features -// by moving the mouse pointer to the borders or corners. -// Technically this is done with input only windows. +//----------------------------------------------------------------------------- +// Electric Border Window management. Electric borders allow a user to change +// the virtual desktop or activate another features by moving the mouse pointer +// to the borders or corners. Technically this is done with input only windows. +//----------------------------------------------------------------------------- + void Workspace::updateElectricBorders() { electric_time_first = xTime(); @@ -2121,104 +2130,97 @@ void Workspace::updateElectricBorders() electricLeft = r.left(); electricRight = r.right(); - for( int pos = 0; - pos < ELECTRIC_COUNT; - ++pos ) + for( int pos = 0; pos < ELECTRIC_COUNT; ++pos ) { - if( electric_reserved[ pos ] == 0 ) + if( electric_reserved[pos] == 0 ) { - if( electric_windows[ pos ] != None ) - XDestroyWindow( display(), electric_windows[ pos ] ); - electric_windows[ pos ] = None; + if( electric_windows[pos] != None ) + XDestroyWindow( display(), electric_windows[pos] ); + electric_windows[pos] = None; continue; } - if( electric_windows[ pos ] != None ) + if( electric_windows[pos] != None ) continue; XSetWindowAttributes attributes; attributes.override_redirect = True; attributes.event_mask = EnterWindowMask | LeaveWindowMask; unsigned long valuemask = CWOverrideRedirect | CWEventMask; - int xywh[ ELECTRIC_COUNT ][ 4 ] = + int xywh[ELECTRIC_COUNT][4] = { - { r.left() + 1, r.top(), r.width() - 2, 1 }, // top - { r.right(), r.top(), 1, 1 }, // topright - { r.right(), r.top() + 1, 1, r.height() - 2 }, // etc. + { r.left() + 1, r.top(), r.width() - 2, 1 }, // Top + { r.right(), r.top(), 1, 1 }, // Top-right + { r.right(), r.top() + 1, 1, r.height() - 2 }, // Etc. { r.right(), r.bottom(), 1, 1 }, { r.left() + 1, r.bottom(), r.width() - 2, 1 }, { r.left(), r.bottom(), 1, 1 }, { r.left(), r.top() + 1, 1, r.height() - 2 }, { r.left(), r.top(), 1, 1 } }; - electric_windows[ pos ] = XCreateWindow( display(), rootWindow(), - xywh[ pos ][ 0 ], xywh[ pos ][ 1 ], xywh[ pos ][ 2 ], xywh[ pos ][ 3 ], + electric_windows[pos] = XCreateWindow( display(), rootWindow(), + xywh[pos][0], xywh[pos][1], xywh[pos][2], xywh[pos][3], 0, CopyFromParent, InputOnly, CopyFromParent, valuemask, &attributes ); - XMapWindow( display(), electric_windows[ pos ]); + XMapWindow( display(), electric_windows[pos] ); + // Set XdndAware on the windows, so that DND enter events are received (#86998) Atom version = 4; // XDND version - XChangeProperty( display(), electric_windows[ pos ], atoms->xdnd_aware, XA_ATOM, - 32, PropModeReplace, ( unsigned char* )&version, 1 ); + XChangeProperty( display(), electric_windows[pos], atoms->xdnd_aware, XA_ATOM, + 32, PropModeReplace, (unsigned char*)( &version ), 1 ); } } void Workspace::destroyElectricBorders() { - for( int pos = 0; - pos < ELECTRIC_COUNT; - ++pos ) + for( int pos = 0; pos < ELECTRIC_COUNT; ++pos ) { - if( electric_windows[ pos ] != None ) - XDestroyWindow( display(), electric_windows[ pos ] ); - electric_windows[ pos ] = None; + if( electric_windows[pos] != None ) + XDestroyWindow( display(), electric_windows[pos] ); + electric_windows[pos] = None; } } void Workspace::reserveElectricBorderSwitching( bool reserve ) { - for( int pos = 0; - pos < ELECTRIC_COUNT; - ++pos ) + for( int pos = 0; pos < ELECTRIC_COUNT; ++pos ) if( reserve ) - reserveElectricBorder( static_cast< ElectricBorder >( pos )); + reserveElectricBorder( static_cast( pos )); else - unreserveElectricBorder( static_cast< ElectricBorder >( pos )); + unreserveElectricBorder( static_cast( pos )); } void Workspace::reserveElectricBorder( ElectricBorder border ) { if( border == ElectricNone ) return; - if( electric_reserved[ border ]++ == 0 ) - QTimer::singleShot( 0, this, SLOT( updateElectricBorders())); + if( electric_reserved[border]++ == 0 ) + QTimer::singleShot( 0, this, SLOT( updateElectricBorders() )); } void Workspace::unreserveElectricBorder( ElectricBorder border ) { if( border == ElectricNone ) return; - assert( electric_reserved[ border ] > 0 ); - if( --electric_reserved[ border ] == 0 ) - QTimer::singleShot( 0, this, SLOT( updateElectricBorders())); + assert( electric_reserved[border] > 0 ); + if( --electric_reserved[border] == 0 ) + QTimer::singleShot( 0, this, SLOT( updateElectricBorders() )); } -void Workspace::checkElectricBorder(const QPoint &pos, Time now) +void Workspace::checkElectricBorder(const QPoint& pos, Time now) { - if ((pos.x() != electricLeft) && - (pos.x() != electricRight) && - (pos.y() != electricTop) && - (pos.y() != electricBottom)) + if(( pos.x() != electricLeft ) && + ( pos.x() != electricRight ) && + ( pos.y() != electricTop ) && + ( pos.y() != electricBottom )) return; bool have_borders = false; - for( int i = 0; - i < ELECTRIC_COUNT; - ++i ) - if( electric_windows[ i ] != None ) + for( int i = 0; i < ELECTRIC_COUNT; ++i ) + if( electric_windows[i] != None ) have_borders = true; if( !have_borders ) return; - Time treshold_set = options->electricBorderDelay(); // set timeout - Time treshold_reset = 250; // reset timeout + Time treshold_set = options->electricBorderDelay(); // Set timeout + Time treshold_reset = 250; // Reset timeout int distance_reset = 30; // Mouse should not move more than this many pixels ElectricBorder border; @@ -2241,20 +2243,20 @@ void Workspace::checkElectricBorder(const QPoint &pos, Time now) else abort(); - if( electric_windows[ border ] == None ) + if( electric_windows[border] == None ) return; - if ((electric_current_border == border) && - (timestampDiff(electric_time_last, now) < treshold_reset) && - ((pos-electric_push_point).manhattanLength() < distance_reset)) + if(( electric_current_border == border ) && + ( timestampDiff( electric_time_last, now ) < treshold_reset ) && + (( pos-electric_push_point ).manhattanLength() < distance_reset )) { electric_time_last = now; - if (timestampDiff(electric_time_first, now) > treshold_set) + if( timestampDiff( electric_time_first, now ) > treshold_set ) { electric_current_border = ElectricNone; - if( effects && static_cast(effects)->borderActivated( border )) - {} // handled by effects + if( effects && static_cast( effects )->borderActivated( border )) + {} // Handled by effects else electricBorderSwitchDesktop( border, pos ); return; @@ -2268,11 +2270,11 @@ void Workspace::checkElectricBorder(const QPoint &pos, Time now) electric_push_point = pos; } - // reset the pointer to find out whether the user is really pushing + // Reset the pointer to find out whether the user is really pushing // (the direction back from which it came, starting from top clockwise) - const int xdiff[ ELECTRIC_COUNT ] = { 0, -1, -1, -1, 0, 1, 1, 1 }; - const int ydiff[ ELECTRIC_COUNT ] = { 1, 1, 0, -1, -1, -1, 0, 1 }; - QCursor::setPos( pos.x() + xdiff[ border ], pos.y() + ydiff[ border ] ); + const int xdiff[ELECTRIC_COUNT] = { 0, -1, -1, -1, 0, 1, 1, 1 }; + const int ydiff[ELECTRIC_COUNT] = { 1, 1, 0, -1, -1, -1, 0, 1 }; + QCursor::setPos( pos.x() + xdiff[border], pos.y() + ydiff[border] ); } void Workspace::electricBorderSwitchDesktop( ElectricBorder border, const QPoint& _pos ) @@ -2306,17 +2308,17 @@ void Workspace::electricBorderSwitchDesktop( ElectricBorder border, const QPoint QCursor::setPos( pos ); } -// this function is called when the user entered an electric border -// with the mouse. It may switch to another virtual desktop -bool Workspace::electricBorderEvent(XEvent *e) +/** + * Called when the user entered an electric border with the mouse. + * It may switch to another virtual desktop. + */ +bool Workspace::electricBorderEvent( XEvent* e ) { if( e->type == EnterNotify ) { - for( int i = 0; - i < ELECTRIC_COUNT; - ++i ) - if( electric_windows[ i ] != None && e->xcrossing.window == electric_windows[ i ] ) - { // the user entered an electric border + for( int i = 0; i < ELECTRIC_COUNT; ++i ) + if( electric_windows[i] != None && e->xcrossing.window == electric_windows[i] ) + { // The user entered an electric border checkElectricBorder( QPoint( e->xcrossing.x_root, e->xcrossing.y_root ), e->xcrossing.time ); return true; } @@ -2325,13 +2327,12 @@ bool Workspace::electricBorderEvent(XEvent *e) { if( e->xclient.message_type == atoms->xdnd_position ) { - for( int i = 0; - i < ELECTRIC_COUNT; - ++i ) - if( electric_windows[ i ] != None && e->xclient.window == electric_windows[ i ] ) + for( int i = 0; i < ELECTRIC_COUNT; ++i ) + if( electric_windows[i] != None && e->xclient.window == electric_windows[i] ) { updateXTime(); - checkElectricBorder( QPoint( e->xclient.data.l[2]>>16, e->xclient.data.l[2]&0xffff), xTime() ); + checkElectricBorder( QPoint( + e->xclient.data.l[2]>>16, e->xclient.data.l[2]&0xffff), xTime() ); return true; } } @@ -2339,15 +2340,18 @@ bool Workspace::electricBorderEvent(XEvent *e) return false; } +//----------------------------------------------------------------------------- +// Top menu + void Workspace::addTopMenu( Client* c ) { - assert( c->isTopMenu()); + assert( c->isTopMenu() ); assert( !topmenus.contains( c )); topmenus.append( c ); - if( managingTopMenus()) + if( managingTopMenus() ) { int minsize = c->minSize().height(); - if( minsize > topMenuHeight()) + if( minsize > topMenuHeight() ) { topmenu_height = minsize; updateTopMenuGeometry(); @@ -2355,37 +2359,40 @@ void Workspace::addTopMenu( Client* c ) updateTopMenuGeometry( c ); updateCurrentTopMenu(); } -// kDebug(1212) << "NEW TOPMENU:" << c; + + //kDebug( 1212 ) << "NEW TOPMENU:" << c; } void Workspace::removeTopMenu( Client* c ) { -// if( c->isTopMenu()) -// kDebug(1212) << "REMOVE TOPMENU:" << c; - assert( c->isTopMenu()); + //if( c->isTopMenu() ) + // kDebug( 1212 ) << "REMOVE TOPMENU:" << c; + + assert( c->isTopMenu() ); assert( topmenus.contains( c )); topmenus.removeAll( c ); updateCurrentTopMenu(); - // TODO reduce topMenuHeight() if possible? + // TODO: Reduce topMenuHeight() if possible? } void Workspace::lostTopMenuSelection() { -// kDebug(1212) << "lost TopMenu selection"; - // make sure this signal is always set when not owning the selection - disconnect( topmenu_watcher, SIGNAL( lostOwner()), this, SLOT( lostTopMenuOwner())); - connect( topmenu_watcher, SIGNAL( lostOwner()), this, SLOT( lostTopMenuOwner())); + //kDebug( 1212 ) << "lost TopMenu selection"; + + // Make sure this signal is always set when not owning the selection + disconnect( topmenu_watcher, SIGNAL( lostOwner() ), this, SLOT( lostTopMenuOwner() )); + connect( topmenu_watcher, SIGNAL( lostOwner() ), this, SLOT( lostTopMenuOwner() )); if( !managing_topmenus ) return; - connect( topmenu_watcher, SIGNAL( lostOwner()), this, SLOT( lostTopMenuOwner())); - disconnect( topmenu_selection, SIGNAL( lostOwnership()), this, SLOT( lostTopMenuSelection())); + connect( topmenu_watcher, SIGNAL( lostOwner() ), this, SLOT( lostTopMenuOwner() )); + disconnect( topmenu_selection, SIGNAL( lostOwnership() ), this, SLOT( lostTopMenuSelection() )); managing_topmenus = false; delete topmenu_space; topmenu_space = NULL; updateClientArea(); for( ClientList::ConstIterator it = topmenus.constBegin(); - it != topmenus.constEnd(); - ++it ) + it != topmenus.constEnd(); + ++it ) (*it)->checkWorkspacePosition(); } @@ -2393,13 +2400,13 @@ void Workspace::lostTopMenuOwner() { if( !options->topMenuEnabled()) return; -// kDebug(1212) << "TopMenu selection lost owner"; + //kDebug( 1212 ) << "TopMenu selection lost owner"; if( !topmenu_selection->claim( false )) { -// kDebug(1212) << "Failed to claim TopMenu selection"; + //kDebug( 1212 ) << "Failed to claim TopMenu selection"; return; } -// kDebug(1212) << "claimed TopMenu selection"; + //kDebug( 1212 ) << "Claimed TopMenu selection"; setupTopMenuHandling(); } @@ -2407,14 +2414,14 @@ void Workspace::setupTopMenuHandling() { if( managing_topmenus ) return; - connect( topmenu_selection, SIGNAL( lostOwnership()), this, SLOT( lostTopMenuSelection())); - disconnect( topmenu_watcher, SIGNAL( lostOwner()), this, SLOT( lostTopMenuOwner())); + connect( topmenu_selection, SIGNAL( lostOwnership() ), this, SLOT( lostTopMenuSelection() )); + disconnect( topmenu_watcher, SIGNAL( lostOwner() ), this, SLOT( lostTopMenuOwner() )); managing_topmenus = true; topmenu_space = new QWidget( NULL, Qt::X11BypassWindowManagerHint ); - Window stack[ 2 ]; - stack[ 0 ] = supportWindow->winId(); - stack[ 1 ] = topmenu_space->winId(); - XRestackWindows(display(), stack, 2); + Window stack[2]; + stack[0] = supportWindow->winId(); + stack[1] = topmenu_space->winId(); + XRestackWindows( display(), stack, 2 ); updateTopMenuGeometry(); topmenu_space->show(); updateClientArea(); @@ -2424,7 +2431,7 @@ void Workspace::setupTopMenuHandling() int Workspace::topMenuHeight() const { if( topmenu_height == 0 ) - { // simply create a dummy menubar and use its preffered height as the menu height + { // Simply create a dummy menubar and use its preffered height as the menu height KMenuBar tmpmenu; tmpmenu.addAction( "dummy" ); topmenu_height = tmpmenu.sizeHint().height(); @@ -2437,25 +2444,25 @@ KDecoration* Workspace::createDecoration( KDecorationBridge* bridge ) return mgr->createDecoration( bridge ); } -// returns a list of all colors (KDecorationDefines::ColorType) the current -// decoration supports -QList< int > Workspace::decorationSupportedColors() const +/** + * Returns a list of all colors (KDecorationDefines::ColorType) the current + * decoration supports + */ +QList Workspace::decorationSupportedColors() const { KDecorationFactory* factory = mgr->factory(); - QList< int > ret; + QList ret; for( Ability ab = ABILITYCOLOR_FIRST; - ab < ABILITYCOLOR_END; - ab = static_cast< Ability>( ab + 1 )) - { + ab < ABILITYCOLOR_END; + ab = static_cast( ab + 1 )) if( factory->supports( ab )) ret << ab; - } return ret; } QString Workspace::desktopName( int desk ) const { - return QString::fromUtf8( rootInfo->desktopName( desk ) ); + return QString::fromUtf8( rootInfo->desktopName( desk )); } bool Workspace::checkStartupNotification( Window w, KStartupInfoId& id, KStartupInfoData& data ) @@ -2463,13 +2470,13 @@ bool Workspace::checkStartupNotification( Window w, KStartupInfoId& id, KStartup return startup->checkStartup( w, id, data ) == KStartupInfo::Match; } -/*! - Puts the focus on a dummy window - Just using XSetInputFocus() with None would block keyboard input +/** + * Puts the focus on a dummy window + * Just using XSetInputFocus() with None would block keyboard input */ void Workspace::focusToNull() { - XSetInputFocus(display(), null_focus_window, RevertToPointerRoot, xTime() ); + XSetInputFocus( display(), null_focus_window, RevertToPointerRoot, xTime() ); } void Workspace::helperDialog( const QString& message, const Client* c ) @@ -2478,46 +2485,46 @@ void Workspace::helperDialog( const QString& message, const Client* c ) QString type; if( message == "noborderaltf3" ) { - KAction* action = qobject_cast(keys->action( "Window Operations Menu" )); + KAction* action = qobject_cast( keys->action( "Window Operations Menu" )); assert( action != NULL ); QString shortcut = QString( "%1 (%2)" ).arg( action->text() ) - .arg( action->globalShortcut().primary().toString(QKeySequence::NativeText)); - args << "--msgbox" << - i18n( "You have selected to show a window without its border.\n" - "Without the border, you will not be able to enable the border " - "again using the mouse: use the window operations menu instead, " - "activated using the %1 keyboard shortcut." , - shortcut ); + .arg( action->globalShortcut().primary().toString( QKeySequence::NativeText )); + args << "--msgbox" << i18n( + "You have selected to show a window without its border.\n" + "Without the border, you will not be able to enable the border " + "again using the mouse: use the window operations menu instead, " + "activated using the %1 keyboard shortcut.", + shortcut ); type = "altf3warning"; } else if( message == "fullscreenaltf3" ) { - KAction* action = qobject_cast(keys->action( "Window Operations Menu" )); + KAction* action = qobject_cast( keys->action( "Window Operations Menu" )); assert( action != NULL ); QString shortcut = QString( "%1 (%2)" ).arg( action->text() ) - .arg( action->globalShortcut().primary().toString(QKeySequence::NativeText)); - args << "--msgbox" << - i18n( "You have selected to show a window in fullscreen mode.\n" - "If the application itself does not have an option to turn the fullscreen " - "mode off you will not be able to disable it " - "again using the mouse: use the window operations menu instead, " - "activated using the %1 keyboard shortcut." , - shortcut ); + .arg( action->globalShortcut().primary().toString( QKeySequence::NativeText )); + args << "--msgbox" << i18n( + "You have selected to show a window in fullscreen mode.\n" + "If the application itself does not have an option to turn the fullscreen " + "mode off you will not be able to disable it " + "again using the mouse: use the window operations menu instead, " + "activated using the %1 keyboard shortcut.", + shortcut ); type = "altf3warning"; } else abort(); - if( !type.isEmpty()) + if( !type.isEmpty() ) { KConfig cfg( "kwin_dialogsrc" ); - KConfigGroup cg(&cfg, "Notification Messages" ); // this depends on KMessageBox - if( !cg.readEntry( type, true )) // has don't show again checked - return; // save launching kdialog - args <<"--dontagain" << "kwin_dialogsrc:" + type; + KConfigGroup cg(&cfg, "Notification Messages" ); // Depends on KMessageBox + if( !cg.readEntry( type, true )) + return; + args << "--dontagain" << "kwin_dialogsrc:" + type; } if( c != NULL ) - args <<"--embed" << QString::number( c->window()); - KProcess::startDetached("kdialog",args); + args << "--embed" << QString::number( c->window() ); + KProcess::startDetached( "kdialog",args ); } void Workspace::setShowingDesktop( bool showing ) @@ -2530,45 +2537,45 @@ void Workspace::setShowingDesktop( bool showing ) showing_desktop_clients.clear(); ++block_focus; ClientList cls = stackingOrder(); - // find them first, then minimize, otherwise transients may get minimized with the window + // Find them first, then minimize, otherwise transients may get minimized with the window // they're transient for for( ClientList::ConstIterator it = cls.constBegin(); - it != cls.constEnd(); - ++it ) - { - if( (*it)->isOnCurrentDesktop() && (*it)->isShown( true ) && !(*it)->isSpecialWindow()) - showing_desktop_clients.prepend( *it ); // topmost first to reduce flicker - } + it != cls.constEnd(); + ++it ) + if( (*it)->isOnCurrentDesktop() && (*it)->isShown( true ) && !(*it)->isSpecialWindow() ) + showing_desktop_clients.prepend( *it ); // Topmost first to reduce flicker for( ClientList::ConstIterator it = showing_desktop_clients.constBegin(); - it != showing_desktop_clients.constEnd(); - ++it ) + it != showing_desktop_clients.constEnd(); + ++it ) (*it)->minimize(); --block_focus; - if( Client* desk = findDesktop( true, currentDesktop())) + if( Client* desk = findDesktop( true, currentDesktop() )) requestFocus( desk ); } else { for( ClientList::ConstIterator it = showing_desktop_clients.constBegin(); - it != showing_desktop_clients.constEnd(); - ++it ) + it != showing_desktop_clients.constEnd(); + ++it ) (*it)->unminimize(); if( showing_desktop_clients.count() > 0 ) - requestFocus( showing_desktop_clients.first()); + requestFocus( showing_desktop_clients.first() ); showing_desktop_clients.clear(); } --block_showing_desktop; } -// Following Kicker's behavior: -// Changing a virtual desktop resets the state and shows the windows again. -// Unminimizing a window resets the state but keeps the windows hidden (except -// the one that was unminimized). -// A new window resets the state and shows the windows again, with the new window -// being active. Due to popular demand (#67406) by people who apparently -// don't see a difference between "show desktop" and "minimize all", this is not -// true if "showDesktopIsMinimizeAll" is set in kwinrc. In such case showing -// a new window resets the state but doesn't show windows. +/** + * Following Kicker's behavior: + * Changing a virtual desktop resets the state and shows the windows again. + * Unminimizing a window resets the state but keeps the windows hidden (except + * the one that was unminimized). + * A new window resets the state and shows the windows again, with the new window + * being active. Due to popular demand (#67406) by people who apparently + * don't see a difference between "show desktop" and "minimize all", this is not + * true if "showDesktopIsMinimizeAll" is set in kwinrc. In such case showing + * a new window resets the state but doesn't show windows. + */ void Workspace::resetShowingDesktop( bool keep_hidden ) { if( block_showing_desktop > 0 ) @@ -2579,21 +2586,23 @@ void Workspace::resetShowingDesktop( bool keep_hidden ) if( !keep_hidden ) { for( ClientList::ConstIterator it = showing_desktop_clients.constBegin(); - it != showing_desktop_clients.constEnd(); - ++it ) + it != showing_desktop_clients.constEnd(); + ++it ) (*it)->unminimize(); } showing_desktop_clients.clear(); --block_showing_desktop; } -// Activating/deactivating this feature works like this: -// When nothing is active, and the shortcut is pressed, global shortcuts are disabled -// (using global_shortcuts_disabled) -// When a window that has disabling forced is activated, global shortcuts are disabled. -// (using global_shortcuts_disabled_for_client) -// When a shortcut is pressed and global shortcuts are disabled (either by a shortcut -// or for a client), they are enabled again. +/** + * Activating/deactivating this feature works like this: + * When nothing is active, and the shortcut is pressed, global shortcuts are disabled + * (using global_shortcuts_disabled) + * When a window that has disabling forced is activated, global shortcuts are disabled. + * (using global_shortcuts_disabled_for_client) + * When a shortcut is pressed and global shortcuts are disabled (either by a shortcut + * or for a client), they are enabled again. + */ void Workspace::slotDisableGlobalShortcuts() { if( global_shortcuts_disabled || global_shortcuts_disabled_for_client ) @@ -2613,14 +2622,14 @@ void Workspace::disableGlobalShortcutsForClient( bool disable ) if( disable ) pending_dfc = true; KGlobalSettings::self()->emitChange( KGlobalSettings::BlockShortcuts, disable ); - // kwin will get the kipc message too + // KWin will get the kipc message too } } void Workspace::disableGlobalShortcuts( bool disable ) { KGlobalSettings::self()->emitChange( KGlobalSettings::BlockShortcuts, disable ); - // kwin will get the kipc message too + // KWin will get the kipc message too } void Workspace::slotBlockShortcuts( int data ) @@ -2635,10 +2644,10 @@ void Workspace::slotBlockShortcuts( int data ) global_shortcuts_disabled = data; global_shortcuts_disabled_for_client = false; } - // update also Alt+LMB actions etc. + // Update also Alt+LMB actions etc. for( ClientList::ConstIterator it = clients.constBegin(); - it != clients.constEnd(); - ++it ) + it != clients.constEnd(); + ++it ) (*it)->updateMouseGrab(); } @@ -2651,8 +2660,8 @@ static QTimer* last_cursor_timer; QPoint Workspace::cursorPos() const { - if( last_cursor_timestamp == CurrentTime - || last_cursor_timestamp != QX11Info::appTime()) + if( last_cursor_timestamp == CurrentTime || + last_cursor_timestamp != QX11Info::appTime() ) { last_cursor_timestamp = QX11Info::appTime(); Window root; @@ -2665,19 +2674,21 @@ QPoint Workspace::cursorPos() const last_buttons = state; if( last_cursor_timer == NULL ) { - Workspace* ws = const_cast< Workspace* >( this ); + Workspace* ws = const_cast( this ); last_cursor_timer = new QTimer( ws ); last_cursor_timer->setSingleShot( true ); - connect( last_cursor_timer, SIGNAL( timeout()), ws, SLOT( resetCursorPosTime())); + connect( last_cursor_timer, SIGNAL( timeout() ), ws, SLOT( resetCursorPosTime() )); } last_cursor_timer->start( 0 ); } return last_cursor_pos; } -// Because of QTimer's and the impossibility to get events for all mouse -// movements (at least I haven't figured out how) the position needs -// to be also refetched after each return to the event loop. +/** + * Because of QTimer's and the impossibility to get events for all mouse + * movements (at least I haven't figured out how) the position needs + * to be also refetched after each return to the event loop. + */ void Workspace::resetCursorPosTime() { last_cursor_timestamp = CurrentTime; @@ -2687,9 +2698,9 @@ void Workspace::checkCursorPos() { QPoint last = last_cursor_pos; int lastb = last_buttons; - cursorPos(); // update if needed + cursorPos(); // Update if needed if( last != last_cursor_pos || lastb != last_buttons ) - static_cast< EffectsHandlerImpl* >( effects )->mouseChanged( cursorPos(), last, + static_cast( effects )->mouseChanged( cursorPos(), last, x11ToQtMouseButtons( last_buttons ), x11ToQtMouseButtons( lastb ), x11ToQtKeyboardModifiers( last_buttons ), x11ToQtKeyboardModifiers( lastb )); } diff --git a/workspace.h b/workspace.h index 32a928ddff..1157689d80 100644 --- a/workspace.h +++ b/workspace.h @@ -39,6 +39,8 @@ along with this program. If not, see . #include +// TODO: Cleanup the order of things in this .h file + class QMenu; class KConfig; class KActionCollection; @@ -67,21 +69,21 @@ class Workspace : public QObject, public KDecorationDefines Workspace( bool restore = false ); virtual ~Workspace(); - static Workspace * self() { return _self; } + static Workspace* self() { return _self; } - bool workspaceEvent( XEvent * ); - bool workspaceEvent( QEvent * ); + bool workspaceEvent( XEvent* ); + bool workspaceEvent( QEvent* ); KDecoration* createDecoration( KDecorationBridge* bridge ); - bool hasClient( const Client * ); + bool hasClient( const Client* ); - template< typename T > Client* findClient( T predicate ) const; - 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 ) const; - template< typename T1, typename T2 > void forEachUnmanaged( T1 procedure, T2 predicate ); - template< typename T > void forEachUnmanaged( T procedure ); + template Client* findClient( T predicate ) const; + template void forEachClient( T1 procedure, T2 predicate ); + template void forEachClient( T procedure ); + template Unmanaged* findUnmanaged( T predicate ) const; + template void forEachUnmanaged( T1 procedure, T2 predicate ); + template void forEachUnmanaged( T procedure ); QRect clientArea( clientAreaOption, const QPoint& p, int desktop ) const; QRect clientArea( clientAreaOption, const Client* c ) const; @@ -92,7 +94,8 @@ class Workspace : public QObject, public KDecorationDefines */ void killWindowId( Window window); - void killWindow() { slotKillWindow(); } + void killWindow() + { slotKillWindow(); } bool initializing() const; @@ -101,32 +104,36 @@ class Workspace : public QObject, public KDecorationDefines * if no client has the focus) */ Client* activeClient() const; - // Client that was activated, but it's not yet really activeClient(), because - // we didn't process yet the matching FocusIn event. Used mostly in focus - // stealing prevention code. + /** + * Client that was activated, but it's not yet really activeClient(), because + * we didn't process yet the matching FocusIn event. Used mostly in focus + * stealing prevention code. + */ Client* mostRecentlyActivatedClient() const; void activateClient( Client*, bool force = false ); void requestFocus( Client* c, bool force = false ); - void takeActivity( Client* c, int flags, bool handled ); // flags are ActivityFlags - void handleTakeActivity( Client* c, Time timestamp, int flags ); // flags are ActivityFlags - bool allowClientActivation( const Client* c, Time time = -1U, bool focus_in = false, bool ignore_desktop = false ); + void takeActivity( Client* c, int flags, bool handled ); // Flags are ActivityFlags + void handleTakeActivity( Client* c, Time timestamp, int flags ); // Flags are ActivityFlags + bool allowClientActivation( const Client* c, Time time = -1U, bool focus_in = false, + bool ignore_desktop = false ); void restoreFocus(); void gotFocusIn( const Client* ); void setShouldGetFocus( Client* ); bool fakeRequestedActivity( Client* c ); void unfakeActivity( Client* c ); bool activateNextClient( Client* c ); - bool focusChangeEnabled() { return block_focus == 0; } + bool focusChangeEnabled() + { return block_focus == 0; } void updateColormap(); /** * Indicates that the client c is being moved around by the user. */ - void setClientIsMoving( Client *c ); + void setClientIsMoving( Client* c ); - void place( Client *c, QRect& area ); + void place( Client* c, QRect& area ); void placeSmart( Client* c, const QRect& area ); QPoint adjustClientPosition( Client* c, QPoint pos, bool unrestricted ); @@ -137,15 +144,15 @@ class Workspace : public QObject, public KDecorationDefines void lowerClientRequest( Client* c, NET::RequestSource src, Time timestamp ); void restackClientUnderActive( Client* ); void updateClientLayer( Client* c ); - void raiseOrLowerClient( Client * ); + void raiseOrLowerClient( Client* ); void restoreSessionStackingOrder( Client* c ); void updateStackingOrder( bool propagate_new_clients = false ); void forceRestacking(); - void clientHidden( Client* ); + void clientHidden( Client* ); void clientAttentionChanged( Client* c, bool set ); - void checkElectricBorder(const QPoint &pos, Time time); + void checkElectricBorder(const QPoint& pos, Time time); void reserveElectricBorder( ElectricBorder border ); void unreserveElectricBorder( ElectricBorder border ); void reserveElectricBorderSwitching( bool reserve ); @@ -159,7 +166,7 @@ class Workspace : public QObject, public KDecorationDefines */ int numberOfDesktops() const; void setNumberOfDesktops( int n ); - void calcDesktopLayout(int* x, int* y, Qt::Orientation* orientation) const; + void calcDesktopLayout( int* x, int* y, Qt::Orientation* orientation ) const; int desktopToRight( int desktop, bool wrap ) const; int desktopToLeft( int desktop, bool wrap ) const; int desktopUp( int desktop, bool wrap ) const; @@ -168,21 +175,21 @@ class Workspace : public QObject, public KDecorationDefines int activeScreen() const; int numScreens() const; void checkActiveScreen( const Client* c ); - void setActiveScreenMouse( const QPoint &mousepos ); + void setActiveScreenMouse( const QPoint& mousepos ); QRect screenGeometry( int screen ) const; - int screenNumber( const QPoint &pos ) const; + int screenNumber( const QPoint& pos ) const; - // for TabBox + // Tab box Client* currentTabBoxClient() const; ClientList currentTabBoxClientList() const; int currentTabBoxDesktop() const; - QList< int > currentTabBoxDesktopList() const; - void setTabBoxClient(Client*); - void setTabBoxDesktop(int); - Client* nextClientFocusChain(Client*) const; - Client* previousClientFocusChain(Client*) const; - Client* nextClientStatic(Client*) const; - Client* previousClientStatic(Client*) const; + QList currentTabBoxDesktopList() const; + void setTabBoxClient( Client* ); + void setTabBoxDesktop( int ); + Client* nextClientFocusChain( Client* ) const; + Client* previousClientFocusChain( Client* ) const; + Client* nextClientStatic( Client* ) const; + Client* previousClientStatic( Client* ) const; int nextDesktopFocusChain( int iDesktop ) const; int previousDesktopFocusChain( int iDesktop ) const; int nextDesktopStatic( int iDesktop ) const; @@ -191,7 +198,7 @@ class Workspace : public QObject, public KDecorationDefines void unrefTabBox(); void closeTabBox(); - /** + /** * Returns the list of clients sorted in stacking order, with topmost client * at the last position */ @@ -199,14 +206,15 @@ class Workspace : public QObject, public KDecorationDefines ToplevelList xStackingOrder() const; ClientList ensureStackingOrder( const ClientList& clients ) const; - Client* topClientOnDesktop( int desktop, int screen, bool unconstrained = false, bool only_normal = true ) const; + Client* topClientOnDesktop( int desktop, int screen, 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 ); void windowToNextDesktop( Client* c ); void sendClientToScreen( Client* c, int screen ); - // KDE4 remove me - and it's also in the DCOP interface :( + // 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 ); @@ -219,13 +227,13 @@ class Workspace : public QObject, public KDecorationDefines /** - * Shows the menu operations menu for the client and makes it active if - * it's not already. + * Shows the menu operations menu for the client and makes it active if + * it's not already. + */ + void showWindowMenu( const QRect& pos, Client* cl ); + /** + * Backwards compatibility. */ - void showWindowMenu( const QRect &pos, Client* cl ); - /** - * Backwards compatibility. - */ void showWindowMenu( int x, int y, Client* cl ); void showWindowMenu( QPoint pos, Client* cl ); @@ -252,18 +260,18 @@ class Workspace : public QObject, public KDecorationDefines double decorationShadowBrightness( ShadowType type ) const; double decorationShadowSaturation( ShadowType type ) const; - // dcop interface + // D-Bus interface void cascadeDesktop(); void unclutterDesktop(); - void doNotManage( const QString & ); - QList< int > decorationSupportedColors() const; + void doNotManage( const QString& ); + QList decorationSupportedColors() const; bool setCurrentDesktop( int new_desktop ); void nextDesktop(); void previousDesktop(); void circulateDesktopApplications(); bool compositingActive(); bool waitForCompositingSetup(); - + void setCurrentScreen( int new_screen ); QString desktopName( int desk ) const; @@ -272,26 +280,31 @@ class Workspace : public QObject, public KDecorationDefines void resetShowingDesktop( bool keep_hidden ); bool showingDesktop() const; - bool isNotManaged( const QString& title ); // ### setter or getter ? + bool isNotManaged( const QString& title ); // TODO: Setter or getter? - void sendPingToWindow( Window w, Time timestamp ); // called from Client::pingWindow() - void sendTakeActivity( Client* c, Time timestamp, long flags ); // called from Client::takeActivity() + 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() + void removeClient( Client*, allowed_t ); // Only called from Client::destroyClient() or Client::releaseWindow() 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 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? - enum FocusChainChange { FocusChainMakeFirst, FocusChainMakeLast, FocusChainUpdate }; + void focusToNull(); // SELI TODO: Public? + enum FocusChainChange + { + FocusChainMakeFirst, + FocusChainMakeLast, + FocusChainUpdate + }; void updateFocusChains( Client* c, FocusChainChange change ); bool forcedGlobalMouseGrab() const; @@ -331,14 +344,14 @@ class Workspace : public QObject, public KDecorationDefines void addRepaint( const QRect& r ); void addRepaint( const QRegion& r ); void addRepaint( int x, int y, int w, int h ); - // creates XComposite overlay window, call initOverlay() afterwards + /// Creates XComposite overlay window, call initOverlay() afterwards bool createOverlay(); - // init overlay and the destination window in it + /// Init overlay and the destination window in it void setupOverlay( Window window ); void showOverlay(); void hideOverlay(); // hides and resets overlay window void setOverlayShape( const QRegion& reg ); - // destroys XComposite overlay window + /// Destroys XComposite overlay window void destroyOverlay(); Window overlayWindow(); void checkUnredirect( bool force = false ); @@ -347,7 +360,8 @@ class Workspace : public QObject, public KDecorationDefines public slots: void addRepaintFull(); void refresh(); - // keybindings + + // Keybindings void slotSwitchDesktopNext(); void slotSwitchDesktopPrevious(); void slotSwitchDesktopRight(); @@ -376,7 +390,7 @@ class Workspace : public QObject, public KDecorationDefines void slotSwitchToDesktop18() { return slotSwitchToDesktop( 18 ); } void slotSwitchToDesktop19() { return slotSwitchToDesktop( 19 ); } void slotSwitchToDesktop20() { return slotSwitchToDesktop( 20 ); } - //void slotSwitchToWindow( int ); + //void slotSwitchToWindow( int ); void slotWindowToDesktop( int ); void slotWindowToDesktop1() { return slotWindowToDesktop( 1 ); } void slotWindowToDesktop2() { return slotWindowToDesktop( 2 ); } @@ -398,7 +412,7 @@ class Workspace : public QObject, public KDecorationDefines void slotWindowToDesktop18() { return slotWindowToDesktop( 18 ); } void slotWindowToDesktop19() { return slotWindowToDesktop( 19 ); } void slotWindowToDesktop20() { return slotWindowToDesktop( 20 ); } - //void slotWindowToListPosition( int ); + //void slotWindowToListPosition( int ); void slotSwitchToScreen( int ); void slotSwitchToScreen0() { return slotSwitchToScreen( 0 ); } void slotSwitchToScreen1() { return slotSwitchToScreen( 1 ); } @@ -534,7 +548,7 @@ class Workspace : public QObject, public KDecorationDefines bool establishTabBoxGrab(); void removeTabBoxGrab(); - void propagateClients( bool propagate_new_clients ); // called only from updateStackingOrder + void propagateClients( bool propagate_new_clients ); // Called only from updateStackingOrder ClientList constrainedStackingOrder(); void raiseClientWithinApplication( Client* c ); void lowerClientWithinApplication( Client* c ); @@ -547,7 +561,7 @@ class Workspace : public QObject, public KDecorationDefines void updateTopMenuGeometry( Client* c = NULL ); void updateToolWindows( bool also_hide ); - // this is the right way to create a new client + /// 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 ); @@ -555,28 +569,28 @@ class Workspace : public QObject, public KDecorationDefines Window findSpecialEventWindow( XEvent* e ); - void randomPlacement(Client* c); - void smartPlacement(Client* c); - void cascadePlacement(Client* c, bool re_init = false); + void randomPlacement( Client* c ); + void smartPlacement( Client* c ); + void cascadePlacement( Client* c, bool re_init = false ); - // desktop names and number of desktops + // Desktop names and number of desktops void loadDesktopSettings(); void saveDesktopSettings(); - // mouse emulation + // Mouse emulation WId getMouseEmulationWindow(); enum MouseEmulation { EmuPress, EmuRelease, EmuMove }; - unsigned int sendFakedMouseEvent( const QPoint &pos, WId win, MouseEmulation type, int button, unsigned int state ); // returns the new state + unsigned int sendFakedMouseEvent( const QPoint& pos, WId win, MouseEmulation type, int button, unsigned int state ); // returns the new state void tabBoxKeyPress( int key ); void tabBoxKeyRelease( const XKeyEvent& ev ); - // electric borders + // Electric borders void destroyElectricBorders(); bool electricBorderEvent(XEvent * e); void electricBorderSwitchDesktop( ElectricBorder border, const QPoint& pos ); - // ------------------ + //--------------------------------------------------------------------- void helperDialog( const QString& message, const Client* c ); @@ -612,12 +626,12 @@ class Workspace : public QObject, public KDecorationDefines Client* active_client; Client* last_active_client; - Client* most_recently_raised; // used _only_ by raiseOrLowerClient() + Client* most_recently_raised; // Used ONLY by raiseOrLowerClient() Client* movingClient; Client* pending_take_activity; int active_screen; - // delay(ed) window focus timer and client + // Delay(ed) window focus timer and client QTimer* delayFocusTimer; Client* delayfocus_client; QPoint focusMousePos; @@ -627,14 +641,14 @@ class Workspace : public QObject, public KDecorationDefines UnmanagedList unmanaged; DeletedList deleted; - ClientList unconstrained_stacking_order; // topmost last - ClientList stacking_order; // topmost last + ClientList unconstrained_stacking_order; // Topmost last + ClientList stacking_order; // Topmost last bool force_restacking; - mutable ToplevelList x_stacking; // from XQueryTree() + mutable ToplevelList x_stacking; // From XQueryTree() mutable bool x_stacking_dirty; - 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 + 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; bool showing_desktop; @@ -650,9 +664,9 @@ class Workspace : public QObject, public KDecorationDefines bool control_grab; bool tab_grab; - //KKeyNative walkThroughDesktopsKeycode, walkBackThroughDesktopsKeycode; - //KKeyNative walkThroughDesktopListKeycode, walkBackThroughDesktopListKeycode; - //KKeyNative walkThroughWindowsKeycode, walkBackThroughWindowsKeycode; + //KKeyNative walkThroughDesktopsKeycode, walkBackThroughDesktopsKeycode; + //KKeyNative walkThroughDesktopListKeycode, walkBackThroughDesktopListKeycode; + //KKeyNative walkThroughWindowsKeycode, walkBackThroughWindowsKeycode; KShortcut cutWalkThroughDesktops, cutWalkThroughDesktopsReverse; KShortcut cutWalkThroughDesktopList, cutWalkThroughDesktopListReverse; KShortcut cutWalkThroughWindows, cutWalkThroughWindowsReverse; @@ -664,56 +678,56 @@ class Workspace : public QObject, public KDecorationDefines TabBox* tab_box; PopupInfo* popupinfo; - QMenu *popup; - QMenu *advanced_popup; - QMenu *trans_popup; - QMenu *desk_popup; + QMenu* popup; + QMenu* advanced_popup; + QMenu* trans_popup; + QMenu* desk_popup; void modalActionsSwitch( bool enabled ); - KActionCollection *keys; - KActionCollection *client_keys; - QAction *mResizeOpAction; - QAction *mMoveOpAction; - QAction *mMaximizeOpAction; - QAction *mShadeOpAction; - QAction *mKeepAboveOpAction; - QAction *mKeepBelowOpAction; - QAction *mFullScreenOpAction; - QAction *mNoBorderOpAction; - QAction *mMinimizeOpAction; - QAction *mCloseOpAction; + KActionCollection* keys; + KActionCollection* client_keys; + QAction* mResizeOpAction; + QAction* mMoveOpAction; + QAction* mMaximizeOpAction; + QAction* mShadeOpAction; + QAction* mKeepAboveOpAction; + QAction* mKeepBelowOpAction; + QAction* mFullScreenOpAction; + QAction* mNoBorderOpAction; + QAction* mMinimizeOpAction; + QAction* mCloseOpAction; ShortcutDialog* client_keys_dialog; Client* client_keys_client; - KActionCollection *disable_shortcuts_keys; + KActionCollection* disable_shortcuts_keys; bool global_shortcuts_disabled; bool global_shortcuts_disabled_for_client; - PluginMgr *mgr; + PluginMgr* mgr; - RootInfo *rootInfo; + RootInfo* rootInfo; QWidget* supportWindow; - // swallowing + // Swallowing QStringList doNotManageList; - // colormap handling + // Colormap handling Colormap default_colormap; Colormap installed_colormap; - // Timer to collect requests for 'reconfigure' + // Timer to collect requests for 'reconfigure' QTimer reconfigureTimer; QTimer updateToolWindowsTimer; - static Workspace *_self; + static Workspace* _self; bool workspaceInit; KStartupInfo* startup; ElectricBorder electric_current_border; - Window electric_windows[ ELECTRIC_COUNT ]; + Window electric_windows[ELECTRIC_COUNT]; int electricLeft; int electricRight; int electricTop; @@ -721,27 +735,27 @@ class Workspace : public QObject, public KDecorationDefines Time electric_time_first; Time electric_time_last; QPoint electric_push_point; - int electric_reserved[ ELECTRIC_COUNT ]; // corners/edges used by something + int electric_reserved[ELECTRIC_COUNT]; // Corners/edges used by something Qt::Orientation layoutOrientation; int layoutX; int layoutY; - Placement *initPositioning; + Placement* initPositioning; - QVector< QRect > workarea; // array of workareas for virtual desktops - QVector< QVector< QRect > > screenarea; // array of workareas per xinerama screen for all virtual desktops + QVector workarea; // Array of workareas for virtual desktops + QVector< QVector > screenarea; // Array of workareas per xinerama screen for all virtual desktops bool managing_topmenus; KSelectionOwner* topmenu_selection; KSelectionWatcher* topmenu_watcher; - ClientList topmenus; // doesn't own them + ClientList topmenus; // Doesn't own them mutable int topmenu_height; QWidget* topmenu_space; int set_active_client_recursion; - int block_stacking_updates; // when >0, stacking updates are temporarily disabled - bool blocked_propagating_new_clients; // propagate also new clients after enabling stacking updates? + int block_stacking_updates; // When > 0, stacking updates are temporarily disabled + bool blocked_propagating_new_clients; // Propagate also new clients after enabling stacking updates? Window null_focus_window; bool forced_global_mouse_grab; friend class StackingUpdatesBlocker; @@ -755,10 +769,10 @@ class Workspace : public QObject, public KDecorationDefines QRegion repaints_region; Window overlay; // XComposite overlay window bool overlay_visible; - bool overlay_shown; // for showOverlay() + bool overlay_shown; // For showOverlay() QRegion overlay_shape; - QSlider *transSlider; - QPushButton *transButton; + QSlider* transSlider; + QPushButton* transButton; QTimer unredirectTimer; bool forceUnredirectCheck; QList< int > composite_paint_times; @@ -767,7 +781,9 @@ class Workspace : public QObject, public KDecorationDefines friend bool performTransiencyCheck(); }; -// helper for Workspace::blockStackingUpdates() being called in pairs (true/false) +/** + * Helper for Workspace::blockStackingUpdates() being called in pairs (True/false) + */ class StackingUpdatesBlocker { public: @@ -775,28 +791,35 @@ class StackingUpdatesBlocker : ws( w ) { ws->blockStackingUpdates( true ); } ~StackingUpdatesBlocker() { ws->blockStackingUpdates( false ); } + private: Workspace* ws; }; -// NET WM Protocol handler class +/** + * NET WM Protocol handler class + */ class RootInfo : public NETRootInfo { private: - typedef KWin::Client Client; // because of NET::Client + typedef KWin::Client Client; // Because of NET::Client + public: - RootInfo( Workspace* ws, Display *dpy, Window w, const char *name, unsigned long pr[], int pr_num, int scr= -1); + RootInfo( Workspace* ws, Display* dpy, Window w, const char* name, unsigned long pr[], + int pr_num, int scr= -1 ); + protected: - virtual void changeNumberOfDesktops(int n); - virtual void changeCurrentDesktop(int d); - virtual void changeActiveWindow(Window w,NET::RequestSource src, Time timestamp, Window active_window); - virtual void closeWindow(Window w); - virtual void moveResize(Window w, int x_root, int y_root, unsigned long direction); - virtual void moveResizeWindow(Window w, int flags, int x, int y, int width, int height ); - virtual void gotPing(Window w, Time timestamp); - virtual void restackWindow(Window w, RequestSource source, Window above, int detail, Time timestamp); - virtual void gotTakeActivity(Window w, Time timestamp, long flags ); + virtual void changeNumberOfDesktops( int n ); + virtual void changeCurrentDesktop( int d ); + virtual void changeActiveWindow( Window w,NET::RequestSource src, Time timestamp, Window active_window ); + virtual void closeWindow( Window w ); + virtual void moveResize( Window w, int x_root, int y_root, unsigned long direction ); + virtual void moveResizeWindow( Window w, int flags, int x, int y, int width, int height ); + virtual void gotPing( Window w, Time timestamp ); + virtual void restackWindow( Window w, RequestSource source, Window above, int detail, Time timestamp ); + virtual void gotTakeActivity( Window w, Time timestamp, long flags ); virtual void changeShowingDesktop( bool showing ); + private: Workspace* workspace; }; @@ -839,34 +862,31 @@ inline void Workspace::removeGroup( Group* group, allowed_t ) inline const ClientList& Workspace::stackingOrder() const { -// TODO Q_ASSERT( block_stacking_updates == 0 ); + // TODO: Q_ASSERT( block_stacking_updates == 0 ); return stacking_order; } -inline void Workspace::showWindowMenu(QPoint pos, Client* cl) +inline void Workspace::showWindowMenu( QPoint pos, Client* cl ) { - showWindowMenu(QRect(pos, pos), cl); + showWindowMenu( QRect( pos, pos ), cl ); } -inline void Workspace::showWindowMenu(int x, int y, Client* cl) +inline void Workspace::showWindowMenu( int x, int y, Client* cl ) { - showWindowMenu(QRect(QPoint(x, y), QPoint(x, y)), cl); + showWindowMenu( QRect( QPoint( x, y ), QPoint( x, y )), cl ); } -inline -void Workspace::setWasUserInteraction() +inline void Workspace::setWasUserInteraction() { was_user_interaction = true; } -inline -bool Workspace::wasUserInteraction() const +inline bool Workspace::wasUserInteraction() const { return was_user_interaction; } -inline -bool Workspace::managingTopMenus() const +inline bool Workspace::managingTopMenus() const { return managing_topmenus; } @@ -906,27 +926,23 @@ inline Window Workspace::overlayWindow() return overlay; } -inline -bool Workspace::rulesUpdatesDisabled() const +inline bool Workspace::rulesUpdatesDisabled() const { return rules_updates_disabled; } -inline -void Workspace::forceRestacking() +inline void Workspace::forceRestacking() { force_restacking = true; - StackingUpdatesBlocker blocker( this ); // do restacking if not blocked + StackingUpdatesBlocker blocker( this ); // Do restacking if not blocked } -inline -void Workspace::updateFocusMousePosition( const QPoint& pos ) +inline void Workspace::updateFocusMousePosition( const QPoint& pos ) { focusMousePos = pos; } -inline -QPoint Workspace::focusMousePosition() const +inline QPoint Workspace::focusMousePosition() const { return focusMousePos; } @@ -944,18 +960,18 @@ inline Client* Workspace::findClient( T predicate ) const template< typename T1, typename T2 > inline void Workspace::forEachClient( T1 procedure, T2 predicate ) { - for ( ClientList::ConstIterator it = clients.constBegin(); it != clients.constEnd(); ++it) - if ( predicate( const_cast< const Client* >( *it))) + for( ClientList::ConstIterator it = clients.constBegin(); it != clients.constEnd(); ++it ) + if( predicate( const_cast( *it ))) procedure( *it ); - for ( ClientList::ConstIterator it = desktops.constBegin(); it != desktops.constEnd(); ++it) - if ( predicate( const_cast< const Client* >( *it))) + for( ClientList::ConstIterator it = desktops.constBegin(); it != desktops.constEnd(); ++it ) + if( predicate( const_cast( *it ))) procedure( *it ); } template< typename T > inline void Workspace::forEachClient( T procedure ) { - return forEachClient( procedure, TruePredicate()); + return forEachClient( procedure, TruePredicate() ); } template< typename T > @@ -967,80 +983,73 @@ inline Unmanaged* Workspace::findUnmanaged( T predicate ) const template< typename T1, typename T2 > inline void Workspace::forEachUnmanaged( T1 procedure, T2 predicate ) { - for ( UnmanagedList::ConstIterator it = unmanaged.constBegin(); it != unmanaged.constEnd(); ++it) - if ( predicate( const_cast< const Unmanaged* >( *it))) + for( UnmanagedList::ConstIterator it = unmanaged.constBegin(); it != unmanaged.constEnd(); ++it ) + if( predicate( const_cast( *it ))) procedure( *it ); } template< typename T > inline void Workspace::forEachUnmanaged( T procedure ) { - return forEachUnmanaged( procedure, TruePredicate()); + return forEachUnmanaged( procedure, TruePredicate() ); } KWIN_COMPARE_PREDICATE( ClientMatchPredicate, Client, const Client*, cl == value ); + inline bool Workspace::hasClient( const Client* c ) { return findClient( ClientMatchPredicate( c )); } -inline -void Workspace::checkCompositeTimer() +inline void Workspace::checkCompositeTimer() { - if( !compositeTimer.isActive()) + if( !compositeTimer.isActive() ) setCompositeTimer(); } -inline -bool Workspace::hasDecorationShadows() const +inline bool Workspace::hasDecorationShadows() const { return mgr->factory()->supports( AbilityCompositingShadow ); } -inline -QList< QList > Workspace::decorationShadowTextures() +inline QList< QList > Workspace::decorationShadowTextures() { - if( KDecorationFactoryUnstable* factory = dynamic_cast< KDecorationFactoryUnstable* >( mgr->factory() )) + if( KDecorationFactoryUnstable* factory = dynamic_cast( mgr->factory() )) return factory->shadowTextures(); return QList< QList >(); } -inline -int Workspace::decorationShadowTextureList( ShadowType type ) const +inline int Workspace::decorationShadowTextureList( ShadowType type ) const { - if( KDecorationFactoryUnstable* factory = dynamic_cast< KDecorationFactoryUnstable* >( mgr->factory() )) + if( KDecorationFactoryUnstable* factory = dynamic_cast( mgr->factory() )) return factory->shadowTextureList( type ); return -1; } -inline -QList Workspace::decorationShadowQuads( ShadowType type, QSize size ) const +inline QList Workspace::decorationShadowQuads( ShadowType type, QSize size ) const { - if( KDecorationFactoryUnstable* factory = dynamic_cast< KDecorationFactoryUnstable* >( mgr->factory() )) + if( KDecorationFactoryUnstable* factory = dynamic_cast( mgr->factory() )) return factory->shadowQuads( type, size ); return QList(); } -inline -double Workspace::decorationShadowOpacity( ShadowType type ) const +inline double Workspace::decorationShadowOpacity( ShadowType type ) const { - if( KDecorationFactoryUnstable* factory = dynamic_cast< KDecorationFactoryUnstable* >( mgr->factory() )) + if( KDecorationFactoryUnstable* factory = dynamic_cast( mgr->factory() )) return factory->shadowOpacity( type ); return 1.0; } -inline -double Workspace::decorationShadowBrightness( ShadowType type ) const +inline double Workspace::decorationShadowBrightness( ShadowType type ) const { - if( KDecorationFactoryUnstable* factory = dynamic_cast< KDecorationFactoryUnstable* >( mgr->factory() )) + if( KDecorationFactoryUnstable* factory = dynamic_cast( mgr->factory() )) return factory->shadowBrightness( type ); return 1.0; } -inline -double Workspace::decorationShadowSaturation( ShadowType type ) const +inline double Workspace::decorationShadowSaturation( ShadowType type ) const { - if( KDecorationFactoryUnstable* factory = dynamic_cast< KDecorationFactoryUnstable* >( mgr->factory() )) + if( KDecorationFactoryUnstable* factory = dynamic_cast< KDecorationFactoryUnstable*>( mgr->factory() )) return factory->shadowSaturation( type ); return 1.0; }