]> git.pld-linux.org Git - packages/rdesktop.git/blob - rdesktop-xinerama.patch
- adapterized
[packages/rdesktop.git] / rdesktop-xinerama.patch
1 --- rdesktop/configure.ac
2 +++ rdesktop/configure.ac
3 @@ -30,6 +30,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 --- rdesktop/xwin.c
13 +++ rdesktop/xwin.c
14 @@ -31,6 +31,9 @@
15  #ifdef HAVE_XRANDR
16  #include <X11/extensions/Xrandr.h>
17  #endif
18 +#ifdef HAVE_XINERAMA
19 +#include <X11/extensions/Xinerama.h>
20 +#endif
21  
22  extern int g_sizeopt;
23  extern int g_width;
24 @@ -816,6 +819,66 @@
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 +void
30 +ScreenSize(XRectangle *screen)
31 +{
32 +       int screens;
33 +       int event_base;
34 +       int error_base;
35 +       int x, y, i, __unused_int;
36 +       unsigned int __unused_uint;
37 +       Window __unused_win;
38 +
39 +       if ((XineramaQueryExtension(g_display, &event_base, &error_base)) && (XineramaIsActive(g_display)))
40 +       {
41 +               XineramaScreenInfo *screeninfo;
42 +
43 +               /* getting current cursor position */
44 +               XQueryPointer(g_display, RootWindowOfScreen(g_screen), &__unused_win, &__unused_win, &x, &y, &__unused_int, &__unused_int, &__unused_uint);
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 <= x
52 +                       && screeninfo[i].y_org <= y
53 +                       && screeninfo[i].x_org + screeninfo[i].width >= x
54 +                       && screeninfo[i].y_org + screeninfo[i].height >= y ))
55 +                       i++;
56 +               if (i >= screens)
57 +                       i = 0;
58 +
59 +               /* Position according to the present screen */
60 +               screen->x = screeninfo[i].x_org;
61 +               screen->y = screeninfo[i].y_org;
62 +               screen->width = screeninfo[i].width;
63 +               screen->height = screeninfo[i].height;
64 +
65 +               /* Free allocated memory */
66 +               XFree(screeninfo);
67 +       }
68 +       else
69 +       {
70 +               /* Xinerama is not in use, default to the XLib screensize call. */
71 +               screen->x = 0;
72 +               screen->y = 0;
73 +               screen->width = WidthOfScreen(g_screen);
74 +               screen->height = HeightOfScreen(g_screen);
75 +       }
76 +}
77 +#else
78 +void
79 +ScreenSize(XRectangle *screen)
80 +{
81 +       screen->x = 0;
82 +       screen->y = 0;
83 +       screen->width = WidthOfScreen(g_screen);
84 +       screen->height = HeightOfScreen(g_screen);
85 +}
86 +#endif
87 +
88  static uint32
89  translate_colour(uint32 colour)
90  {
91 @@ -1912,17 +1975,26 @@
92          */
93         if (g_fullscreen)
94         {
95 -               g_width = WidthOfScreen(g_screen);
96 -               g_height = HeightOfScreen(g_screen);
97 +               XRectangle screen;
98 +               ScreenSize(&screen);
99 +
100 +               g_width = screen.width;
101 +               g_height = screen.height;
102                 g_using_full_workarea = True;
103         }
104         else if (g_sizeopt < 0)
105         {
106 +               XRectangle screen;
107 +               ScreenSize(&screen);
108 +
109 +               g_width = screen.width;
110 +               g_height = screen.height;
111 +
112                 /* Percent of screen */
113                 if (-g_sizeopt >= 100)
114                         g_using_full_workarea = True;
115 -               g_height = HeightOfScreen(g_screen) * (-g_sizeopt) / 100;
116 -               g_width = WidthOfScreen(g_screen) * (-g_sizeopt) / 100;
117 +               g_width = screen.width * (-g_width) / 100;
118 +               g_height = screen.height * (-g_width) / 100;
119         }
120         else if (g_sizeopt == 1)
121         {
122 @@ -2005,14 +2077,19 @@
123         long input_mask, ic_input_mask;
124         XEvent xevent;
125  
126 -       wndwidth = g_fullscreen ? WidthOfScreen(g_screen) : g_width;
127 -       wndheight = g_fullscreen ? HeightOfScreen(g_screen) : g_height;
128 +       XRectangle screen;
129 +       ScreenSize(&screen);
130  
131 +       wndwidth = g_fullscreen ? screen.width : g_width;
132 +       wndheight = g_fullscreen ? screen.height : g_height;
133 +       g_xpos = g_fullscreen ? screen.x : g_xpos;
134 +       g_ypos = g_fullscreen ? screen.y : g_ypos;
135 +
136         /* Handle -x-y portion of geometry string */
137         if (g_xpos < 0 || (g_xpos == 0 && (g_pos & 2)))
138 -               g_xpos = WidthOfScreen(g_screen) + g_xpos - g_width;
139 +               g_xpos = screen.width + g_xpos - g_width;
140         if (g_ypos < 0 || (g_ypos == 0 && (g_pos & 4)))
141 -               g_ypos = HeightOfScreen(g_screen) + g_ypos - g_height;
142 +               g_ypos = screen.height + g_ypos - g_height;
143  
144         get_window_attribs(&attribs);
145  
This page took 0.510221 seconds and 3 git commands to generate.