]> git.pld-linux.org Git - packages/rdesktop.git/blame - rdesktop-xinerama.patch
- rel 5
[packages/rdesktop.git] / rdesktop-xinerama.patch
CommitLineData
e3229496 1--- configure.ac.orig 2008-06-25 23:22:27.000000000 +0200
2+++ configure.ac 2008-06-25 23:17:51.000000000 +0200
3@@ -18,6 +18,8 @@
4 AC_SEARCH_LIBS(socket, socket)
5 AC_SEARCH_LIBS(inet_aton, resolv)
6
7+AC_CHECK_LIB(Xinerama, XineramaQueryScreens, AC_DEFINE(HAVE_XINERAMA) LIBS="$LIBS -lXinerama", [], [])
8+
9 AC_CHECK_HEADER(sys/select.h, AC_DEFINE(HAVE_SYS_SELECT_H))
10 AC_CHECK_HEADER(sys/modem.h, AC_DEFINE(HAVE_SYS_MODEM_H))
11 AC_CHECK_HEADER(sys/filio.h, AC_DEFINE(HAVE_SYS_FILIO_H))
12--- xwin.c.orig 2008-06-25 23:50:02.000000000 +0200
13+++ xwin.c 2008-06-25 23:49:25.000000000 +0200
14@@ -21,6 +21,9 @@
15
16 #include <X11/Xlib.h>
17 #include <X11/Xutil.h>
18+#ifdef HAVE_XINERAMA
19+ #include <X11/extensions/Xinerama.h>
20+#endif
21 #include <X11/Xproto.h>
22 #include <unistd.h>
23 #include <sys/time.h>
24@@ -570,6 +573,71 @@
25 #define LOUT24(o, x) { *(o++) = x; *(o++) = x >> 8; *(o++) = x >> 16; }
26 #define LOUT32(o, x) { *(o++) = x; *(o++) = x >> 8; *(o++) = x >> 16; *(o++) = x >> 24; }
27
28+#ifdef HAVE_XINERAMA
29+// IF XINERAMA LIBRARY
30+
31+int g_last_wnd_pos_x;
32+int g_last_wnd_pos_y;
33+
34+void
35+ScreenSize(XRectangle *screen)
36+{
37+ int screens;
38+ int event_base;
39+ int error_base;
40+
41+ if (XineramaQueryExtension(g_display, &event_base, &error_base))
42+ {
43+ XineramaScreenInfo *screeninfo;
44+ int i;
45+
46+ /* Get the Xinerama screen infomation. */
47+ screeninfo = XineramaQueryScreens(g_display, &screens);
48+
49+ /* Search for the appropriate screen. */
50+ i = 0;
51+ while (!(screeninfo[i].x_org <= g_last_wnd_pos_x
52+ && screeninfo[i].y_org <= g_last_wnd_pos_y
53+ && screeninfo[i].x_org + screeninfo[i].width >= g_last_wnd_pos_x
54+ && screeninfo[i].y_org + screeninfo[i].height >= g_last_wnd_pos_y ))
55+ {
56+ i++;
57+ }
58+ if (i >= screens) i = 0;
59+
60+ /* Position according to the present screen. */
61+ screen->x = screeninfo[i].x_org;
62+ screen->y = screeninfo[i].y_org;
63+ screen->width = screeninfo[i].width;
64+ screen->height = screeninfo[i].height;
65+
66+ /* Free allocated memory. */
67+ XFree(screeninfo);
68+ }
69+ else
70+ {
71+ /* Xinerama is not in use, default to the XLib screensize call. */
72+ screen->x = 0;
73+ screen->y = 0;
74+ screen->width = WidthOfScreen(g_screen);
75+ screen->height = HeightOfScreen(g_screen);
76+ }
77+}
78+
79+#else
80+// IF NO XINERAMA LIBRARY
81+
82+void
83+ScreenSize(XRectangle *screen)
84+{
85+ screen->x = 0;
86+ screen->y = 0;
87+ screen->width = WidthOfScreen(g_screen);
88+ screen->height = HeightOfScreen(g_screen);
89+}
90+
91+#endif
92+
93 static uint32
94 translate_colour(uint32 colour)
95 {
96@@ -1615,17 +1683,26 @@
97 */
98 if (g_fullscreen)
99 {
100- g_width = WidthOfScreen(g_screen);
101- g_height = HeightOfScreen(g_screen);
102+ XRectangle screen;
103+ ScreenSize(&screen);
104+
105+ g_width = screen.width;
106+ g_height = screen.height;
107 g_using_full_workarea = True;
108 }
109 else if (g_width < 0)
110 {
111+ XRectangle screen;
112+ ScreenSize(&screen);
113+
114+ g_width = screen.width;
115+ g_height = screen.height;
116+
117 /* Percent of screen */
118 if (-g_width >= 100)
119 g_using_full_workarea = True;
120- g_height = HeightOfScreen(g_screen) * (-g_width) / 100;
121- g_width = WidthOfScreen(g_screen) * (-g_width) / 100;
122+ g_width = screen.width * (-g_width) / 100;
123+ g_height = screen.height * (-g_width) / 100;
124 }
125 else if (g_width == 0)
126 {
127@@ -1734,14 +1811,19 @@
128 long input_mask, ic_input_mask;
129 XEvent xevent;
130
131- wndwidth = g_fullscreen ? WidthOfScreen(g_screen) : g_width;
132- wndheight = g_fullscreen ? HeightOfScreen(g_screen) : g_height;
133+ XRectangle screen;
134+
135+ ScreenSize(&screen);
136+ wndwidth = g_fullscreen ? screen.width : g_width;
137+ wndheight = g_fullscreen ? screen.height : g_height;
138+ g_xpos = g_fullscreen ? screen.x : g_xpos;
139+ g_ypos = g_fullscreen ? screen.y : g_ypos;
140
141 /* Handle -x-y portion of geometry string */
142 if (g_xpos < 0 || (g_xpos == 0 && (g_pos & 2)))
143- g_xpos = WidthOfScreen(g_screen) + g_xpos - g_width;
144+ g_xpos = screen.width + g_xpos - g_width;
145 if (g_ypos < 0 || (g_ypos == 0 && (g_pos & 4)))
146- g_ypos = HeightOfScreen(g_screen) + g_ypos - g_height;
147+ g_ypos = screen.height + g_ypos - g_height;
148
149 get_window_attribs(&attribs);
150
151@@ -1882,6 +1964,11 @@
152 void
153 xwin_toggle_fullscreen(void)
154 {
155+#ifdef HAVE_XINERAMA
156+ Window root, parent, *children;
157+ unsigned int nchildren;
158+ XWindowAttributes win_attrib;
159+#endif
160 Pixmap contents = 0;
161
162 if (g_seamless_active)
163@@ -1895,6 +1982,17 @@
164 XCopyArea(g_display, g_wnd, contents, g_gc, 0, 0, g_width, g_height, 0, 0);
165 }
166
167+#ifdef HAVE_XINERAMA
168+ /* Determine the parent window. */
169+ XQueryTree(g_display, g_wnd, &root, &parent, &children, &nchildren);
170+ if (children != NULL) XFree(children);
171+
172+ /* Find the present coordinates of the window. */
173+ XGetWindowAttributes(g_display, parent, &win_attrib);
174+ g_last_wnd_pos_x = win_attrib.x + 1;
175+ g_last_wnd_pos_y = win_attrib.y + 1;
176+#endif
177+
178 ui_destroy_window();
179 g_fullscreen = !g_fullscreen;
180 ui_create_window();
This page took 0.06766 seconds and 4 git commands to generate.