Nux

Merge lp:~smspillaz/nux/nux.fix_861341 into lp:nux

Proposed by Sam Spilsbury
Status: Merged
Merge reported by: Neil J. Patel
Merged at revision: not available
Proposed branch: lp:~smspillaz/nux/nux.fix_861341
Merge into: lp:nux
Diff against target: 162 lines (+68/-6)
6 files modified
NuxGraphics/GraphicsDisplayX11.cpp (+4/-0)
NuxGraphics/GraphicsDisplayX11.h (+2/-0)
NuxGraphics/XInputWindow.cpp (+59/-5)
NuxGraphics/XInputWindow.h (+1/-0)
NuxGraphics/nux-graphics.pc.in (+1/-1)
configure.ac (+1/-0)
To merge this branch: bzr merge lp:~smspillaz/nux/nux.fix_861341
Reviewer Review Type Date Requested Status
Jay Taoko (community) Approve
Review via email: mp+77318@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Jay Taoko (jaytaoko) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NuxGraphics/GraphicsDisplayX11.cpp'
2--- NuxGraphics/GraphicsDisplayX11.cpp 2011-09-28 10:24:48 +0000
3+++ NuxGraphics/GraphicsDisplayX11.cpp 2011-09-28 12:34:00 +0000
4@@ -199,6 +199,8 @@
5 bool FullscreenFlag,
6 bool create_rendering_data)
7 {
8+ int xinerama_event, xinerama_error;
9+ int xinerama_major, xinerama_minor;
10 NScopeLock Scope (&CreateOpenGLWindow_CriticalSection);
11
12 m_GfxInterfaceCreated = false;
13@@ -223,6 +225,8 @@
14
15 m_X11Screen = DefaultScreen (m_X11Display);
16 XF86VidModeQueryVersion (m_X11Display, &_x11_major, &_x11_minor);
17+ XineramaQueryVersion (m_X11Display, &xinerama_major, &xinerama_minor);
18+ XineramaQueryExtension (m_X11Display, &xinerama_event, &xinerama_error);
19
20 XF86VidModeGetAllModeLines (m_X11Display, m_X11Screen, &m_NumVideoModes, &m_X11VideoModes);
21 m_X11OriginalVideoMode = *m_X11VideoModes[0];
22
23=== modified file 'NuxGraphics/GraphicsDisplayX11.h'
24--- NuxGraphics/GraphicsDisplayX11.h 2011-05-26 21:08:18 +0000
25+++ NuxGraphics/GraphicsDisplayX11.h 2011-09-28 12:34:00 +0000
26@@ -36,6 +36,7 @@
27 #include <X11/keysym.h>
28
29 #include <X11/extensions/xf86vmode.h>
30+#include <X11/extensions/Xinerama.h>
31
32 namespace nux
33 {
34@@ -312,6 +313,7 @@
35
36 void * KeyboardGrabData () { return _global_keyboard_grab_data; }
37 void * PointerGrabData () { return _global_pointer_grab_data; }
38+
39 private:
40 void InitGlobalGrabWindow ();
41
42
43=== modified file 'NuxGraphics/XInputWindow.cpp'
44--- NuxGraphics/XInputWindow.cpp 2011-09-20 06:03:43 +0000
45+++ NuxGraphics/XInputWindow.cpp 2011-09-28 12:34:00 +0000
46@@ -103,15 +103,69 @@
47
48 void XInputWindow::SetStruts()
49 {
50- int screenHeight, screenWidth;
51+ int n_info;
52+ XineramaScreenInfo *info = XineramaQueryScreens (display_, &n_info);
53+ Region screen_region;
54+ Region total_screen_region = XCreateRegion ();
55+ Region input_window_region = XCreateRegion ();
56+ Region intersection = XCreateRegion ();
57+ XineramaScreenInfo monitor;
58+ XRectangle tmp_rect;
59+ int largestWidth = 0, largestHeight = 0;
60+ int screenWidth, screenHeight;
61 long int data[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
62
63- screenHeight = XDisplayHeight(display_, 0);
64- screenWidth = XDisplayWidth(display_, 0);
65+ /* Find the screen that this region intersects */
66+ tmp_rect.x = geometry_.x;
67+ tmp_rect.y = geometry_.y;
68+ tmp_rect.width = geometry_.width;
69+ tmp_rect.height = geometry_.height;
70+
71+ XUnionRectWithRegion (&tmp_rect, input_window_region, input_window_region);
72+
73+ for (int i = 0; i < n_info; i++)
74+ {
75+ tmp_rect.x = info[i].x_org;
76+ tmp_rect.y = info[i].y_org;
77+ tmp_rect.width = info[i].width;
78+ tmp_rect.height = info[i].height;
79+
80+ screen_region = XCreateRegion ();
81+
82+ XUnionRectWithRegion (&tmp_rect, screen_region, screen_region);
83+ XUnionRegion (screen_region, total_screen_region, total_screen_region);
84+ XIntersectRegion (screen_region, input_window_region, intersection);
85+
86+ if (!XEmptyRegion (intersection))
87+ {
88+ int width = intersection->extents.x2 - intersection->extents.x1;
89+ int height = intersection->extents.y2 - intersection->extents.y1;
90+
91+ if ((width * height) > (largestWidth * largestHeight))
92+ {
93+ largestWidth = width;
94+ largestHeight = height;
95+
96+ monitor = info[i];
97+ }
98+ }
99+
100+ XDestroyRegion (screen_region);
101+ }
102+
103+ screenWidth = total_screen_region->extents.x2 - total_screen_region->extents.x1;
104+ screenHeight = total_screen_region->extents.y2 - total_screen_region->extents.y1;
105+
106+ XDestroyRegion (input_window_region);
107+ XDestroyRegion (intersection);
108+ XDestroyRegion (total_screen_region);
109+
110+ if (info)
111+ XFree (info);
112
113 if (geometry_.width > geometry_.height)
114 {
115- if (geometry_.y < screenHeight / 2)
116+ if (geometry_.y - monitor.y_org < monitor.height / 2)
117 {
118 /* top */
119 data[2] = geometry_.y + geometry_.height;
120@@ -128,7 +182,7 @@
121 }
122 else
123 {
124- if (geometry_.x < screenWidth / 2)
125+ if (geometry_.x - monitor.x_org < monitor.width / 2)
126 {
127 /* left */
128 data[0] = geometry_.x + geometry_.width;
129
130=== modified file 'NuxGraphics/XInputWindow.h'
131--- NuxGraphics/XInputWindow.h 2011-09-20 06:03:43 +0000
132+++ NuxGraphics/XInputWindow.h 2011-09-28 12:34:00 +0000
133@@ -28,6 +28,7 @@
134 #include <X11/Xatom.h>
135 /* keysym.h contains keysymbols which we use to resolv what keys that are being pressed */
136 #include <X11/keysym.h>
137+#include <X11/Xregion.h>
138
139 #include <X11/extensions/xf86vmode.h>
140
141
142=== modified file 'NuxGraphics/nux-graphics.pc.in'
143--- NuxGraphics/nux-graphics.pc.in 2011-09-20 06:03:43 +0000
144+++ NuxGraphics/nux-graphics.pc.in 2011-09-28 12:34:00 +0000
145@@ -8,4 +8,4 @@
146 Version: @VERSION@
147 Libs: -L${libdir} -lnux-graphics-@NUX_API_VERSION@
148 Cflags: -I${includedir}/Nux-@NUX_API_VERSION@
149-Requires: glib-2.0 nux-core-@NUX_API_VERSION@ nux-image-@NUX_API_VERSION@ gl glu xxf86vm glew glewmx
150+Requires: glib-2.0 nux-core-@NUX_API_VERSION@ nux-image-@NUX_API_VERSION@ gl glu xxf86vm glew glewmx xinerama
151
152=== modified file 'configure.ac'
153--- configure.ac 2011-09-26 09:42:41 +0000
154+++ configure.ac 2011-09-28 12:34:00 +0000
155@@ -143,6 +143,7 @@
156 glewmx
157 xxf86vm
158 sigc++-2.0
159+ xinerama
160 )
161 AC_SUBST(NUX_GRAPHICS_CFLAGS)
162 AC_SUBST(NUX_GRAPHICS_LIBS)

Subscribers

People subscribed via source and target branches