[gnome-desktop] Properly get the workarea for positioning the labels
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-desktop] Properly get the workarea for positioning the labels
- Date: Thu, 10 Feb 2011 03:08:43 +0000 (UTC)
commit b4b3fbe614c245e5e2cc4ca431d0f5310eca6ed1
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Feb 9 22:08:02 2011 -0500
Properly get the workarea for positioning the labels
This fixes https://bugzilla.gnome.org/show_bug.cgi?id=641996
libgnome-desktop/gnome-rr-labeler.c | 43 +++++++++++++++++++++++++++++++---
1 files changed, 39 insertions(+), 4 deletions(-)
---
diff --git a/libgnome-desktop/gnome-rr-labeler.c b/libgnome-desktop/gnome-rr-labeler.c
index a5db10b..b316864 100644
--- a/libgnome-desktop/gnome-rr-labeler.c
+++ b/libgnome-desktop/gnome-rr-labeler.c
@@ -63,6 +63,38 @@ static void gnome_rr_labeler_finalize (GObject *object);
static void create_label_windows (GnomeRRLabeler *labeler);
static void setup_from_config (GnomeRRLabeler *labeler);
+static int
+get_current_desktop (GdkScreen *screen)
+{
+ Display *display;
+ Window win;
+ Atom current_desktop, type;
+ int format;
+ unsigned long n_items, bytes_after;
+ unsigned char *data_return = NULL;
+ int workspace = 0;
+
+ display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
+ win = XRootWindow (display, GDK_SCREEN_XNUMBER (screen));
+
+ current_desktop = XInternAtom (display, "_NET_CURRENT_DESKTOP", True);
+
+ XGetWindowProperty (display,
+ win,
+ current_desktop,
+ 0, G_MAXLONG,
+ False, XA_CARDINAL,
+ &type, &format, &n_items, &bytes_after,
+ &data_return);
+
+ if (type == XA_CARDINAL && format == 32 && n_items > 0)
+ workspace = (int) data_return[0];
+ if (data_return)
+ XFree (data_return);
+
+ return workspace;
+}
+
static gboolean
get_work_area (GnomeRRLabeler *labeler,
GdkRectangle *rect)
@@ -78,6 +110,7 @@ get_work_area (GnomeRRLabeler *labeler,
long *workareas;
int result;
int disp_screen;
+ int desktop;
Display *display;
display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (labeler->priv->screen));
@@ -116,11 +149,13 @@ get_work_area (GnomeRRLabeler *labeler,
return FALSE;
}
+ desktop = get_current_desktop (labeler->priv->screen);
+
workareas = (long *) ret_workarea;
- rect->x = workareas[disp_screen * 4];
- rect->y = workareas[disp_screen * 4 + 1];
- rect->width = workareas[disp_screen * 4 + 2];
- rect->height = workareas[disp_screen * 4 + 3];
+ rect->x = workareas[desktop * 4];
+ rect->y = workareas[desktop * 4 + 1];
+ rect->width = workareas[desktop * 4 + 2];
+ rect->height = workareas[desktop * 4 + 3];
XFree (ret_workarea);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]