summaryrefslogtreecommitdiff
path: root/libmate-desktop/mate-rr-labeler.c
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-11-08 01:36:31 +0100
committerinfirit <[email protected]>2014-11-28 08:51:50 +0100
commitd9abcf8aa5902bdfce68c77dac560e7aac3af28f (patch)
tree7b5df90796db339b1348580f336a75b517c6e8ee /libmate-desktop/mate-rr-labeler.c
parent644beeec923fdf918512a4754fb4336e24550128 (diff)
downloadmate-desktop-d9abcf8aa5902bdfce68c77dac560e7aac3af28f.tar.bz2
mate-desktop-d9abcf8aa5902bdfce68c77dac560e7aac3af28f.tar.xz
Properly get the workarea for positioning the labels
Based on gnome-desktop commit: b4b3fbe614c245e5e2cc4ca431d0f5310eca6ed1 From: Matthias Clasen <[email protected]> Gnome bug: https://bugzilla.gnome.org/show_bug.cgi?id=641996
Diffstat (limited to 'libmate-desktop/mate-rr-labeler.c')
-rw-r--r--libmate-desktop/mate-rr-labeler.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/libmate-desktop/mate-rr-labeler.c b/libmate-desktop/mate-rr-labeler.c
index d498520..fa0db03 100644
--- a/libmate-desktop/mate-rr-labeler.c
+++ b/libmate-desktop/mate-rr-labeler.c
@@ -67,6 +67,38 @@ static void mate_rr_labeler_finalize (GObject *object);
static void create_label_windows (MateRRLabeler *labeler);
static void setup_from_config (MateRRLabeler *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 (MateRRLabeler *labeler,
GdkRectangle *rect)
@@ -82,6 +114,7 @@ get_work_area (MateRRLabeler *labeler,
long *workareas;
int result;
int disp_screen;
+ int desktop;
Display *display;
display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (labeler->priv->screen));
@@ -120,11 +153,13 @@ get_work_area (MateRRLabeler *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);