5 |
http://www.freedesktop.org/standards/wm-spec.html |
http://www.freedesktop.org/standards/wm-spec.html |
6 |
|
|
7 |
Copyright (C) Matthew Chapman 1999-2002 |
Copyright (C) Matthew Chapman 1999-2002 |
8 |
|
Copyright (C) Peter Astrand <peter@cendio.se> 2003 |
9 |
|
|
10 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
11 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
22 |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
23 |
*/ |
*/ |
24 |
|
|
|
#include "rdesktop.h" |
|
25 |
#include <X11/Xlib.h> |
#include <X11/Xlib.h> |
26 |
|
#include "rdesktop.h" |
27 |
|
|
28 |
extern Display *display; |
extern Display *g_display; |
29 |
|
|
30 |
/* |
/* |
31 |
Get window property value (32 bit format) |
Get window property value (32 bit format) |
41 |
int actual_format_return; |
int actual_format_return; |
42 |
unsigned long bytes_after_return; |
unsigned long bytes_after_return; |
43 |
|
|
44 |
property = XInternAtom(display, propname, True); |
property = XInternAtom(g_display, propname, True); |
45 |
if (property == None) |
if (property == None) |
46 |
{ |
{ |
47 |
fprintf(stderr, "Atom %s does not exist\n", propname); |
fprintf(stderr, "Atom %s does not exist\n", propname); |
48 |
return (-1); |
return (-1); |
49 |
} |
} |
50 |
|
|
51 |
result = XGetWindowProperty(display, DefaultRootWindow(display), property, 0, /* long_offset */ |
result = XGetWindowProperty(g_display, DefaultRootWindow(g_display), property, 0, /* long_offset */ |
52 |
max_length, /* long_length */ |
max_length, /* long_length */ |
53 |
False, /* delete */ |
False, /* delete */ |
54 |
AnyPropertyType, /* req_type */ |
AnyPropertyType, /* req_type */ |
88 |
Returns -1 on error |
Returns -1 on error |
89 |
*/ |
*/ |
90 |
static int |
static int |
91 |
get_current_desktop() |
get_current_desktop(void) |
92 |
{ |
{ |
93 |
unsigned long nitems_return; |
unsigned long nitems_return; |
94 |
uint32 *prop_return; |
unsigned char *prop_return; |
95 |
int current_desktop; |
int current_desktop; |
96 |
|
|
97 |
if (get_property_value("_NET_CURRENT_DESKTOP", 1, &nitems_return, |
if (get_property_value("_NET_CURRENT_DESKTOP", 1, &nitems_return, |
98 |
(unsigned char **) &prop_return) < 0) |
&prop_return) < 0) |
99 |
return (-1); |
return (-1); |
100 |
|
|
101 |
if (nitems_return != 1) |
if (nitems_return != 1) |
119 |
{ |
{ |
120 |
int current_desktop; |
int current_desktop; |
121 |
unsigned long nitems_return; |
unsigned long nitems_return; |
122 |
uint32 *prop_return; |
unsigned char *prop_return; |
123 |
|
uint32 *return_words; |
124 |
const uint32 net_workarea_x_offset = 0; |
const uint32 net_workarea_x_offset = 0; |
125 |
const uint32 net_workarea_y_offset = 1; |
const uint32 net_workarea_y_offset = 1; |
126 |
const uint32 net_workarea_width_offset = 2; |
const uint32 net_workarea_width_offset = 2; |
128 |
const uint32 max_prop_length = 32 * 4; /* Max 32 desktops */ |
const uint32 max_prop_length = 32 * 4; /* Max 32 desktops */ |
129 |
|
|
130 |
if (get_property_value("_NET_WORKAREA", max_prop_length, &nitems_return, |
if (get_property_value("_NET_WORKAREA", max_prop_length, &nitems_return, |
131 |
(unsigned char **) &prop_return) < 0) |
&prop_return) < 0) |
132 |
return (-1); |
return (-1); |
133 |
|
|
134 |
if (nitems_return % 4) |
if (nitems_return % 4) |
142 |
if (current_desktop < 0) |
if (current_desktop < 0) |
143 |
return -1; |
return -1; |
144 |
|
|
145 |
*x = prop_return[current_desktop * 4 + net_workarea_x_offset]; |
return_words = (uint32 *)prop_return; |
146 |
*y = prop_return[current_desktop * 4 + net_workarea_y_offset]; |
|
147 |
*width = prop_return[current_desktop * 4 + net_workarea_width_offset]; |
*x = return_words[current_desktop * 4 + net_workarea_x_offset]; |
148 |
*height = prop_return[current_desktop * 4 + net_workarea_height_offset]; |
*y = return_words[current_desktop * 4 + net_workarea_y_offset]; |
149 |
|
*width = return_words[current_desktop * 4 + net_workarea_width_offset]; |
150 |
|
*height = return_words[current_desktop * 4 + net_workarea_height_offset]; |
151 |
|
|
152 |
XFree(prop_return); |
XFree(prop_return); |
153 |
|
|