[gtk+/touch-selection-fixes: 2/3] texthandles: set input shape on	handles' window
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [gtk+/touch-selection-fixes: 2/3] texthandles: set input shape on	handles' window
- Date: Fri, 26 Oct 2012 16:36:31 +0000 (UTC)
commit 0eb09ac0f2d583dc72a9a2d3f1fec1f4188fd4b8
Author: Carlos Garnacho <carlos lanedo com>
Date:   Fri Oct 26 17:48:26 2012 +0200
    texthandles: set input shape on handles' window
    
    This improves both interaction and theming, as it allows
    arbitrary handle shapes while just being draggable from
    the visible areas.
    
    This way themes can set up handles with the hotspot visually
    displaced from the horizontal center, as long as the hotspot
    lies centered in the image/svg asset.
 gtk/gtktexthandle.c |   42 +++++++++++++++++++++++-------------------
 1 files changed, 23 insertions(+), 19 deletions(-)
---
diff --git a/gtk/gtktexthandle.c b/gtk/gtktexthandle.c
index a0d3ae2..3d06ee4 100644
--- a/gtk/gtktexthandle.c
+++ b/gtk/gtktexthandle.c
@@ -127,33 +127,33 @@ _gtk_text_handle_update_shape (GtkTextHandle         *handle,
                                GtkTextHandlePosition  pos)
 {
   GtkTextHandlePrivate *priv;
+  cairo_surface_t *surface;
+  cairo_region_t *region;
+  cairo_t *cr;
 
   priv = handle->priv;
 
+  surface =
+    gdk_window_create_similar_surface (window,
+                                       CAIRO_CONTENT_COLOR_ALPHA,
+                                       gdk_window_get_width (window),
+                                       gdk_window_get_height (window));
+
+  cr = cairo_create (surface);
+  _gtk_text_handle_draw (handle, cr, pos);
+  cairo_destroy (cr);
+
+  region = gdk_cairo_region_create_from_surface (surface);
+
   if (gtk_widget_is_composited (priv->parent))
     gdk_window_shape_combine_region (window, NULL, 0, 0);
   else
-    {
-      cairo_surface_t *surface;
-      cairo_region_t *region;
-      cairo_t *cr;
+    gdk_window_shape_combine_region (window, region, 0, 0);
 
-      surface =
-        gdk_window_create_similar_surface (window,
-                                           CAIRO_CONTENT_COLOR_ALPHA,
-                                           gdk_window_get_width (window),
-                                           gdk_window_get_height (window));
+  gdk_window_input_shape_combine_region (window, region, 0, 0);
 
-      cr = cairo_create (surface);
-      _gtk_text_handle_draw (handle, cr, pos);
-      cairo_destroy (cr);
-
-      region = gdk_cairo_region_create_from_surface (surface);
-      gdk_window_shape_combine_region (window, region, 0, 0);
-
-      cairo_surface_destroy (surface);
-      cairo_region_destroy (region);
-    }
+  cairo_surface_destroy (surface);
+  cairo_region_destroy (region);
 }
 
 static GdkWindow *
@@ -574,6 +574,10 @@ _gtk_text_handle_set_mode (GtkTextHandle     *handle,
     }
 
   priv->mode = mode;
+
+  _gtk_text_handle_update_shape (handle,
+                                 priv->windows[GTK_TEXT_HANDLE_POSITION_CURSOR].window,
+                                 GTK_TEXT_HANDLE_POSITION_CURSOR);
 }
 
 GtkTextHandleMode
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]