GtkApplicationWindow: Fix resize grip positioning
Based on a patch by Carlos Garcia Campos, bug 668248
This commit is contained in:
		@ -24,6 +24,7 @@
 | 
			
		||||
#include "gtkapplicationwindow.h"
 | 
			
		||||
 | 
			
		||||
#include "gtkapplicationprivate.h"
 | 
			
		||||
#include "gtkwindowprivate.h"
 | 
			
		||||
#include "gtkmodelmenu.h"
 | 
			
		||||
#include "gactionmuxer.h"
 | 
			
		||||
#include "gtkaccelgroup.h"
 | 
			
		||||
@ -635,7 +636,7 @@ gtk_application_window_real_size_allocate (GtkWidget     *widget,
 | 
			
		||||
      gint menubar_height;
 | 
			
		||||
      GtkWidget *child;
 | 
			
		||||
 | 
			
		||||
      gtk_widget_set_allocation (widget, allocation);
 | 
			
		||||
      _gtk_window_set_allocation (GTK_WINDOW (widget), allocation);
 | 
			
		||||
 | 
			
		||||
      gtk_widget_get_preferred_height_for_width (window->priv->menubar, allocation->width, &menubar_height, NULL);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -5530,21 +5530,30 @@ set_grip_position (GtkWindow *window)
 | 
			
		||||
                          rect.width, rect.height);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
gtk_window_size_allocate (GtkWidget     *widget,
 | 
			
		||||
/* _gtk_window_set_allocation:
 | 
			
		||||
 * @window: a #GtkWindow
 | 
			
		||||
 * @allocation: the new allocation
 | 
			
		||||
 *
 | 
			
		||||
 * This function is like gtk_widget_set_allocation()
 | 
			
		||||
 * but does the necessary extra work to update
 | 
			
		||||
 * the resize grip positioning, etc.
 | 
			
		||||
 *
 | 
			
		||||
 * Call this instead of gtk_widget_set_allocation()
 | 
			
		||||
 * when overriding ::size_allocate in a GtkWindow
 | 
			
		||||
 * subclass without chaining up.
 | 
			
		||||
 */
 | 
			
		||||
void
 | 
			
		||||
_gtk_window_set_allocation (GtkWindow     *window,
 | 
			
		||||
                            GtkAllocation *allocation)
 | 
			
		||||
{
 | 
			
		||||
  GtkWindow *window = GTK_WINDOW (widget);
 | 
			
		||||
  GtkAllocation child_allocation;
 | 
			
		||||
  GtkWidget *child;
 | 
			
		||||
  guint border_width;
 | 
			
		||||
  GtkWidget *widget = (GtkWidget *)window;
 | 
			
		||||
 | 
			
		||||
  gtk_widget_set_allocation (widget, allocation);
 | 
			
		||||
 | 
			
		||||
  if (gtk_widget_get_realized (widget))
 | 
			
		||||
    {
 | 
			
		||||
      /* If it's not a toplevel we're embedded, we need to resize the window's 
 | 
			
		||||
       * window and skip the grip.
 | 
			
		||||
      /* If it's not a toplevel we're embedded, we need to resize
 | 
			
		||||
       * the window's window and skip the grip.
 | 
			
		||||
       */
 | 
			
		||||
      if (!gtk_widget_is_toplevel (widget))
 | 
			
		||||
        {
 | 
			
		||||
@ -5558,6 +5567,18 @@ gtk_window_size_allocate (GtkWidget     *widget,
 | 
			
		||||
          set_grip_position (window);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
gtk_window_size_allocate (GtkWidget     *widget,
 | 
			
		||||
                          GtkAllocation *allocation)
 | 
			
		||||
{
 | 
			
		||||
  GtkWindow *window = GTK_WINDOW (widget);
 | 
			
		||||
  GtkAllocation child_allocation;
 | 
			
		||||
  GtkWidget *child;
 | 
			
		||||
  guint border_width;
 | 
			
		||||
 | 
			
		||||
  _gtk_window_set_allocation (window, allocation);
 | 
			
		||||
 | 
			
		||||
  child = gtk_bin_get_child (&(window->bin));
 | 
			
		||||
  if (child && gtk_widget_get_visible (child))
 | 
			
		||||
@ -5565,10 +5586,8 @@ gtk_window_size_allocate (GtkWidget     *widget,
 | 
			
		||||
      border_width = gtk_container_get_border_width (GTK_CONTAINER (window));
 | 
			
		||||
      child_allocation.x = border_width;
 | 
			
		||||
      child_allocation.y = border_width;
 | 
			
		||||
      child_allocation.width =
 | 
			
		||||
	MAX (1, (gint)allocation->width - child_allocation.x * 2);
 | 
			
		||||
      child_allocation.height =
 | 
			
		||||
	MAX (1, (gint)allocation->height - child_allocation.y * 2);
 | 
			
		||||
      child_allocation.width = MAX (1, allocation->width - border_width * 2);
 | 
			
		||||
      child_allocation.height = MAX (1, allocation->height - border_width * 2);
 | 
			
		||||
 | 
			
		||||
      gtk_widget_size_allocate (child, &child_allocation);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -68,6 +68,9 @@ void            _gtk_window_get_wmclass            (GtkWindow  *window,
 | 
			
		||||
                                                    gchar     **wmclass_name,
 | 
			
		||||
                                                    gchar     **wmclass_class);
 | 
			
		||||
 | 
			
		||||
void            _gtk_window_set_allocation         (GtkWindow     *window,
 | 
			
		||||
                                                    GtkAllocation *allocation);
 | 
			
		||||
 | 
			
		||||
typedef void (*GtkWindowKeysForeachFunc) (GtkWindow      *window,
 | 
			
		||||
                                          guint           keyval,
 | 
			
		||||
                                          GdkModifierType modifiers,
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user