diff options
-rw-r--r-- | libmate-desktop/mate-rr-labeler.c | 43 |
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); |