setCapture.diff
include/nel/misc/events.h (copie de travail) | ||
---|---|---|
250 | 250 |
altButton =0x20 |
251 | 251 |
}; |
252 | 252 | |
253 |
// TODO list altGr ? |
|
253 | 254 |
enum TKeyButton |
254 | 255 |
{ |
255 | 256 |
noKeyButton =0x0, |
... | ... | |
279 | 280 | |
280 | 281 |
/** |
281 | 282 |
* CEventKeyDown |
282 |
* Send when a key is push down. The key type is Key and FirstTime is true if the previous key state wasn't pushed. |
|
283 |
* Send when a key is pushed down. The key type is Key and FirstTime is true if the previous key state wasn't pushed.
|
|
283 | 284 |
*/ |
284 | 285 |
class CEventKeyDown : public CEventKey |
285 | 286 |
{ |
include/nel/misc/mutex.h (copie de travail) | ||
---|---|---|
196 | 196 |
* \date 2002, 2003 |
197 | 197 |
*/ |
198 | 198 |
#ifdef __ppc__ |
199 |
// on ppc, use fait mutex because we don't have ppc implementation of fast mutex
|
|
199 |
// on ppc, use fair mutex because we don't have ppc implementation of fast mutex
|
|
200 | 200 |
# define CFastMutex CFairMutex |
201 | 201 |
#else |
202 | 202 | |
... | ... | |
253 | 253 |
// Enter critical section |
254 | 254 |
__forceinline void enter () volatile |
255 | 255 |
{ |
256 |
//std::cout << "Entering, Lock=" << _Lock << std::endl;
|
|
256 |
// std::cout << "Entering, Lock=" << _Lock << std::endl;
|
|
257 | 257 |
if (atomic_swap (&_Lock)) |
258 | 258 |
{ |
259 | 259 |
// First test |
... | ... | |
278 | 278 |
#ifdef NL_OS_WINDOWS |
279 | 279 |
Sleep (wait_time); |
280 | 280 |
#else |
281 |
//std::cout << "Sleeping i=" << i << std::endl;
|
|
281 |
// std::cout << "Sleeping i=" << i << std::endl;
|
|
282 | 282 |
usleep( wait_time*1000 ); |
283 | 283 |
#endif |
284 | 284 |
} |
... | ... | |
289 | 289 |
__forceinline void leave () volatile |
290 | 290 |
{ |
291 | 291 |
_Lock = 0; |
292 |
//std::cout << "Leave" << std::endl;
|
|
292 |
// std::cout << "Leave" << std::endl;
|
|
293 | 293 |
} |
294 | 294 | |
295 | 295 |
private: |
src/misc/win_event_emitter.cpp (copie de travail) | ||
---|---|---|
127 | 127 |
case WM_SYSKEYDOWN: |
128 | 128 |
if (_KeyboardEventsEnabled) |
129 | 129 |
{ |
130 |
// Ctrl, shit or alt ? |
|
130 |
// Ctrl, shift or alt ?
|
|
131 | 131 |
if ((int)wParam==VK_MENU) |
132 | 132 |
_AltButton=true; |
133 | 133 |
if ((int)wParam==VK_CONTROL) |
src/3d/driver/opengl/driver_opengl.cpp (copie de travail) | ||
---|---|---|
277 | 277 |
#ifdef XF86VIDMODE |
278 | 278 |
// zero the old screen mode |
279 | 279 |
memset(&_OldScreenMode, 0, sizeof(_OldScreenMode)); |
280 |
_capture = false ; |
|
280 | 281 |
#endif //XF86VIDMODE |
281 | 282 | |
282 | 283 |
#endif // NL_OS_UNIX |
... | ... | |
458 | 459 |
{ |
459 | 460 |
nldebug("3D: XOpenDisplay on '%s' OK", getenv("DISPLAY")); |
460 | 461 |
} |
461 | ||
462 | 462 |
#endif |
463 | 463 |
return true; |
464 | 464 |
} |
... | ... | |
533 | 533 |
{ |
534 | 534 |
H_AUTO_OGL(CDriverGL_setDisplay) |
535 | 535 | |
536 |
uint width = mode.Width; |
|
537 |
uint height = mode.Height; |
|
536 |
uint width = _WindowWidth = mode.Width;
|
|
537 |
uint height = _WindowHeight = mode.Height;
|
|
538 | 538 | |
539 | 539 |
#ifdef NL_OS_WINDOWS |
540 | 540 | |
... | ... | |
1103 | 1103 |
XTextProperty text_property; |
1104 | 1104 |
// FIXME char*s are created as const char*, but that doesn't work |
1105 | 1105 |
// with XStringListToTextProperty()'s char** ... |
1106 |
char *title="NeL window";
|
|
1106 |
char *title = "NeL window";
|
|
1107 | 1107 |
XStringListToTextProperty(&title, 1, &text_property); |
1108 | 1108 | |
1109 | 1109 |
XSetWMProperties (dpy, win, &text_property, &text_property, 0, 0, &size_hints, 0, 0); |
1110 | 1110 |
glXMakeCurrent (dpy, win, ctx); |
1111 | 1111 |
XMapRaised (dpy, win); |
1112 | 1112 | |
1113 |
XSelectInput (dpy, win, KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask); |
|
1113 |
XSelectInput (dpy, win, KeyPressMask|KeyReleaseMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|StructureNotifyMask);
|
|
1114 | 1114 | |
1115 | 1115 |
XMapWindow(dpy, win); |
1116 | 1116 | |
... | ... | |
1938 | 1938 |
// flush direct input messages if any |
1939 | 1939 |
NLMISC::safe_cast<NLMISC::CDIEventEmitter *>(_EventEmitter.getEmitter(1))->poll(); |
1940 | 1940 |
} |
1941 |
#endif |
|
1941 |
#else // NL_OS_WINDOWS |
|
1942 |
if (_capture) |
|
1943 |
{ |
|
1944 |
sint mouseX, mouseY, tmp, newX, newY ; |
|
1945 |
uint utmp ; |
|
1946 |
Window root, fromroot, tmpwin; |
|
1947 |
|
|
1948 |
// retrive the root window |
|
1949 |
root = DefaultRootWindow(dpy); |
|
1950 |
|
|
1951 |
_WindowX = _EventEmitter.getWindowPosX() ; |
|
1952 |
_WindowY = _EventEmitter.getWindowPosY() ; |
|
1953 |
|
|
1954 |
nldebug("%d %d", _WindowWidth, _WindowHeight) ; |
|
1955 |
|
|
1956 |
// gets the mouse position even if it is outside the window |
|
1957 |
XQueryPointer(dpy, root, &fromroot, &tmpwin, &mouseX, &mouseY, &tmp, &tmp, &utmp); |
|
1958 |
|
|
1959 |
newX = mouseX ; |
|
1960 |
newY = mouseY ; |
|
1961 |
|
|
1962 |
clamp(newX, _WindowX, _WindowX + _WindowWidth - 1); |
|
1963 |
clamp(newY, _WindowY, _WindowY + _WindowHeight - 1); |
|
1964 |
|
|
1965 |
if (newX - mouseX || newY - mouseY) // mouse has to be moved ? |
|
1966 |
// move the new position |
|
1967 |
XWarpPointer( dpy, None, fromroot, 0, 0, 0, 0, newX, newY) ; |
|
1968 |
} |
|
1969 |
#endif // !NL_OS_WINDOWS |
|
1942 | 1970 | |
1943 | 1971 |
if (!_WndActive) |
1944 | 1972 |
{ |
... | ... | |
2460 | 2488 |
} |
2461 | 2489 |
} |
2462 | 2490 |
#elif defined (NL_OS_UNIX) |
2463 |
x = y = 0; |
|
2491 |
x = _EventEmitter.getWindowPosX() ; |
|
2492 |
y = _EventEmitter.getWindowPosY() ; |
|
2464 | 2493 |
#endif // NL_OS_UNIX |
2465 | 2494 |
} |
2466 | 2495 | |
... | ... | |
2537 | 2566 | |
2538 | 2567 |
#elif defined (NL_OS_UNIX) |
2539 | 2568 | |
2540 |
nlwarning("LINUXTODO: This method is not implemented under linux"); |
|
2541 |
// TODO for Linux : implement it (clipRect with the window dimensions ?) |
|
2569 |
_capture = b ; |
|
2542 | 2570 | |
2543 | 2571 |
#endif // NL_OS_UNIX |
2544 | 2572 |
} |
src/3d/driver/opengl/driver_opengl.h (copie de travail) | ||
---|---|---|
699 | 699 |
int _OldDotClock; // old dotclock |
700 | 700 |
XF86VidModeModeLine _OldScreenMode; // old modeline |
701 | 701 |
int _OldX, _OldY; //Viewport settings |
702 |
bool _capture ; |
|
702 | 703 |
#endif //XF86VIDMODE |
703 | 704 | |
704 | 705 |
#endif // NL_OS_UNIX |
src/3d/driver/opengl/unix_event_emitter.cpp (copie de travail) | ||
---|---|---|
43 | 43 |
{ |
44 | 44 |
_dpy = dpy; |
45 | 45 |
_win = win; |
46 |
_posX = 0 ; |
|
47 |
_posY = 0 ; |
|
46 | 48 |
} |
47 | 49 | |
48 |
void CUnixEventEmitter::submitEvents(CEventServer & server, bool allWindows)
|
|
50 |
void CUnixEventEmitter::submitEvents(CEventServer & server, bool /*allWindows*/)
|
|
49 | 51 |
{ |
50 | 52 |
while (XPending(_dpy)) |
51 | 53 |
{ |
... | ... | |
224 | 226 |
break; |
225 | 227 |
Case(ButtonPress) |
226 | 228 |
{ |
227 |
//nlinfo("%d %d %d", event.xbutton.button, event.xbutton.x, event.xbutton.y); |
|
228 | 229 |
XWindowAttributes xwa; |
229 | 230 |
XGetWindowAttributes (_dpy, _win, &xwa); |
230 | 231 |
float fX = (float) event.xbutton.x / (float) xwa.width; |
231 | 232 |
float fY = 1.0f - (float) event.xbutton.y / (float) xwa.height; |
233 |
|
|
232 | 234 |
TMouseButton button=getMouseButton(event.xbutton.state); |
233 | 235 |
switch(event.xbutton.button) |
234 | 236 |
{ |
... | ... | |
252 | 254 |
} |
253 | 255 |
Case(ButtonRelease) |
254 | 256 |
{ |
255 |
//nlinfo("%d %d %d", event.xbutton.button, event.xbutton.x, event.xbutton.y); |
|
256 | 257 |
XWindowAttributes xwa; |
257 | 258 |
XGetWindowAttributes (_dpy, _win, &xwa); |
258 | 259 |
float fX = (float) event.xbutton.x / (float) xwa.width; |
259 | 260 |
float fY = 1.0f - (float) event.xbutton.y / (float) xwa.height; |
261 |
|
|
260 | 262 |
switch(event.xbutton.button) |
261 | 263 |
{ |
262 | 264 |
case Button1: |
... | ... | |
327 | 329 |
Case(DestroyNotify) |
328 | 330 |
break; |
329 | 331 |
Case(ConfigureNotify) |
330 |
/* if (event.xconfigure.width==gmaxx && event.xconfigure.height==gmaxy) { |
|
331 |
UpdateGWin(); |
|
332 |
} else { |
|
333 |
XResizeWindow(display, gwindow, gmaxx, gmaxy); |
|
334 |
} */ |
|
332 |
_posX = event.xconfigure.x ; |
|
333 |
_posY = event.xconfigure.y ; |
|
335 | 334 |
break; |
336 | 335 |
default: |
337 | 336 |
nlinfo("UnknownEvent"); |
src/3d/driver/opengl/unix_event_emitter.h (copie de travail) | ||
---|---|---|
45 | 45 |
{ |
46 | 46 |
public: |
47 | 47 | |
48 |
/// Constructor |
|
49 |
CUnixEventEmitter(); |
|
48 |
/// Constructor |
|
49 |
CUnixEventEmitter(); |
|
50 |
|
|
51 |
void init (Display *dpy, Window win); |
|
50 | 52 | |
51 |
void init (Display *dpy, Window win); |
|
52 | ||
53 | 53 |
/** |
54 | 54 |
* sends all events to server |
55 | 55 |
* (should call CEventServer method postEvent() ) |
... | ... | |
59 | 59 | |
60 | 60 |
public: |
61 | 61 |
void processMessage (XEvent &event, CEventServer &server); |
62 |
sint getWindowPosX() const ; |
|
63 |
sint getWindowPosY() const ; |
|
62 | 64 | |
63 | 65 |
private: |
64 | 66 |
Display *_dpy; |
65 | 67 |
Window _win; |
68 |
|
|
69 |
// position of the window, retrieved on configure events |
|
70 |
sint _posX ; |
|
71 |
sint _posY ; |
|
66 | 72 |
}; |
67 | 73 | |
74 |
/* Inline code */ |
|
75 |
inline sint CUnixEventEmitter::getWindowPosX() const |
|
76 |
{ |
|
77 |
return _posX ; |
|
78 |
} |
|
68 | 79 | |
80 |
inline sint CUnixEventEmitter::getWindowPosY() const |
|
81 |
{ |
|
82 |
return _posY ; |
|
83 |
} |
|
84 | ||
69 | 85 |
} // NLMISC |
70 | 86 | |
71 | 87 |
#endif // NL_OS_UNIX |