[gnome-settings-daemon] media-keys: Always use the primary monitor for display
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] media-keys: Always use the primary monitor for display
- Date: Fri, 10 Jun 2011 13:27:14 +0000 (UTC)
commit e310a5445a4d2020359a4dd4105eb70fcae334bd
Author: Bastien Nocera <hadess hadess net>
Date: Fri Jun 10 14:25:42 2011 +0100
media-keys: Always use the primary monitor for display
And sizing. This means that the popup will have a constant
size on the primary monitor.
https://bugzilla.gnome.org/show_bug.cgi?id=650159
plugins/media-keys/gsd-media-keys-manager.c | 26 ++----------------------
plugins/media-keys/gsd-osd-window.c | 28 +++++++++++++++++---------
2 files changed, 21 insertions(+), 33 deletions(-)
---
diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c
index 21bc774..b2171d0 100644
--- a/plugins/media-keys/gsd-media-keys-manager.c
+++ b/plugins/media-keys/gsd-media-keys-manager.c
@@ -418,10 +418,7 @@ dialog_show (GsdMediaKeysManager *manager)
int screen_h;
int x;
int y;
- int pointer_x;
- int pointer_y;
GtkRequisition win_req;
- GdkScreen *pointer_screen;
GdkRectangle geometry;
int monitor;
@@ -436,29 +433,12 @@ dialog_show (GsdMediaKeysManager *manager)
gtk_window_get_default_size (GTK_WINDOW (manager->priv->dialog), &orig_w, &orig_h);
gtk_widget_size_request (manager->priv->dialog, &win_req);
- if (win_req.width > orig_w) {
+ if (win_req.width > orig_w)
orig_w = win_req.width;
- }
- if (win_req.height > orig_h) {
+ if (win_req.height > orig_h)
orig_h = win_req.height;
- }
- pointer_screen = NULL;
- gdk_display_get_pointer (gdk_screen_get_display (manager->priv->current_screen),
- &pointer_screen,
- &pointer_x,
- &pointer_y,
- NULL);
- if (pointer_screen != manager->priv->current_screen) {
- /* The pointer isn't on the current screen, so just
- * assume the default monitor
- */
- monitor = 0;
- } else {
- monitor = gdk_screen_get_monitor_at_point (manager->priv->current_screen,
- pointer_x,
- pointer_y);
- }
+ monitor = gdk_screen_get_primary_monitor (manager->priv->current_screen);
gdk_screen_get_monitor_geometry (manager->priv->current_screen,
monitor,
diff --git a/plugins/media-keys/gsd-osd-window.c b/plugins/media-keys/gsd-osd-window.c
index 60dfa11..cca85ff 100644
--- a/plugins/media-keys/gsd-osd-window.c
+++ b/plugins/media-keys/gsd-osd-window.c
@@ -56,6 +56,7 @@ struct GsdOsdWindowPrivate
gint screen_width;
gint screen_height;
+ gint monitor;
};
enum {
@@ -682,12 +683,17 @@ gboolean
gsd_osd_window_is_valid (GsdOsdWindow *window)
{
GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (window));
- gint width, height;
- width = gdk_screen_get_width (screen);
- height = gdk_screen_get_height (screen);
+ gint monitor;
+ GdkRectangle mon_rect;
- if (window->priv->screen_width != width ||
- window->priv->screen_height != height)
+ monitor = gdk_screen_get_primary_monitor (screen);
+ if (monitor != window->priv->monitor)
+ return FALSE;
+
+ gdk_screen_get_monitor_geometry (screen, monitor, &mon_rect);
+
+ if (window->priv->screen_width != mon_rect.width ||
+ window->priv->screen_height != mon_rect.height)
return FALSE;
return gdk_screen_is_composited (screen) == window->priv->is_composited;
@@ -698,6 +704,7 @@ gsd_osd_window_init (GsdOsdWindow *window)
{
GdkScreen *screen;
gdouble scalew, scaleh, scale;
+ GdkRectangle monitor;
gint size;
window->priv = GSD_OSD_WINDOW_GET_PRIVATE (window);
@@ -705,18 +712,19 @@ gsd_osd_window_init (GsdOsdWindow *window)
screen = gtk_widget_get_screen (GTK_WIDGET (window));
window->priv->is_composited = gdk_screen_is_composited (screen);
- window->priv->screen_width = gdk_screen_get_width (screen);
- window->priv->screen_height = gdk_screen_get_height (screen);
+ window->priv->monitor = gdk_screen_get_primary_monitor (screen);
+ gdk_screen_get_monitor_geometry (screen, window->priv->monitor, &monitor);
+ window->priv->screen_width = monitor.width;
+ window->priv->screen_height = monitor.height;
gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
/* assume 130x130 on a 640x480 display and scale from there */
- scalew = gdk_screen_get_width (screen) / 640.0;
- scaleh = gdk_screen_get_height (screen) / 480.0;
+ scalew = monitor.width / 640.0;
+ scaleh = monitor.height / 480.0;
scale = MIN (scalew, scaleh);
size = 130 * MAX (1, scale);
-
gtk_window_set_default_size (GTK_WINDOW (window), size, size);
window->priv->fade_out_alpha = 1.0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]