[gdm] simple-greeter: Don't request an invalid size
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdm] simple-greeter: Don't request an invalid size
- Date: Mon, 13 Jun 2011 21:52:40 +0000 (UTC)
commit 9694ea8e7a179060e122bbf9890829321c7fedeb
Author: Benjamin Otte <otte redhat com>
Date: Sat Apr 2 04:10:09 2011 +0200
simple-greeter: Don't request an invalid size
GTK widgets must at all times report a size they can handle. So it is
not allowed to return 0 when not realized, because then size allocations
break when GTK uses this size for its widget.
In this case, GTK uses the pre-realize size to determine the size it
should request when creating the greeter window - chicken and egg so to
say.
This patch just uses the default monitor (I guess the root window's
monitor is the default monitor?) for determining the login window size.
One thing this patch doesn't do is add a call to gtk_widget_queue_resize()
from the realize callback or from monitor-changing signals, though
that's probably technically necessary.
https://bugzilla.gnome.org/show_bug.cgi?id=646498
gui/simple-greeter/gdm-greeter-login-window.c | 30 ++++++++++---------------
1 files changed, 12 insertions(+), 18 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-greeter-login-window.c b/gui/simple-greeter/gdm-greeter-login-window.c
index e323bc2..11f5469 100644
--- a/gui/simple-greeter/gdm-greeter-login-window.c
+++ b/gui/simple-greeter/gdm-greeter-login-window.c
@@ -1549,25 +1549,23 @@ gdm_greeter_login_window_get_preferred_width (GtkWidget *widget,
{
int monitor;
GdkScreen *screen;
+ GdkWindow *window;
GdkRectangle area;
GtkAllocation widget_allocation;
int min_size;
int nat_size;
- min_size = 0;
- nat_size = 0;
-
- if (!gtk_widget_get_realized (widget)) {
- goto out;
- }
-
gtk_widget_get_preferred_width (gtk_bin_get_child (GTK_BIN (widget)),
&min_size,
&nat_size);
/* Make width be at least 33% screen width */
screen = gtk_widget_get_screen (widget);
- monitor = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (widget));
+ window = gtk_widget_get_window (widget);
+ if (window == NULL) {
+ window = gdk_screen_get_root_window (screen);
+ }
+ monitor = gdk_screen_get_monitor_at_window (screen, window);
gdk_screen_get_monitor_geometry (screen, monitor, &area);
min_size = MAX (min_size, .33 * area.width);
nat_size = MAX (nat_size, .33 * area.width);
@@ -1578,7 +1576,6 @@ gdm_greeter_login_window_get_preferred_width (GtkWidget *widget,
min_size = MAX (min_size, widget_allocation.width);
nat_size = MAX (nat_size, widget_allocation.width);
- out:
if (minimum_size)
*minimum_size = min_size;
if (natural_size)
@@ -1592,29 +1589,26 @@ gdm_greeter_login_window_get_preferred_height (GtkWidget *widget,
{
int monitor;
GdkScreen *screen;
+ GdkWindow *window;
GdkRectangle area;
int min_size;
int nat_size;
- min_size = 0;
- nat_size = 0;
-
- if (!gtk_widget_get_realized (widget)) {
- goto out;
- }
-
gtk_widget_get_preferred_height (gtk_bin_get_child (GTK_BIN (widget)),
&min_size,
&nat_size);
/* Make height be at most 80% of screen height */
screen = gtk_widget_get_screen (widget);
- monitor = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (widget));
+ window = gtk_widget_get_window (widget);
+ if (window == NULL) {
+ window = gdk_screen_get_root_window (screen);
+ }
+ monitor = gdk_screen_get_monitor_at_window (screen, window);
gdk_screen_get_monitor_geometry (screen, monitor, &area);
min_size = MIN (min_size, .8 * area.height);
nat_size = MIN (nat_size, .8 * area.height);
- out:
if (minimum_size)
*minimum_size = min_size;
if (natural_size)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]