From 5fb81f837baa1a4986921d82cbec706e9a75f47c Mon Sep 17 00:00:00 2001 From: Matthias Ettrich Date: Thu, 13 Jul 2000 17:59:12 +0000 Subject: [PATCH] no "resize" and "maximize" options for non-resizable windows svn path=/trunk/kdebase/kwin/; revision=56608 --- client.cpp | 14 +++++++++++++- client.h | 2 ++ main.cpp | 4 ++-- workspace.cpp | 21 +++++++++++---------- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/client.cpp b/client.cpp index 258938d3fb..f3b691ccad 100644 --- a/client.cpp +++ b/client.cpp @@ -1022,6 +1022,18 @@ QSize Client::sizeForWindowSize( const QSize& wsize, bool ignore_height) const } +/*! + Returns whether the window is resizable or has a fixed size. + */ +bool Client::isResizable() const +{ + if ( ( xSizeHint.flags & PMaxSize) == 0 || (xSizeHint.flags & PMinSize ) == 0 ) + return TRUE; + return ( xSizeHint.min_width != xSizeHint.max_width ) || + ( xSizeHint.min_height != xSizeHint.max_height ); +} + + /*! Reimplemented to provide move/resize */ @@ -1446,7 +1458,7 @@ void Client::killWindow() void Client::maximize( MaximizeMode m) { - if (!isMovable()) + if (!isMovable() || !isResizable() ) return; QRect clientArea = workspace()->clientArea(); diff --git a/client.h b/client.h index ed1b07947a..fde852540a 100644 --- a/client.h +++ b/client.h @@ -126,6 +126,8 @@ public: bool isDesktop() const; bool isDock() const; bool isMenu() const; + + bool isResizable() const; void takeFocus(); diff --git a/main.cpp b/main.cpp index d73af60c7d..8be14ae5dd 100644 --- a/main.cpp +++ b/main.cpp @@ -46,7 +46,7 @@ static void crashHandler(int) { KCrash::setCrashHandler(0); // Exit on next crash. delete client; client = 0; // Unregister with dcop. - system("kwin&"); // Try to restart +// system("kwin&"); // Try to restart } int x11ErrorHandler(Display *d, XErrorEvent *e){ @@ -214,7 +214,7 @@ int main( int argc, char * argv[] ) signal(SIGHUP, SIG_IGN); Application a; - KCrash::setCrashHandler(crashHandler); // Try to restart on crash +// KCrash::setCrashHandler(crashHandler); // Try to restart on crash fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, 1); client = a.dcopClient(); diff --git a/workspace.cpp b/workspace.cpp index c41e5527ac..016e46fad3 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -844,13 +844,13 @@ Client* Workspace::previousStaticClient( Client* c ) const /*! - Returns topmost visible client. Windows on the dock and the - desktop are excluded. + Returns topmost visible client. Windows on the dock, the desktop + or of any other special kind are excluded. */ Client* Workspace::topClientOnDesktop() const { for ( ClientList::ConstIterator it = stacking_order.fromLast(); it != stacking_order.end(); --it) { - if ( !(*it)->isDesktop() && !(*it)->isDock() && !(*it)->isDock() ) + if ( !(*it)->isDesktop() && (*it)->isVisible() && (*it)->wantsTabFocus() ) return *it; } return 0; @@ -1528,18 +1528,19 @@ void Workspace::lowerClient( Client* c, bool dropFocus ) ClientList list = constrainedStackingOrder( stacking_order ); Window* new_stack = new Window[ list.count() + 1 ]; int i = 0; - Client *new_top = 0; for ( ClientList::ConstIterator it = list.fromLast(); it != list.end(); --it) { new_stack[i++] = (*it)->winId(); - if (!new_top && (*it)->isVisible()) new_top = (*it); } XRaiseWindow(qt_xdisplay(), new_stack[0]); XRestackWindows(qt_xdisplay(), new_stack, i); delete [] new_stack; propagateClients( TRUE ); - if (dropFocus && new_top) { - requestFocus(new_top); + + if (dropFocus ) { + Client* top = topClientOnDesktop(); + if ( top ) + requestFocus( top); } } @@ -2101,6 +2102,8 @@ void Workspace::clientPopupAboutToShow() { if ( !popup_client || !popup ) return; + popup->setItemEnabled( Options::ResizeOp, popup_client->isResizable() ); + popup->setItemEnabled( Options::MaximizeOp, popup_client->isResizable() ); popup->setItemChecked( Options::MaximizeOp, popup_client->isMaximized() ); popup->setItemChecked( Options::ShadeOp, popup_client->isShade() ); popup->setItemChecked( Options::StaysOnTopOp, popup_client->staysOnTop() ); @@ -2642,9 +2645,7 @@ void Workspace::loadDesktopSettings() { KConfig c("kdeglobals"); c.setGroup("Desktops"); - if (!c.hasKey("Number")) - c.writeEntry("Number", 4); - int n = c.readNumEntry("Number"); + int n = c.readNumEntry("Number", 4); number_of_desktops = n; rootInfo->setNumberOfDesktops( number_of_desktops ); for(int i = 1; i <= n; i++) {