[gtk+/wip/carlosg/event-delivery: 24/24] gtkbutton: Make windowless



commit 05b8eb0778a2a16fa24f583730f5ff293a278339
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Mar 31 19:11:03 2017 +0200

    gtkbutton: Make windowless
    
    It is no longer necessary to receive events, so it's relatively straightforward
    now to drop.

 gtk/gtkbutton.c      |   91 ++++----------------------------------------------
 gtk/gtkcheckbutton.c |    5 ---
 2 files changed, 7 insertions(+), 89 deletions(-)
---
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index c2c4c1d..2b89ba0 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -119,10 +119,7 @@ static void gtk_button_get_property   (GObject            *object,
                                        GParamSpec         *pspec);
 static void gtk_button_screen_changed (GtkWidget          *widget,
                                       GdkScreen          *previous_screen);
-static void gtk_button_realize (GtkWidget * widget);
 static void gtk_button_unrealize (GtkWidget * widget);
-static void gtk_button_map (GtkWidget * widget);
-static void gtk_button_unmap (GtkWidget * widget);
 static void gtk_button_size_allocate (GtkWidget * widget,
                                      GtkAllocation * allocation);
 static void gtk_button_snapshot (GtkWidget * widget, GtkSnapshot *snapshot);
@@ -225,10 +222,7 @@ gtk_button_class_init (GtkButtonClass *klass)
 
   widget_class->measure = gtk_button_measure_;
   widget_class->screen_changed = gtk_button_screen_changed;
-  widget_class->realize = gtk_button_realize;
   widget_class->unrealize = gtk_button_unrealize;
-  widget_class->map = gtk_button_map;
-  widget_class->unmap = gtk_button_unmap;
   widget_class->size_allocate = gtk_button_size_allocate;
   widget_class->snapshot = gtk_button_snapshot;
   widget_class->grab_broken_event = gtk_button_grab_broken;
@@ -343,32 +337,28 @@ multipress_pressed_cb (GtkGestureMultiPress *gesture,
 static gboolean
 touch_release_in_button (GtkButton *button)
 {
-  GtkButtonPrivate *priv;
-  gint width, height;
+  GtkAllocation allocation;
   GdkEvent *event;
   gdouble x, y;
 
-  priv = button->priv;
   event = gtk_get_current_event ();
 
   if (!event)
     return FALSE;
 
-  if (event->type != GDK_TOUCH_END ||
-      event->touch.window != priv->event_window)
+  if (event->type != GDK_TOUCH_END)
     {
       gdk_event_free (event);
       return FALSE;
     }
 
   gdk_event_get_coords (event, &x, &y);
-  width = gdk_window_get_width (priv->event_window);
-  height = gdk_window_get_height (priv->event_window);
+  gtk_widget_get_allocation (GTK_WIDGET (button), &allocation);
 
   gdk_event_free (event);
 
-  if (x >= 0 && x <= width &&
-      y >= 0 && y <= height)
+  if (x >= 0 && x <= allocation.width &&
+      y >= 0 && y <= allocation.height)
     return TRUE;
 
   return FALSE;
@@ -776,23 +766,6 @@ gtk_button_get_relief (GtkButton *button)
 }
 
 static void
-gtk_button_realize (GtkWidget *widget)
-{
-  GtkButton *button = GTK_BUTTON (widget);
-  GtkButtonPrivate *priv = button->priv;
-  GtkAllocation allocation;
-
-  GTK_WIDGET_CLASS (gtk_button_parent_class)->realize (widget);
-
-  gtk_widget_get_allocation (widget, &allocation);
-
-  priv->event_window = gdk_window_new_input (gtk_widget_get_window (widget),
-                                             GDK_ALL_EVENTS_MASK,
-                                             &allocation);
-  gtk_widget_register_window (widget, priv->event_window);
-}
-
-static void
 gtk_button_unrealize (GtkWidget *widget)
 {
   GtkButton *button = GTK_BUTTON (widget);
@@ -801,44 +774,10 @@ gtk_button_unrealize (GtkWidget *widget)
   if (priv->activate_timeout)
     gtk_button_finish_activate (button, FALSE);
 
-  if (priv->event_window)
-    {
-      gtk_widget_unregister_window (widget, priv->event_window);
-      gdk_window_destroy (priv->event_window);
-      priv->event_window = NULL;
-    }
-
   GTK_WIDGET_CLASS (gtk_button_parent_class)->unrealize (widget);
 }
 
 static void
-gtk_button_map (GtkWidget *widget)
-{
-  GtkButton *button = GTK_BUTTON (widget);
-  GtkButtonPrivate *priv = button->priv;
-
-  GTK_WIDGET_CLASS (gtk_button_parent_class)->map (widget);
-
-  if (priv->event_window)
-    gdk_window_show (priv->event_window);
-}
-
-static void
-gtk_button_unmap (GtkWidget *widget)
-{
-  GtkButton *button = GTK_BUTTON (widget);
-  GtkButtonPrivate *priv = button->priv;
-
-  if (priv->event_window)
-    {
-      gdk_window_hide (priv->event_window);
-      priv->in_button = FALSE;
-    }
-
-  GTK_WIDGET_CLASS (gtk_button_parent_class)->unmap (widget);
-}
-
-static void
 gtk_button_size_allocate (GtkWidget     *widget,
                          GtkAllocation *allocation)
 {
@@ -871,17 +810,6 @@ gtk_button_allocate (GtkCssGadget        *gadget,
   if (child && gtk_widget_get_visible (child))
     gtk_widget_size_allocate_with_baseline (child, (GtkAllocation *)allocation, baseline);
 
-  if (gtk_widget_get_realized (widget))
-    {
-      GtkAllocation border_allocation;
-      gtk_css_gadget_get_border_allocation (gadget, &border_allocation, NULL);
-      gdk_window_move_resize (GTK_BUTTON (widget)->priv->event_window,
-                              border_allocation.x,
-                              border_allocation.y,
-                              border_allocation.width,
-                              border_allocation.height);
-    }
-
   gtk_container_get_children_clip (GTK_CONTAINER (widget), out_clip);
 }
 
@@ -1021,13 +949,8 @@ gtk_real_button_activate (GtkButton *button)
        */
       if (device && gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
        {
-          if (gdk_seat_grab (gdk_device_get_seat (device), priv->event_window,
-                             GDK_SEAT_CAPABILITY_KEYBOARD, TRUE,
-                             NULL, NULL, NULL, NULL) == GDK_GRAB_SUCCESS)
-            {
-              gtk_device_grab_add (widget, device, TRUE);
-              priv->grab_keyboard = device;
-           }
+          gtk_device_grab_add (widget, device, TRUE);
+          priv->grab_keyboard = device;
        }
 
       priv->activate_timeout = gdk_threads_add_timeout (ACTIVATE_TIMEOUT,
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index 66f597b..2e5ba0c 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -444,11 +444,6 @@ gtk_check_button_size_allocate (GtkWidget     *widget,
     {
       GtkAllocation border_allocation;
       gtk_css_gadget_get_border_allocation (gadget, &border_allocation, NULL);
-      gdk_window_move_resize (GTK_BUTTON (widget)->priv->event_window,
-                              border_allocation.x,
-                              border_allocation.y,
-                              border_allocation.width,
-                              border_allocation.height);
     }
 }
 


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