[gtk+/wip/im-osk-position: 3/6] widget: Add API to request/unset the area to be covered by an OSK



commit 92a670df866f083026d9e91c0d9d79db3a6c1a9a
Author: Carlos Garnacho <carlos lanedo com>
Date:   Wed Jun 27 15:47:01 2012 +0200

    widget: Add API to request/unset the area to be covered by an OSK
    
    The requests are emitted by the focus widget controlled by an GtkIMContext,
    and spread up the hierarchy till the toplevel. whenever a widget handles
    the request, emission is stopped, being that same widget responsible of
    handling the unset request.

 gtk/gtkwidget.c |   72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gtk/gtkwidget.h |    5 ++++
 2 files changed, 77 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 14b53ed..0056544 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -481,6 +481,8 @@ enum {
   DRAG_FAILED,
   STYLE_UPDATED,
   TOUCH_EVENT,
+  REQUEST_CLEAR_AREA,
+  UNSET_CLEAR_AREA,
   LAST_SIGNAL
 };
 
@@ -3111,6 +3113,23 @@ gtk_widget_class_init (GtkWidgetClass *klass)
 		  _gtk_marshal_BOOLEAN__UINT,
                   G_TYPE_BOOLEAN, 1, G_TYPE_UINT);
 
+  widget_signals[REQUEST_CLEAR_AREA] =
+    g_signal_new (I_("request-clear-area"),
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_LAST, 0,
+                  g_signal_accumulator_true_handled, NULL,
+                  _gtk_marshal_BOOLEAN__BOXED_BOXED,
+                  G_TYPE_BOOLEAN, 2,
+                  CAIRO_GOBJECT_TYPE_RECTANGLE_INT,
+                  CAIRO_GOBJECT_TYPE_RECTANGLE_INT);
+  widget_signals[UNSET_CLEAR_AREA] =
+    g_signal_new (I_("unset-clear-area"),
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_LAST, 0,
+                  g_signal_accumulator_true_handled, NULL,
+                  _gtk_marshal_BOOLEAN__BOOLEAN,
+                  G_TYPE_BOOLEAN, 1, G_TYPE_BOOLEAN);
+
   binding_set = gtk_binding_set_by_class (klass);
   gtk_binding_entry_add_signal (binding_set, GDK_KEY_F10, GDK_SHIFT_MASK,
                                 "popup-menu", 0);
@@ -14072,3 +14091,56 @@ _gtk_widget_set_style (GtkWidget *widget,
 {
   widget->priv->style = style;
 }
+
+gboolean
+gtk_widget_request_clear_area (GtkWidget             *widget,
+                               cairo_rectangle_int_t *clear_area,
+			       cairo_rectangle_int_t *cursor_position)
+{
+  gboolean handled = FALSE;
+  GtkWidget *cur;
+
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+  g_return_val_if_fail (cursor_position != NULL, FALSE);
+  g_return_val_if_fail (clear_area != NULL, FALSE);
+
+  if (cursor_position->x < clear_area->x - cursor_position->width ||
+      cursor_position->x >= clear_area->x + clear_area->width ||
+      cursor_position->y < clear_area->y - cursor_position->height ||
+      cursor_position->y >= clear_area->y + clear_area->height)
+    return FALSE;
+
+  cur = widget;
+
+  while (!handled && cur)
+    {
+      g_signal_emit (cur, widget_signals[REQUEST_CLEAR_AREA], 0,
+                     cursor_position, clear_area, &handled);
+
+      if (!handled)
+        cur = gtk_widget_get_parent (cur);
+    }
+
+  return handled;
+}
+
+gboolean
+gtk_widget_unset_clear_area (GtkWidget *widget,
+                             gboolean   snap_back)
+{
+  gboolean handled = FALSE;
+  GtkWidget *cur;
+
+  cur = widget;
+
+  while (!handled && cur)
+    {
+      g_signal_emit (cur, widget_signals[UNSET_CLEAR_AREA], 0,
+                     snap_back, &handled);
+
+      if (!handled)
+        cur = gtk_widget_get_parent (cur);
+    }
+
+  return handled;
+}
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 576d7e9..6f4c442 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -886,6 +886,11 @@ GDK_AVAILABLE_IN_3_4
 GdkModifierType   gtk_widget_get_modifier_mask (GtkWidget         *widget,
                                                 GdkModifierIntent  intent);
 
+gboolean gtk_widget_request_clear_area (GtkWidget             *widget,
+                                        cairo_rectangle_int_t *clear_area,
+                                        cairo_rectangle_int_t *cursor_position);
+gboolean gtk_widget_unset_clear_area   (GtkWidget             *widget,
+                                        gboolean               snap_back);
 
 G_END_DECLS
 



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