[gtk/abolish-size-allocate: 14/17] tooltip: Add private api to allocate the window



commit 1f0024a7f03510b66ebba15f2a5f51880a9fb549
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed May 6 13:56:27 2020 -0400

    tooltip: Add private api to allocate the window
    
    Add private gtk_tooltip_maybe_allocate() function
    and use it from GtkWindow and GtkPopover.
    
    This will let us stop using the ::size-allocate signal,
    without having to redo all the tooltip management first.
    
    That will happen later.

 gtk/gtkpopover.c        |  3 +++
 gtk/gtktooltip.c        | 13 +++++++++++++
 gtk/gtktooltipprivate.h |  3 +++
 gtk/gtkwindow.c         |  3 +++
 4 files changed, 22 insertions(+)
---
diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c
index 6ffc7f7126..7b21e2b725 100644
--- a/gtk/gtkpopover.c
+++ b/gtk/gtkpopover.c
@@ -122,6 +122,7 @@
 #include "gtksnapshot.h"
 #include "gtkshortcutmanager.h"
 #include "gtkbuildable.h"
+#include "gtktooltipprivate.h"
 
 #include "gtkrender.h"
 #include "gtkstylecontextprivate.h"
@@ -1417,6 +1418,8 @@ gtk_popover_size_allocate (GtkWidget *widget,
       gtk_popover_update_shape (popover);
       g_clear_pointer (&priv->arrow_render_node, gsk_render_node_unref);
     }
+
+  gtk_tooltip_maybe_allocate (GTK_NATIVE (popover));
 }
 
 static void
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index f611b4f562..fc9e665444 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -977,3 +977,16 @@ gtk_tooltip_handle_event_internal (GdkEventType   event_type,
        break;
     }
 }
+
+void
+gtk_tooltip_maybe_allocate (GtkNative *native)
+{
+  GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (native));
+  GtkTooltip *tooltip;
+
+  tooltip = g_object_get_qdata (G_OBJECT (display), quark_current_tooltip);
+  if (!tooltip || GTK_NATIVE (tooltip->native) != native)
+    return;
+
+  gtk_native_check_resize (GTK_NATIVE (tooltip->window));
+}
diff --git a/gtk/gtktooltipprivate.h b/gtk/gtktooltipprivate.h
index 5a050da199..ca63406b2c 100644
--- a/gtk/gtktooltipprivate.h
+++ b/gtk/gtktooltipprivate.h
@@ -27,6 +27,7 @@
 
 
 #include <gtk/gtktooltip.h>
+#include <gtk/gtknative.h>
 
 
 G_BEGIN_DECLS
@@ -42,6 +43,8 @@ GtkWidget * _gtk_widget_find_at_coords   (GdkSurface         *surface,
                                           gint               *widget_x,
                                           gint               *widget_y);
 
+void gtk_tooltip_maybe_allocate          (GtkNative          *native);
+
 G_END_DECLS
 
 
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 471fcc8738..bc79bd3d28 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -70,6 +70,7 @@
 #include "gtkwindowgroup.h"
 #include "gtkpopovermenubarprivate.h"
 #include "gtkcssboxesimplprivate.h"
+#include "gtktooltipprivate.h"
 
 #include "a11y/gtkwindowaccessibleprivate.h"
 #include "a11y/gtkcontaineraccessibleprivate.h"
@@ -5076,6 +5077,8 @@ gtk_window_size_allocate (GtkWidget *widget,
 
   if (child && gtk_widget_get_visible (child))
     gtk_widget_size_allocate (child, &child_allocation, -1);
+
+  gtk_tooltip_maybe_allocate (GTK_NATIVE (widget));
 }
 
 gboolean


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