[gtk+/client-side-decorations: 5/50] fixes for sizing
- From: Cody Russell <bratsche src gnome org>
- To: svn-commits-list gnome org
- Subject: [gtk+/client-side-decorations: 5/50] fixes for sizing
- Date: Wed, 8 Jul 2009 15:28:34 +0000 (UTC)
commit e3c076aaf4dbbdbe3002f1e0466d343f7485431b
Author: Cody Russell <crussell canonical com>
Date: Sat May 16 19:25:08 2009 -0400
fixes for sizing
gtk/gtkwindow-decorate.c | 6 +++
gtk/gtkwindow.c | 77 +++++++++++++++++++++++++++------------------
2 files changed, 52 insertions(+), 31 deletions(-)
---
diff --git a/gtk/gtkwindow-decorate.c b/gtk/gtkwindow-decorate.c
index 2fbe002..0ebbc65 100644
--- a/gtk/gtkwindow-decorate.c
+++ b/gtk/gtkwindow-decorate.c
@@ -206,6 +206,9 @@ gtk_decorated_window_get_box (GtkWindow *window)
deco = get_decoration (window);
+ if (!deco || !deco->hbox)
+ return NULL;
+
return deco->hbox;
}
@@ -230,6 +233,9 @@ gtk_decorated_window_calculate_frame_size (GtkWindow *window)
GtkWindowDecoration *deco = get_decoration (window);
gint border_left, border_top, border_right, border_bottom;
+ if (!deco)
+ return;
+
decorations = gtk_window_get_client_side_decorations (window);
if (!decorations)
{
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 2ee012e..f63101a 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -38,6 +38,7 @@
#include "gtkrc.h"
#include "gtkwindow.h"
#include "gtkwindow-decorate.h"
+#include "gtklabel.h"
#include "gtkbindings.h"
#include "gtkkeyhash.h"
#include "gtkmain.h"
@@ -194,6 +195,8 @@ struct _GtkWindowPrivate
gdouble opacity;
gchar *startup_id;
+
+ GtkWidget *title_label;
};
static void gtk_window_dispose (GObject *object);
@@ -964,10 +967,10 @@ gtk_window_init (GtkWindow *window)
window->modal = FALSE;
window->frame = NULL;
window->has_frame = FALSE;
- window->frame_left = 0;
- window->frame_right = 0;
- window->frame_top = 0;
- window->frame_bottom = 0;
+ window->frame_left = 6;
+ window->frame_right = 6;
+ window->frame_top = 24;
+ window->frame_bottom = 6;
window->type_hint = GDK_WINDOW_TYPE_HINT_NORMAL;
window->gravity = GDK_GRAVITY_NORTH_WEST;
window->decorated = TRUE;
@@ -996,8 +999,6 @@ gtk_window_init (GtkWindow *window)
window->has_user_ref_count = TRUE;
toplevel_list = g_slist_prepend (toplevel_list, window);
- gtk_decorated_window_init (window);
-
g_signal_connect (window->screen, "composited-changed",
G_CALLBACK (gtk_window_on_composited_changed), window);
}
@@ -1425,9 +1426,12 @@ gtk_window_set_title (GtkWindow *window,
const gchar *title)
{
char *new_title;
-
+ GtkWindowPrivate *priv;
+
g_return_if_fail (GTK_IS_WINDOW (window));
+ priv = GTK_WINDOW_GET_PRIVATE (window);
+
new_title = g_strdup (title);
g_free (window->title);
window->title = new_title;
@@ -1437,6 +1441,7 @@ gtk_window_set_title (GtkWindow *window,
gdk_window_set_title (GTK_WIDGET (window)->window, window->title);
gtk_decorated_window_set_title (window, title);
+ gtk_label_set_text (GTK_LABEL (priv->title_label), title);
}
g_object_notify (G_OBJECT (window), "title");
@@ -2951,13 +2956,11 @@ gtk_window_set_decorated (GtkWindow *window,
{
if (window->decorated && !priv->client_side_decorations)
{
- g_print ("gdk_window_set_decorations (GDK_DECOR_ALL)\n");
gdk_window_set_decorations (GTK_WIDGET (window)->window,
GDK_DECOR_ALL);
}
else
{
- g_print ("gdk_window_set_decorations (0)\n");
gdk_window_set_decorations (GTK_WIDGET (window)->window,
0);
}
@@ -4841,6 +4844,7 @@ gtk_window_realize (GtkWidget *widget)
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
+#if 0
if (window->has_frame)
{
attributes.width = widget->allocation.width + window->frame_left + window->frame_right;
@@ -4888,7 +4892,11 @@ gtk_window_realize (GtkWidget *widget)
attributes_mask = 0;
parent_window = gtk_widget_get_root_window (widget);
}
-
+#endif
+
+ attributes_mask = 0;
+ parent_window = gtk_widget_get_root_window (widget);
+
attributes.width = widget->allocation.width;
attributes.height = widget->allocation.height;
attributes.event_mask = gtk_widget_get_events (widget);
@@ -4899,8 +4907,13 @@ gtk_window_realize (GtkWidget *widget)
GDK_LEAVE_NOTIFY_MASK |
GDK_FOCUS_CHANGE_MASK |
GDK_STRUCTURE_MASK);
- if (priv->client_side_decorated)
- attributes.event_mask |= GDK_BUTTON_PRESS_MASK;
+ if (priv->client_side_decorated && window->type != GTK_WINDOW_POPUP)
+ {
+ attributes.event_mask |= GDK_BUTTON_PRESS_MASK;
+ attributes.width += window->frame_left + window->frame_right;
+ attributes.height += window->frame_top + window->frame_bottom;
+ }
+
attributes.type_hint = priv->type_hint;
attributes_mask |= GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_TYPE_HINT;
@@ -5024,12 +5037,10 @@ gtk_window_size_request (GtkWidget *widget,
{
GtkWindow *window;
GtkBin *bin;
- GtkWidget *decorated_hbox;
GtkRequisition child_requisition;
window = GTK_WINDOW (widget);
bin = GTK_BIN (window);
- decorated_hbox = gtk_decorated_window_get_box (window);
requisition->width = GTK_CONTAINER (window)->border_width * 2;
requisition->height = GTK_CONTAINER (window)->border_width * 2;
@@ -5048,24 +5059,38 @@ gtk_window_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkWindow *window;
+ GtkContainer *container;
GtkAllocation child_allocation;
GtkAllocation new_allocation;
GtkWidget *decorated_hbox = NULL;
GtkWindowPrivate *priv;
window = GTK_WINDOW (widget);
+ container = GTK_CONTAINER (widget);
widget->allocation = *allocation;
priv = GTK_WINDOW_GET_PRIVATE (window);
- decorated_hbox = gtk_decorated_window_get_box (window);
+ decorated_hbox = NULL; //gtk_decorated_window_get_box (window);
if (window->bin.child && GTK_WIDGET_VISIBLE (window->bin.child))
{
- child_allocation.x = GTK_CONTAINER (window)->border_width;
- child_allocation.y = GTK_CONTAINER (window)->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);
+ if (priv->client_side_decorated && window->type != GTK_WINDOW_POPUP)
+ {
+ child_allocation.x = container->border_width + window->frame_left;
+ child_allocation.y = container->border_width + window->frame_top;
+ child_allocation.width = MAX (1, (gint)allocation->width - container->border_width * 2
+ - window->frame_left - window->frame_right);
+ child_allocation.height = MAX (1, (gint)allocation->height - container->border_width * 2
+ - window->frame_top - window->frame_bottom);
+ }
+ else
+ {
+ child_allocation.x = GTK_CONTAINER (window)->border_width;
+ child_allocation.y = GTK_CONTAINER (window)->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);
+ }
gtk_widget_size_allocate (window->bin.child, &child_allocation);
}
@@ -5088,16 +5113,6 @@ gtk_window_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (decorated_hbox, &deco_allocation);
}
-
- if (GTK_WIDGET_REALIZED (widget) && window->frame)
- {
- if (window->frame)
- gdk_window_resize (window->frame,
- allocation->width + window->frame_left + window->frame_right,
- allocation->height + window->frame_top + window->frame_bottom);
-
- gdk_window_resize (widget->window, allocation->width, allocation->height);
- }
}
static gint
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]