[mutter] Handle input area set to full screen or reset during start-up



commit 0a863b8c2b90d2cbbe8d9a7db7f423c8bf879161
Author: Marina Zhurakhinskaya <marinaz redhat com>
Date:   Fri Jun 19 16:42:10 2009 -0400

    Handle input area set to full screen or reset during start-up
    
    info->pending_input_region needed to be destroyed in
    mutter_set_stage_input_region() before it was set to something
    else or before it was reset to be full screen (region == None).
    
    Set the initial input area to an empty region by
    setting info->pending_input_region to an empty region by default
    and setting it to None or a new region if a new input region is
    specified.
    
    Remove show_overlay_window() function that was used to set an empty
    input region on start-up, and uses a call to do_set_stage_input_region()
    with info->pending_input_region as an argument instead.

 src/compositor/mutter/compositor-mutter.c |   73 ++++++++++++++++++----------
 1 files changed, 47 insertions(+), 26 deletions(-)
---
diff --git a/src/compositor/mutter/compositor-mutter.c b/src/compositor/mutter/compositor-mutter.c
index 81541da..1ab954c 100644
--- a/src/compositor/mutter/compositor-mutter.c
+++ b/src/compositor/mutter/compositor-mutter.c
@@ -1738,21 +1738,6 @@ process_property_notify (Mutter		*compositor,
   DEBUG_TRACE ("process_property_notify: unknown\n");
 }
 
-static void
-show_overlay_window (Display *xdisplay, Window xstage, Window xoverlay)
-{
-  XserverRegion  region;
-
-  region = XFixesCreateRegion (xdisplay, NULL, 0);
-
-  XFixesSetWindowShapeRegion (xdisplay, xoverlay, ShapeBounding, 0, 0, 0);
-
-  XFixesSetWindowShapeRegion (xdisplay, xoverlay, ShapeInput, 0, 0, region);
-  XFixesSetWindowShapeRegion (xdisplay, xstage,   ShapeInput, 0, 0, region);
-
-  XFixesDestroyRegion (xdisplay, region);
-}
-
 static Window
 get_output_window (MetaScreen *screen)
 {
@@ -1828,6 +1813,19 @@ mutter_get_windows (MetaScreen *screen)
   return info->windows;
 }
 
+static void
+do_set_stage_input_region (MetaScreen *screen,
+                           XserverRegion region)
+{
+  MetaCompScreen *info = meta_screen_get_compositor_data (screen);
+  MetaDisplay *display = meta_screen_get_display (screen);
+  Display        *xdpy = meta_display_get_xdisplay (display);
+  Window        xstage = clutter_x11_get_stage_window (CLUTTER_STAGE (info->stage));
+
+  XFixesSetWindowShapeRegion (xdpy, xstage, ShapeInput, 0, 0, region);
+  XFixesSetWindowShapeRegion (xdpy, info->output, ShapeInput, 0, 0, region);
+}
+
 void
 mutter_set_stage_input_region (MetaScreen *screen,
                                XserverRegion region)
@@ -1838,16 +1836,23 @@ mutter_set_stage_input_region (MetaScreen *screen,
 
   if (info->stage && info->output)
     {
-      Window xstage = clutter_x11_get_stage_window (CLUTTER_STAGE (info->stage));
-
-      XFixesSetWindowShapeRegion (xdpy, xstage, ShapeInput, 0, 0, region);
-      XFixesSetWindowShapeRegion (xdpy, info->output, ShapeInput, 0, 0, region);
+      do_set_stage_input_region (screen, region);
     }
-  else if (region != None)
+  else 
     {
-      info->pending_input_region = XFixesCreateRegion (xdpy, NULL, 0);
-      XFixesCopyRegion (xdpy, info->pending_input_region, region);
-    }
+      /* Reset info->pending_input_region if one existed before and set the new
+       * one to use it later. */ 
+      if (info->pending_input_region)
+        {
+          XFixesDestroyRegion (xdpy, info->pending_input_region);
+          info->pending_input_region = None;
+        }
+      if (region != None)
+        {
+          info->pending_input_region = XFixesCreateRegion (xdpy, NULL, 0);
+          XFixesCopyRegion (xdpy, info->pending_input_region, region);
+        }
+    } 
 }
 
 void
@@ -1898,6 +1903,14 @@ clutter_cmp_manage_screen (MetaCompositor *compositor,
     }
 
   info = g_new0 (MetaCompScreen, 1);
+  /*
+   * We use an empty input region for Clutter as a default because that allows
+   * the user to interact with all the windows displayed on the screen.
+   * We have to initialize info->pending_input_region to an empty region explicitly, 
+   * because None value is used to mean that the whole screen is an input region.
+   */
+  info->pending_input_region = XFixesCreateRegion (xdisplay, NULL, 0);
+
   info->screen = screen;
 
   meta_screen_set_compositor_data (screen, info);
@@ -1962,11 +1975,19 @@ clutter_cmp_manage_screen (MetaCompositor *compositor,
   info->output = get_output_window (screen);
   XReparentWindow (xdisplay, xwin, info->output, 0, 0);
 
-  show_overlay_window (xdisplay, xwin, info->output);
-
+ /* Make sure there isn't any left-over output shape on the 
+  * overlay window by setting the whole screen to be an
+  * output region.
+  * 
+  * Note: there doesn't seem to be any real chance of that
+  *  because the X server will destroy the overlay window
+  *  when the last client using it exits.
+  */
+  XFixesSetWindowShapeRegion (xdisplay, info->output, ShapeBounding, 0, 0, None);
+
+  do_set_stage_input_region (screen, info->pending_input_region);
   if (info->pending_input_region != None)
     {
-      mutter_set_stage_input_region (screen, info->pending_input_region);
       XFixesDestroyRegion (xdisplay, info->pending_input_region);
       info->pending_input_region = None;
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]