From 12b4954267579c9d23eea4b24e1249497e04ff3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Mon, 17 May 2004 12:06:45 +0000 Subject: [PATCH] Revertlast, already fixed as ##79252 , and this unnecessarily takes up screen edges. svn path=/trunk/kdebase/kwin/; revision=312031 --- workspace.cpp | 118 +++++++++++++++++++++++++------------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/workspace.cpp b/workspace.cpp index 66b527f045..a71c669bc7 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -315,7 +315,7 @@ void Workspace::init() unsigned int i, nwins; Window root_return, parent_return, *wins; XQueryTree(qt_xdisplay(), root, &root_return, &parent_return, &wins, &nwins); - for (i = 0; i < nwins; i++) + for (i = 0; i < nwins; i++) { XWindowAttributes attr; XGetWindowAttributes(qt_xdisplay(), wins[i], &attr); @@ -323,12 +323,12 @@ void Workspace::init() continue; if( topmenu_space && topmenu_space->winId() == wins[ i ] ) continue; - if (attr.map_state != IsUnmapped) + if (attr.map_state != IsUnmapped) { if ( addSystemTrayWin( wins[i] ) ) continue; Client* c = createClient( wins[i], true ); - if ( c != NULL && root != qt_xrootwin() ) + if ( c != NULL && root != qt_xrootwin() ) { // TODO what is this? // TODO may use QWidget:.create XReparentWindow( qt_xdisplay(), c->frameId(), root, 0, 0 ); @@ -607,7 +607,7 @@ void Workspace::updateCurrentTopMenu() } // ... then hide the other ones. Avoids flickers. - for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it) + for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it) { if( (*it)->isTopMenu() && (*it) != menubar ) (*it)->hideClient( true ); @@ -701,7 +701,7 @@ void Workspace::updateColormap() Colormap cmap = default_colormap; if ( activeClient() && activeClient()->colormap() != None ) cmap = activeClient()->colormap(); - if ( cmap != installed_colormap ) + if ( cmap != installed_colormap ) { XInstallColormap(qt_xdisplay(), cmap ); installed_colormap = cmap; @@ -800,7 +800,7 @@ void Workspace::loadDesktopSettings() screenarea = NULL; rootInfo->setNumberOfDesktops( number_of_desktops ); desktop_focus_chain.resize( n ); - for(int i = 1; i <= n; i++) + for(int i = 1; i <= n; i++) { QString s = c.readEntry(QString("Name_%1").arg(i), i18n("Desktop %1").arg(i)); @@ -821,21 +821,21 @@ void Workspace::saveDesktopSettings() c.setGroup(groupname); c.writeEntry("Number", number_of_desktops ); - for(int i = 1; i <= number_of_desktops; i++) + for(int i = 1; i <= number_of_desktops; i++) { QString s = desktopName( i ); QString defaultvalue = i18n("Desktop %1").arg(i); - if ( s.isEmpty() ) + if ( s.isEmpty() ) { s = defaultvalue; rootInfo->setDesktopName( i, s.utf8().data() ); } - if (s != defaultvalue) + if (s != defaultvalue) { c.writeEntry( QString("Name_%1").arg(i), s ); } - else + else { QString currentvalue = c.readEntry(QString("Name_%1").arg(i)); if (currentvalue != defaultvalue) @@ -873,10 +873,10 @@ void Workspace::doNotManage( QString title ) */ 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.search(title) != -1) + if (r.search(title) != -1) { doNotManageList.remove( it ); return TRUE; @@ -888,7 +888,7 @@ bool Workspace::isNotManaged( const QString& title ) /*! Refreshes all the client windows */ -void Workspace::refresh() +void Workspace::refresh() { QWidget w; w.setGeometry( QApplication::desktop()->geometry() ); @@ -925,7 +925,7 @@ void ObscuringWindows::create( Client* c ) Window obs_win; XWindowChanges chngs; int mask = CWSibling | CWStackMode; - if( cached->count() > 0 ) + if( cached->count() > 0 ) { cached->remove( obs_win = cached->first()); chngs.x = c->x(); @@ -934,7 +934,7 @@ void ObscuringWindows::create( Client* c ) chngs.height = c->height(); mask |= CWX | CWY | CWWidth | CWHeight; } - else + else { XSetWindowAttributes a; a.background_pixmap = None; @@ -955,7 +955,7 @@ ObscuringWindows::~ObscuringWindows() max_cache_size = QMAX( max_cache_size, obscuring_windows.count() + 4 ) - 1; for( QValueList::ConstIterator it = obscuring_windows.begin(); it != obscuring_windows.end(); - ++it ) + ++it ) { XUnmapWindow( qt_xdisplay(), *it ); if( cached->count() < max_cache_size ) @@ -983,7 +983,7 @@ bool Workspace::setCurrentDesktop( int new_desktop ) // TODO Q_ASSERT( block_stacking_updates == 0 ); // make sure stacking_order is up to date StackingUpdatesBlocker blocker( this ); - if (new_desktop != current_desktop) + if (new_desktop != current_desktop) { /* optimized Desktop switching: unmapping done from back to front @@ -1018,7 +1018,7 @@ bool Workspace::setCurrentDesktop( int new_desktop ) --block_focus; Client* c = 0; - if ( options->focusPolicyIsReasonable()) + if ( options->focusPolicyIsReasonable()) { // Search in focus chain @@ -1028,11 +1028,11 @@ bool Workspace::setCurrentDesktop( int new_desktop ) c = active_client; // the requestFocus below will fail, as the client is already active } - if ( !c ) + if ( !c ) { - for( ClientList::ConstIterator it = focus_chain.fromLast(); it != focus_chain.end(); --it) + for( ClientList::ConstIterator it = focus_chain.fromLast(); it != focus_chain.end(); --it) { - if ( (*it)->isShown( false ) && !(*it)->isOnAllDesktops() && (*it)->isOnCurrentDesktop()) + if ( (*it)->isShown( false ) && !(*it)->isOnAllDesktops() && (*it)->isOnCurrentDesktop()) { c = *it; break; @@ -1040,11 +1040,11 @@ bool Workspace::setCurrentDesktop( int new_desktop ) } } - if ( !c ) + if ( !c ) { - for( ClientList::ConstIterator it = focus_chain.fromLast(); it != focus_chain.end(); --it) + for( ClientList::ConstIterator it = focus_chain.fromLast(); it != focus_chain.end(); --it) { - if ( (*it)->isShown( false ) && (*it)->isOnCurrentDesktop()) + if ( (*it)->isShown( false ) && (*it)->isOnCurrentDesktop()) { c = *it; break; @@ -1062,12 +1062,12 @@ bool Workspace::setCurrentDesktop( int new_desktop ) if( c != active_client ) setActiveClient( NULL, Allowed ); - if ( c ) + if ( c ) requestFocus( c ); - else + else focusToNull(); - if( !desktops.isEmpty() ) + if( !desktops.isEmpty() ) { Window w_tmp; int i_tmp; @@ -1121,7 +1121,7 @@ void Workspace::setNumberOfDesktops( int n ) // 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 ) + if( old_number_of_desktops < number_of_desktops ) { rootInfo->setNumberOfDesktops( number_of_desktops ); NETPoint* viewports = new NETPoint[ number_of_desktops ]; @@ -1132,17 +1132,17 @@ void Workspace::setNumberOfDesktops( int n ) // 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 ) + if( old_number_of_desktops > number_of_desktops ) { for( ClientList::ConstIterator it = clients.begin(); it != clients.end(); - ++it) + ++it) { if( !(*it)->isOnAllDesktops() && (*it)->desktop() > numberOfDesktops()) sendClientToDesktop( *it, numberOfDesktops(), true ); } } - if( old_number_of_desktops > number_of_desktops ) + if( old_number_of_desktops > number_of_desktops ) { rootInfo->setNumberOfDesktops( number_of_desktops ); NETPoint* viewports = new NETPoint[ number_of_desktops ]; @@ -1182,7 +1182,7 @@ void Workspace::sendClientToDesktop( Client* c, int desk, bool dont_activate ) else restackClientUnderActive( c ); } - else + else { raiseClient( c ); focus_chain.remove( c ); @@ -1288,7 +1288,7 @@ void Workspace::propagateSystemTrayWins() Window *cl = new Window[ systemTrayWins.count()]; int i = 0; - for ( SystemTrayWindowList::ConstIterator it = systemTrayWins.begin(); it != systemTrayWins.end(); ++it ) + for ( SystemTrayWindowList::ConstIterator it = systemTrayWins.begin(); it != systemTrayWins.end(); ++it ) { cl[i++] = (*it).win; } @@ -1304,7 +1304,7 @@ 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 @@ -1343,12 +1343,12 @@ void Workspace::sendTakeActivity( Client* c, Time timestamp, long flags ) */ void Workspace::slotGrabWindow() { - if ( active_client ) + if ( active_client ) { QPixmap snapshot = QPixmap::grabWindow( active_client->frameId() ); //No XShape - no work. - if( Shape::available()) + if( Shape::available()) { //As the first step, get the mask from XShape. int count, order; @@ -1358,7 +1358,7 @@ void Workspace::slotGrabWindow() //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) + if (rects) { //Create a QRegion from the rectangles describing the bounding mask. QRegion contents; @@ -1409,7 +1409,7 @@ void Workspace::slotGrabDesktop() void Workspace::slotMouseEmulation() { - if ( mouse_emulation ) + if ( mouse_emulation ) { XUngrabKeyboard(qt_xdisplay(), qt_x_time); mouse_emulation = FALSE; @@ -1419,7 +1419,7 @@ void Workspace::slotMouseEmulation() if ( XGrabKeyboard(qt_xdisplay(), root, FALSE, GrabModeAsync, GrabModeAsync, - qt_x_time) == GrabSuccess ) + qt_x_time) == GrabSuccess ) { mouse_emulation = TRUE; mouse_emulation_state = 0; @@ -1441,7 +1441,7 @@ WId Workspace::getMouseEmulationWindow() uint state; Window w; Client * c = 0; - do + do { w = child; if (!c) @@ -1463,12 +1463,12 @@ unsigned int Workspace::sendFakedMouseEvent( QPoint pos, WId w, MouseEmulation t if ( !w ) return state; QWidget* widget = QWidget::find( w ); - if ( (!widget || widget->inherits("QToolButton") ) && !findClient( WindowMatchPredicate( w )) ) + if ( (!widget || widget->inherits("QToolButton") ) && !findClient( WindowMatchPredicate( w )) ) { int x, y; Window xw; XTranslateCoordinates( qt_xdisplay(), qt_xrootwin(), w, pos.x(), pos.y(), &x, &y, &xw ); - if ( type == EmuMove ) + if ( type == EmuMove ) { // motion notify events XMotionEvent e; e.type = MotionNotify; @@ -1484,7 +1484,7 @@ unsigned int Workspace::sendFakedMouseEvent( QPoint pos, WId w, MouseEmulation t e.is_hint = NotifyNormal; XSendEvent( qt_xdisplay(), w, TRUE, ButtonMotionMask, (XEvent*)&e ); } - else + else { XButtonEvent e; e.type = type == EmuRelease ? ButtonRelease : ButtonPress; @@ -1500,9 +1500,9 @@ unsigned int Workspace::sendFakedMouseEvent( QPoint pos, WId w, MouseEmulation t e.button = button; XSendEvent( qt_xdisplay(), w, TRUE, ButtonPressMask, (XEvent*)&e ); - if ( type == EmuPress ) + if ( type == EmuPress ) { - switch ( button ) + switch ( button ) { case 2: state |= Button2Mask; @@ -1515,9 +1515,9 @@ unsigned int Workspace::sendFakedMouseEvent( QPoint pos, WId w, MouseEmulation t break; } } - else + else { - switch ( button ) + switch ( button ) { case 2: state &= ~Button2Mask; @@ -1551,7 +1551,7 @@ bool Workspace::keyPressMouseEmulation( XKeyEvent& ev ) int delta = is_control?1:is_alt?32:8; QPoint pos = QCursor::pos(); - switch ( kc ) + switch ( kc ) { case XK_Left: case XK_KP_Left: @@ -1596,16 +1596,16 @@ bool Workspace::keyPressMouseEmulation( XKeyEvent& ev ) case XK_Return: case XK_space: case XK_KP_Enter: - case XK_KP_Space: + case XK_KP_Space: { - if ( !mouse_emulation_state ) + 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 ); } - else + else { // release all if ( mouse_emulation_state & Button1Mask ) mouse_emulation_state = sendFakedMouseEvent( pos, mouse_emulation_window, EmuRelease, Button1, mouse_emulation_state ); @@ -1660,10 +1660,10 @@ void Workspace::checkElectricBorders() electricLeft = r.left(); electricRight = r.right(); - if (options->electricBorders() == Options::ElectricDisabled) - destroyBorderWindows(); - else + if (options->electricBorders() == Options::ElectricAlways) createBorderWindows(); + else + destroyBorderWindows(); } void Workspace::createBorderWindows() @@ -1796,7 +1796,7 @@ void Workspace::clientMoved(const QPoint &pos, Time now) { case 1: slotSwitchDesktopLeft(); - if (currentDesktop() != desk_before) + if (currentDesktop() != desk_before) { offset = r.width() / 5; QCursor::setPos(r.width() - offset, pos.y()); @@ -1805,7 +1805,7 @@ void Workspace::clientMoved(const QPoint &pos, Time now) case 2: slotSwitchDesktopRight(); - if (currentDesktop() != desk_before) + if (currentDesktop() != desk_before) { offset = r.width() / 5; QCursor::setPos(offset, pos.y()); @@ -1814,7 +1814,7 @@ void Workspace::clientMoved(const QPoint &pos, Time now) case 3: slotSwitchDesktopUp(); - if (currentDesktop() != desk_before) + if (currentDesktop() != desk_before) { offset = r.height() / 5; QCursor::setPos(pos.x(), r.height() - offset); @@ -1823,7 +1823,7 @@ void Workspace::clientMoved(const QPoint &pos, Time now) case 4: slotSwitchDesktopDown(); - if (currentDesktop() != desk_before) + if (currentDesktop() != desk_before) { offset = r.height() / 5; QCursor::setPos(pos.x(), offset); @@ -1833,7 +1833,7 @@ void Workspace::clientMoved(const QPoint &pos, Time now) return; } } - else + else { electric_current_border = border; electric_time_first = now;