Bug 122425 - kwin doesn't support XShape1.1 => disables input shapes e.g for cairo-clock 0.3.1
Summary: kwin doesn't support XShape1.1 => disables input shapes e.g for cairo-clock 0...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-21 17:25 UTC by Johannes Schaub
Modified: 2006-08-10 15:07 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Schaub 2006-02-21 17:25:12 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          g++3.4.3 
OS:                Linux

Developing a new applications which uses so-called input-shapes i tried MacSlows' example, which explains its usage (http://macslow.thepimp.net/projects/input_shape_test.c)

but apparently kwin blocks it from using its shape. i tried metacity, and with it, the sample just works.

Input-Shapes are a official feature of the X Extension XShape, spec 1.1. Having kwin to not support it/to block apps from using it, is a shame for KDE. 
Please repair kwin to work properly like metacity in this case does.

thx in advance
Comment 1 Lubos Lunak 2006-02-21 18:09:12 UTC
Yeah, what a shame for our several months old last stable release that it doesn't support some extension that's apparently so new that even X.org 6.9.0 doesn't include it. I at least cannot find it anywhere, doc/hardcopy/Xext describes only XShape 1.0 and I don't see anything in the libXext code either.

Where can one find anything about this?
Comment 2 Johannes Schaub 2006-02-21 18:21:37 UTC
do "xdpyinfo -ext SHAPE" to see your version.
no, that spec isn't totally new and is supported by at least Xorg7.0 (and therefore 6.9 too), and metacity 2.8.6, which is of gnome 2.8(!). 
also consider that i was joking when i said that it would be a shame for KDE. everyone knows that KDE doesn't have to shame for anything :)
Comment 3 Lubos Lunak 2006-02-22 09:17:22 UTC
It is new, the newest X.org version at the time of 3.5.0 release was 6.8, which has only XShape 1.0. And this still doesn't answer the question of any docs for it - I guess it will be again something along the lines of "ask your favourite X developer" :-/.

Comment 4 Christian Loose 2006-02-22 11:22:38 UTC
Keith updated the XShape specification to 1.1 just four days ago. ;-)

See http://webcvs.freedesktop.org/xorg/doc/xorg-docs/specs/Xext/shape.ms?rev=1.4&view=log.
Comment 5 Johannes Schaub 2006-02-22 16:26:09 UTC
ok you're soo right. it's too new. just would be happy if kwin supports it... thx to all
Comment 6 Lubos Lunak 2006-08-10 15:07:29 UTC
SVN commit 571711 by lunakl:

Support for input shape from XShape1.1.
FEATURE: 122425



 M  +23 -10    client.cpp  
 M  +2 -4      geometry.cpp  
 M  +2 -6      manage.cpp  
 M  +9 -4      utils.cpp  
 M  +4 -2      utils.h  


--- branches/KDE/3.5/kdebase/kwin/client.cpp #571710:571711
@@ -458,24 +458,37 @@
 
 void Client::updateShape()
     {
-    setShapable(TRUE);
+    // workaround for #19644 - shaped windows shouldn't have decoration
+    if( shape() && !noBorder()) 
+        {
+        noborder = true;
+        updateDecoration( true );
+        }
     if ( shape() )
-    {
+        {
         XShapeCombineShape(qt_xdisplay(), frameId(), ShapeBounding,
                            clientPos().x(), clientPos().y(),
                            window(), ShapeBounding, ShapeSet);
-    }
+        setShapable(TRUE);
+        }
     else
-    {
+        {
         XShapeCombineMask( qt_xdisplay(), frameId(), ShapeBounding, 0, 0,
                            None, ShapeSet);
-    }
-    // workaround for #19644 - shaped windows shouldn't have decoration
-    if( shape() && !noBorder()) 
-        {
-        noborder = true;
-        updateDecoration( true );
         }
+    if( Shape::major() > 1 || Shape::minor() >= 1 ) // has input shape support
+        { // there appears to be no way to find out if a window has input
+          // shape set or not, so always set propagate the input shape
+          // (it's the same like the bounding shape by default)
+        XShapeCombineMask( qt_xdisplay(), frameId(), ShapeInput, 0, 0,
+                           None, ShapeSet );
+        XShapeCombineShape( qt_xdisplay(), frameId(), ShapeInput,
+                           clientPos().x(), clientPos().y(),
+                           window(), ShapeBounding, ShapeSubtract );
+        XShapeCombineShape( qt_xdisplay(), frameId(), ShapeInput,
+                           clientPos().x(), clientPos().y(),
+                           window(), ShapeInput, ShapeUnion );
+        }
     }
 
 void Client::setMask( const QRegion& reg, int mode )
--- branches/KDE/3.5/kdebase/kwin/geometry.cpp #571710:571711
@@ -1709,8 +1709,7 @@
             cs.width(), cs.height());
         XMoveResizeWindow( qt_xdisplay(), window(), 0, 0, cs.width(), cs.height());
         }
-    if( shape())
-        updateShape();
+    updateShape();
     // SELI TODO won't this be too expensive?
     updateWorkareaDiffs();
     sendSyntheticConfigureNotify();
@@ -1764,8 +1763,7 @@
             cs.width(), cs.height());
         XMoveResizeWindow( qt_xdisplay(), window(), 0, 0, cs.width(), cs.height());
         }
-    if( shape())
-        updateShape();
+    updateShape();
     updateWorkareaDiffs();
     sendSyntheticConfigureNotify();
     updateWindowRules();
--- branches/KDE/3.5/kdebase/kwin/manage.cpp #571710:571711
@@ -316,12 +316,8 @@
         keepInArea( area, partial_keep_in_area );
 
     XShapeSelectInput( qt_xdisplay(), window(), ShapeNotifyMask );
-    if ( (is_shape = Shape::hasShape( window())) ) 
-        {
-        updateShape();
-        }
-//    else
-//	setShapable(FALSE);
+    is_shape = Shape::hasShape( window());
+    updateShape();
 	
     //CT extra check for stupid jdk 1.3.1. But should make sense in general
     // if client has initial state set to Iconic and is transient with a parent
--- branches/KDE/3.5/kdebase/kwin/utils.cpp #571710:571711
@@ -44,7 +44,7 @@
 // used to store the return values of
 // XShapeQueryExtension.
 // Necessary since shaped window are an extension to X
-int Shape::kwin_has_shape = 0;
+int Shape::kwin_shape_version = 0;
 int Shape::kwin_shape_event = 0;
 
 // does the window w  need a shape combine mask around it?
@@ -53,7 +53,7 @@
     int xws, yws, xbs, ybs;
     unsigned int wws, hws, wbs, hbs;
     int boundingShaped = 0, clipShaped = 0;
-    if (!kwin_has_shape)
+    if (!available())
         return FALSE;
     XShapeQueryExtents(qt_xdisplay(), w,
                        &boundingShaped, &xws, &yws, &wws, &hws,
@@ -68,9 +68,14 @@
 
 void Shape::init()
     {
+    kwin_shape_version = 0;
     int dummy;
-    kwin_has_shape =
-      XShapeQueryExtension(qt_xdisplay(), &kwin_shape_event, &dummy);
+    if( !XShapeQueryExtension(qt_xdisplay(), &kwin_shape_event, &dummy))
+        return;
+    int major, minor;
+    if( !XShapeQueryVersion( qt_xdisplay(), &major, &minor ))
+        return;
+    kwin_shape_version = major * 16 + minor;
     }
 
 void Motif::readFlags( WId w, bool& noborder, bool& resize, bool& move,
--- branches/KDE/3.5/kdebase/kwin/utils.h #571710:571711
@@ -111,12 +111,14 @@
 class Shape 
     {
     public:
-        static bool available() { return kwin_has_shape; }
+        static bool available() { return kwin_shape_version > 0; }
+        static int major() { return kwin_shape_version / 16; }
+        static int minor() { return kwin_shape_version % 16; }
         static bool hasShape( WId w);
         static int shapeEvent();
         static void init();
     private:
-        static int kwin_has_shape;
+        static int kwin_shape_version; // as 16*major+minor
         static int kwin_shape_event;
     };