Bug 128648

Summary: Click raise active window doesn't raise the active window
Product: [Plasma] kwin Reporter: Joseph Smith <alienfeet2000>
Component: compositingAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: kde, ovit.debian, sgrayban
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Joseph Smith 2006-06-05 03:11:00 UTC
Version:           3.5.3 (using KDE KDE 3.5.3)
Installed from:    Gentoo Packages
Compiler:          gcc 4.1.1  gcc (GCC) 4.1.1 (Gentoo 4.1.1)
OS:                Linux

The click raise active window setting no longer raises the active window.  I noticed this after updating from KDE 3.5.2.  I'm using the focus follows mouse focus policy with a focus delay of 500ms.  Click to raise works if you click in an unfocused window (before the 500ms delay expires), which is the behavior I expect, but as soon as a lower window attains focus 'click raise active window' doesn't work.

To reproduce:
1) Set focus follows mouse focus policy.
2) Set delay focus for 500ms.
3) Select focus follows mouse.
4) Put two windows on the desktop.
5) Focus on the lower window area by letting the delay focus expire.
6) Click on the focused window area (not the titlebar) and notice that it doesn't raise.

The expected behavior is that the lower focused window should raise when clicking in the window area.

Currently, the only way to raise a window when clicking in the window area is to click in the window when unfocused.  This is the expected behavior for unfocused windows, and it was the behavior with 3.5.2.
Comment 1 Joseph Smith 2006-06-07 09:27:19 UTC
It looks like this may be related to the Xorg server version and not the KDE version, but it still may be a bug in kwin.  My system upgraded the Xorg server while KDE was updated to 3.5.3.  I don't have KDE 3.5.2 installed anymore, so I can't say if the newer Xorg modules will produce the same problem with that version of kwin.  In any case, there appears to be an incompatibility between KDE 3.5.3 and Xorg 7.1.  I've listed Xorg modules that were updated with KDE.


The problem is not apparent with the following Xorg modules:
xorg-server-1.0.2
xf86-input-mouse-1.0.4
xf86-input-keyboard-1.0.1.3
xf86-video-ati-6.5.8.0
xorg-x11-7.0


The upgraded versions are:
xorg-server-1.1.0
xf86-video-vesa-1.2.0
xf86-video-ati-6.6.0
xf86-input-mouse-1.1.1
xf86-input-keyboard-1.1.0
xorg-x11-7.1

These are Gentoo module versions, but I think they correspond to the Xorg module versions.
Comment 2 Lubos Lunak 2006-06-08 14:10:15 UTC
Works fine with KDE 3.5.3 and XOrg 6.9.0. I'm afraid it'll take some time before I'll have some system with 7.1 handy.
Comment 3 Joseph Smith 2006-08-26 19:20:25 UTC
It appears that this problem may be more directly related to using kompmgr.  The problem seems to only appear with Xorg 7.1 when kompmgr is running.
Comment 4 Andy Neitzke 2006-10-18 01:32:14 UTC
I have this problem too under xorg 7.1 -- and indeed only when kompmgr is running.  I am using KDE 3.5.5.
Comment 5 Kyle 2006-10-27 21:57:55 UTC
I have seen this problem on Kubuntu (dapper) with X.org 7.0.0.  I find it to be unrelated to any 'delay focus' setting.  
Comment 6 Kyle 2006-10-27 21:59:36 UTC
I should have mentioned, I have KDE 3.5.2 installed as well.
Comment 7 Kim Rasmussen 2006-11-03 13:11:41 UTC
I have the same problem under XOrg 7.1.1, but only when running kompmgr. I am using KDE 3.5.5.
Comment 8 Lubos Lunak 2006-11-08 14:53:54 UTC
SVN commit 603293 by lunakl:

Ok, with a compositing manager running, VisibilityNotify no longer
considers windows not visible just because a window is above them,
so the code from r198017 no longer works.
BUG: 128648




 M  +0 -1      client.cpp  
 M  +0 -2      client.h  
 M  +3 -22     events.cpp  
 M  +4 -0      layers.cpp  
 M  +1 -2      manage.cpp  
 M  +1 -2      workspace.cpp  


--- branches/KDE/3.5/kdebase/kwin/client.cpp #603292:603293
@@ -128,7 +128,6 @@
     modal = false;
     noborder = false;
     user_noborder = false;
-    not_obscured = false;
     urgency = false;
     ignore_focus_stealing = false;
     demands_attention = false;
--- branches/KDE/3.5/kdebase/kwin/client.h #603292:603293
@@ -336,7 +336,6 @@
         void clientMessageEvent( XClientMessageEvent* e );
         void enterNotifyEvent( XCrossingEvent* e );
         void leaveNotifyEvent( XCrossingEvent* e );
-        void visibilityNotifyEvent( XVisibilityEvent* e );
         void focusInEvent( XFocusInEvent* e );
         void focusOutEvent( XFocusOutEvent* e );
 
@@ -485,7 +484,6 @@
         uint modal : 1; // NET::Modal
         uint noborder : 1;
         uint user_noborder : 1;
-        uint not_obscured : 1;
         uint urgency : 1; // XWMHints, UrgencyHint
         uint ignore_focus_stealing : 1; // don't apply focus stealing prevention to this client
         uint demands_attention : 1;
--- branches/KDE/3.5/kdebase/kwin/events.cpp #603292:603293
@@ -631,9 +631,6 @@
                 workspace()->updateColormap();
             }
             break;
-        case VisibilityNotify:
-            visibilityNotifyEvent( &e->xvisibility );
-            break;
         default:
             if( e->xany.window == window())
             {
@@ -1009,18 +1006,13 @@
  */
 void Client::updateMouseGrab()
     {
-    if( workspace()->globalShortcutsDisabled())
-        {
-        XUngrabButton( qt_xdisplay(), AnyButton, AnyModifier, wrapperId());
-        // keep grab for the simple click without modifiers if needed
-        if( !( !options->clickRaise || not_obscured ))
-            grabButton( None );
-        return;
-        }
     if( isActive() && !workspace()->forcedGlobalMouseGrab()) // see Workspace::establishTabBoxGrab()
         {
         // remove the grab for no modifiers only if the window
         // is unobscured or if the user doesn't want click raise
+        // (it is unobscured if it the topmost in the unconstrained stacking order, i.e. it is
+        // the most recently raised window)
+        bool not_obscured = workspace()->topClientOnDesktop( workspace()->currentDesktop(), true ) == this;
         if( !options->clickRaise || not_obscured )
             ungrabButton( None );
         else
@@ -1455,17 +1447,6 @@
         setActive( FALSE );
     }
 
-void Client::visibilityNotifyEvent( XVisibilityEvent * e)
-    {
-    if( e->window != frameId())
-        return; // care only about the whole frame
-    bool new_not_obscured = e->state == VisibilityUnobscured;
-    if( not_obscured == new_not_obscured )
-        return;
-    not_obscured = new_not_obscured;
-    updateMouseGrab();
-    }
-
 // performs _NET_WM_MOVERESIZE
 void Client::NETMoveResize( int x_root, int y_root, NET::Direction direction )
     {
--- branches/KDE/3.5/kdebase/kwin/layers.cpp #603292:603293
@@ -117,7 +117,11 @@
         }
 #endif
     if( changed || propagate_new_clients )
+        {
         propagateClients( propagate_new_clients );
+        if( active_client )
+            active_client->updateMouseGrab();
+        }
     }
 
 /*!
--- branches/KDE/3.5/kdebase/kwin/manage.cpp #603292:603293
@@ -565,8 +565,7 @@
             FocusChangeMask |
             ExposureMask |
             PropertyChangeMask |
-            StructureNotifyMask | SubstructureRedirectMask |
-            VisibilityChangeMask );
+            StructureNotifyMask | SubstructureRedirectMask );
     XSelectInput( qt_xdisplay(), wrapper, ClientWinMask | SubstructureNotifyMask );
     XSelectInput( qt_xdisplay(), client,
                   FocusChangeMask |
--- branches/KDE/3.5/kdebase/kwin/workspace.cpp #603292:603293
@@ -2022,8 +2022,7 @@
     XSetWindowAttributes attributes;
     unsigned long valuemask;
     attributes.override_redirect = True;
-    attributes.event_mask =  (EnterWindowMask | LeaveWindowMask |
-                              VisibilityChangeMask);
+    attributes.event_mask =  ( EnterWindowMask | LeaveWindowMask );
     valuemask=  (CWOverrideRedirect | CWEventMask | CWCursor );
     attributes.cursor = XCreateFontCursor(qt_xdisplay(),
                                           XC_sb_up_arrow);
Comment 9 Lubos Lunak 2006-12-18 13:54:47 UTC
*** Bug 138875 has been marked as a duplicate of this bug. ***
Comment 10 Lubos Lunak 2007-05-25 16:17:11 UTC
*** Bug 145902 has been marked as a duplicate of this bug. ***
Comment 11 Scott Grayban 2008-03-14 18:11:03 UTC
This patch has also broken Superkaramba -- have months of testing and working out what was changed we found that this fix has broken superkaramba.

See bug #143255