author | Sam Lantinga <slouken@libsdl.org> |
Wed, 10 Jul 2013 21:57:31 -0700 | |
changeset 7396 | a36ab6149a10 |
parent 7214 | 5b31583ecf9e |
child 7402 | 235c9aaeefd1 |
permissions | -rw-r--r-- |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 |
/* |
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5530
diff
changeset
|
2 |
Simple DirectMedia Layer |
6885 | 3 |
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org> |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5530
diff
changeset
|
5 |
This software is provided 'as-is', without any express or implied |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5530
diff
changeset
|
6 |
warranty. In no event will the authors be held liable for any damages |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5530
diff
changeset
|
7 |
arising from the use of this software. |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5530
diff
changeset
|
9 |
Permission is granted to anyone to use this software for any purpose, |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5530
diff
changeset
|
10 |
including commercial applications, and to alter it and redistribute it |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5530
diff
changeset
|
11 |
freely, subject to the following restrictions: |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5530
diff
changeset
|
13 |
1. The origin of this software must not be misrepresented; you must not |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5530
diff
changeset
|
14 |
claim that you wrote the original software. If you use this software |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5530
diff
changeset
|
15 |
in a product, an acknowledgment in the product documentation would be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5530
diff
changeset
|
16 |
appreciated but is not required. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5530
diff
changeset
|
17 |
2. Altered source versions must be plainly marked as such, and must not be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5530
diff
changeset
|
18 |
misrepresented as being the original software. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5530
diff
changeset
|
19 |
3. This notice may not be removed or altered from any source distribution. |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 |
*/ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 |
#include "SDL_config.h" |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
|
5481
22dfc3958dc3
Fixed so code will compile with SDL_config_minimal.h
Sam Lantinga <slouken@libsdl.org>
parents:
5408
diff
changeset
|
23 |
#if SDL_VIDEO_DRIVER_X11 |
22dfc3958dc3
Fixed so code will compile with SDL_config_minimal.h
Sam Lantinga <slouken@libsdl.org>
parents:
5408
diff
changeset
|
24 |
|
2046
da8332c8f480
Replaced strncmp for SDL_VIDEODRIVER test with strcasecmp
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
25 |
#include <sys/types.h> |
da8332c8f480
Replaced strncmp for SDL_VIDEODRIVER test with strcasecmp
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
26 |
#include <sys/time.h> |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
27 |
#include <signal.h> |
2046
da8332c8f480
Replaced strncmp for SDL_VIDEODRIVER test with strcasecmp
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
28 |
#include <unistd.h> |
4558
4d95152d9e39
Applied the same logic as the fix for bug 894.
Sam Lantinga <slouken@libsdl.org>
parents:
4556
diff
changeset
|
29 |
#include <limits.h> /* For INT_MAX */ |
2046
da8332c8f480
Replaced strncmp for SDL_VIDEODRIVER test with strcasecmp
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset
|
30 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
#include "SDL_x11video.h" |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
32 |
#include "SDL_x11video.h" |
4934
a5b86644c208
Fixed compiling X11 touch interface
Sam Lantinga <slouken@libsdl.org>
parents:
4902
diff
changeset
|
33 |
#include "SDL_x11touch.h" |
6316
a89c79a3f0cd
1.Moved all xinput2 functionality to its own file
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
6311
diff
changeset
|
34 |
#include "SDL_x11xinput2.h" |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
#include "../../events/SDL_events_c.h" |
2940
b93965a16fe0
Fixed X11 mouse motion/button events - it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
36 |
#include "../../events/SDL_mouse_c.h" |
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
37 |
#include "../../events/SDL_touch_c.h" |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 |
|
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
39 |
#include "SDL_timer.h" |
3241
08c5964f2a34
Fixed a few issues compiling with Mac OS X 10.6
Sam Lantinga <slouken@libsdl.org>
parents:
3195
diff
changeset
|
40 |
#include "SDL_syswm.h" |
08c5964f2a34
Fixed a few issues compiling with Mac OS X 10.6
Sam Lantinga <slouken@libsdl.org>
parents:
3195
diff
changeset
|
41 |
|
4642
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
42 |
#include <stdio.h> |
057e8762d2a1
Added reading of event* for touch events.
Jim Grandpre <jim.tla@gmail.com>
parents:
4640
diff
changeset
|
43 |
|
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
44 |
typedef struct { |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
45 |
unsigned char *data; |
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
46 |
int format, count; |
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
47 |
Atom type; |
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
48 |
} SDL_x11Prop; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
49 |
|
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
50 |
/* Reads property |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
51 |
Must call XFree on results |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
52 |
*/ |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
53 |
static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) |
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
54 |
{ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
55 |
unsigned char *ret=NULL; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
56 |
Atom type; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
57 |
int fmt; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
58 |
unsigned long count; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
59 |
unsigned long bytes_left; |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
60 |
int bytes_fetch = 0; |
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
61 |
|
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
62 |
do { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
63 |
if (ret != 0) XFree(ret); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
64 |
XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
65 |
bytes_fetch += bytes_left; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
66 |
} while (bytes_left != 0); |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
67 |
|
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
68 |
p->data=ret; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
69 |
p->format=fmt; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
70 |
p->count=count; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
71 |
p->type=type; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
72 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
73 |
|
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
74 |
/* Find text-uri-list in a list of targets and return it's atom |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
75 |
if available, else return None */ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
76 |
static Atom X11_PickTarget(Display *disp, Atom list[], int list_count) |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
77 |
{ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
78 |
Atom request = None; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
79 |
char *name; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
80 |
int i; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
81 |
for (i=0; i < list_count && request == None; i++) { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
82 |
name = XGetAtomName(disp, list[i]); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
83 |
if (strcmp("text/uri-list", name)==0) request = list[i]; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
84 |
XFree(name); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
85 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
86 |
return request; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
87 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
88 |
|
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
89 |
/* Wrapper for X11_PickTarget for a maximum of three targets, a special |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
90 |
case in the Xdnd protocol */ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
91 |
static Atom X11_PickTargetFromAtoms(Display *disp, Atom a0, Atom a1, Atom a2) |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
92 |
{ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
93 |
int count=0; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
94 |
Atom atom[3]; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
95 |
if (a0 != None) atom[count++] = a0; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
96 |
if (a1 != None) atom[count++] = a1; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
97 |
if (a2 != None) atom[count++] = a2; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
98 |
return X11_PickTarget(disp, atom, count); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
99 |
} |
6474
39087ac884d7
Added debug define (commented out)
Sam Lantinga <slouken@libsdl.org>
parents:
6432
diff
changeset
|
100 |
/*#define DEBUG_XEVENTS*/ |
39087ac884d7
Added debug define (commented out)
Sam Lantinga <slouken@libsdl.org>
parents:
6432
diff
changeset
|
101 |
|
4565
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
102 |
/* Check to see if this is a repeated key. |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
103 |
(idea shamelessly lifted from GII -- thanks guys! :) |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
104 |
*/ |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
105 |
static SDL_bool X11_KeyRepeat(Display *display, XEvent *event) |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
106 |
{ |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
107 |
XEvent peekevent; |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
108 |
|
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
109 |
if (XPending(display)) { |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
110 |
XPeekEvent(display, &peekevent); |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
111 |
if ((peekevent.type == KeyPress) && |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
112 |
(peekevent.xkey.keycode == event->xkey.keycode) && |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
113 |
((peekevent.xkey.time-event->xkey.time) < 2)) { |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
114 |
return SDL_TRUE; |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
115 |
} |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
116 |
} |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
117 |
return SDL_FALSE; |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
118 |
} |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
119 |
|
5530
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
120 |
static SDL_bool X11_IsWheelEvent(Display * display,XEvent * event,int * ticks) |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
121 |
{ |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
122 |
XEvent peekevent; |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
123 |
if (XPending(display)) { |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
124 |
/* according to the xlib docs, no specific mouse wheel events exist. |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
125 |
however, mouse wheel events trigger a button press and a button release |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
126 |
immediately. thus, checking if the same button was released at the same |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
127 |
time as it was pressed, should be an adequate hack to derive a mouse |
5530
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
128 |
wheel event. */ |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
129 |
XPeekEvent(display,&peekevent); |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
130 |
if ((peekevent.type == ButtonRelease) && |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
131 |
(peekevent.xbutton.button == event->xbutton.button) && |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
132 |
(peekevent.xbutton.time == event->xbutton.time)) { |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
133 |
|
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
134 |
/* by default, X11 only knows 5 buttons. on most 3 button + wheel mouse, |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
135 |
Button4 maps to wheel up, Button5 maps to wheel down. */ |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
136 |
if (event->xbutton.button == Button4) { |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
137 |
*ticks = 1; |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
138 |
} |
6184
976d9ec6c290
Fixed bug 1305 - mouse wheel scroll-down event created when mouse wheel is pressed down
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
139 |
else if (event->xbutton.button == Button5) { |
5530
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
140 |
*ticks = -1; |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
141 |
} |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
142 |
|
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
143 |
/* remove the following release event, as this is now a wheel event */ |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
144 |
XNextEvent(display,&peekevent); |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
145 |
return SDL_TRUE; |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
146 |
} |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
147 |
} |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
148 |
return SDL_FALSE; |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
149 |
} |
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
150 |
|
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
151 |
/* Convert URI to local filename |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
152 |
return filename if possible, else NULL |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
153 |
*/ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
154 |
static char* X11_URIToLocal(char* uri) { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
155 |
char *file = NULL; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
156 |
|
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
157 |
if (memcmp(uri,"file:/",6) == 0) uri += 6; /* local file? */ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
158 |
else if (strstr(uri,":/") != NULL) return file; /* wrong scheme */ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
159 |
|
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
160 |
SDL_bool local = uri[0] != '/' || ( uri[0] != '\0' && uri[1] == '/' ); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
161 |
|
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
162 |
/* got a hostname? */ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
163 |
if ( !local && uri[0] == '/' && uri[2] != '/' ) { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
164 |
char* hostname_end = strchr( uri+1, '/' ); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
165 |
if ( hostname_end != NULL ) { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
166 |
char hostname[ 257 ]; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
167 |
if ( gethostname( hostname, 255 ) == 0 ) { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
168 |
hostname[ 256 ] = '\0'; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
169 |
if ( memcmp( uri+1, hostname, hostname_end - ( uri+1 )) == 0 ) { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
170 |
uri = hostname_end + 1; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
171 |
local = SDL_TRUE; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
172 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
173 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
174 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
175 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
176 |
if ( local ) { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
177 |
file = uri; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
178 |
if ( uri[1] == '/' ) { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
179 |
file++; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
180 |
} else { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
181 |
file--; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
182 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
183 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
184 |
return file; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
185 |
} |
6311
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
186 |
|
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
187 |
#if SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS |
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
188 |
static void X11_HandleGenericEvent(SDL_VideoData *videodata,XEvent event) |
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
189 |
{ |
7214
5b31583ecf9e
Only free EventData if it's successfully retrieved.
Edward Rudd <urkle@outoforder.cc>
parents:
7199
diff
changeset
|
190 |
if (XGetEventData(videodata->display, &event)) { |
5b31583ecf9e
Only free EventData if it's successfully retrieved.
Edward Rudd <urkle@outoforder.cc>
parents:
7199
diff
changeset
|
191 |
XGenericEventCookie *cookie = &event.xcookie; |
5b31583ecf9e
Only free EventData if it's successfully retrieved.
Edward Rudd <urkle@outoforder.cc>
parents:
7199
diff
changeset
|
192 |
X11_HandleXinput2Event(videodata, cookie); |
5b31583ecf9e
Only free EventData if it's successfully retrieved.
Edward Rudd <urkle@outoforder.cc>
parents:
7199
diff
changeset
|
193 |
XFreeEventData(videodata->display, cookie); |
5b31583ecf9e
Only free EventData if it's successfully retrieved.
Edward Rudd <urkle@outoforder.cc>
parents:
7199
diff
changeset
|
194 |
} |
6311
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
195 |
} |
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
196 |
#endif /* SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS */ |
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
197 |
|
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
198 |
|
6481
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
199 |
static void |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
200 |
X11_DispatchFocusIn(SDL_WindowData *data) |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
201 |
{ |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
202 |
#ifdef DEBUG_XEVENTS |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
203 |
printf("window %p: Dispatching FocusIn\n", data); |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
204 |
#endif |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
205 |
SDL_SetKeyboardFocus(data->window); |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
206 |
#ifdef X_HAVE_UTF8_STRING |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
207 |
if (data->ic) { |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
208 |
XSetICFocus(data->ic); |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
209 |
} |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
210 |
#endif |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
211 |
} |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
212 |
|
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
213 |
static void |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
214 |
X11_DispatchFocusOut(SDL_WindowData *data) |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
215 |
{ |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
216 |
#ifdef DEBUG_XEVENTS |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
217 |
printf("window %p: Dispatching FocusOut\n", data); |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
218 |
#endif |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
219 |
SDL_SetKeyboardFocus(NULL); |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
220 |
#ifdef X_HAVE_UTF8_STRING |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
221 |
if (data->ic) { |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
222 |
XUnsetICFocus(data->ic); |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
223 |
} |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
224 |
#endif |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
225 |
} |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
226 |
|
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
227 |
static void |
6481
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
228 |
X11_DispatchMapNotify(SDL_WindowData *data) |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
229 |
{ |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
230 |
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0); |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
231 |
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESTORED, 0, 0); |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
232 |
} |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
233 |
|
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
234 |
static void |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
235 |
X11_DispatchUnmapNotify(SDL_WindowData *data) |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
236 |
{ |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
237 |
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_HIDDEN, 0, 0); |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
238 |
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
239 |
} |
6311
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
240 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 |
static void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 |
X11_DispatchEvent(_THIS) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 |
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
245 |
Display *display = videodata->display; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 |
SDL_WindowData *data; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 |
XEvent xevent; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 |
int i; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 |
SDL_zero(xevent); /* valgrind fix. --ryan. */ |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
251 |
XNextEvent(display, &xevent); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 |
|
2325
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
253 |
/* filter events catchs XIM events and sends them to the correct |
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
254 |
handler */ |
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
255 |
if (XFilterEvent(&xevent, None) == True) { |
2327
7b53a8401195
In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents:
2326
diff
changeset
|
256 |
#if 0 |
2328
91e601d9df8b
re: bug#563. checking in some commented out trace code and a fix so that the in testalpha.c the background only flashes when alpha == 255. The problem that is being
Bob Pendleton <bob@pendleton.com>
parents:
2327
diff
changeset
|
257 |
printf("Filtered event type = %d display = %d window = %d\n", |
91e601d9df8b
re: bug#563. checking in some commented out trace code and a fix so that the in testalpha.c the background only flashes when alpha == 255. The problem that is being
Bob Pendleton <bob@pendleton.com>
parents:
2327
diff
changeset
|
258 |
xevent.type, xevent.xany.display, xevent.xany.window); |
2325
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
259 |
#endif |
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
260 |
return; |
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
261 |
} |
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
262 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 |
/* Send a SDL_SYSWMEVENT if the application wants them */ |
4429
faa9fc8e7f67
General improvements for user custom event registration
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
264 |
if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) { |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 |
SDL_SysWMmsg wmmsg; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 |
SDL_VERSION(&wmmsg.version); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 |
wmmsg.subsystem = SDL_SYSWM_X11; |
5056
8b7988f42fcb
Added the ability to get the UIKit window through the SDL API.
Sam Lantinga <slouken@libsdl.org>
parents:
4934
diff
changeset
|
269 |
wmmsg.msg.x11.event = xevent; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 |
SDL_SendSysWMEvent(&wmmsg); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 |
|
6311
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
273 |
#if SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS |
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
274 |
if(xevent.type == GenericEvent) { |
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
275 |
X11_HandleGenericEvent(videodata,xevent); |
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
276 |
return; |
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
277 |
} |
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
278 |
#endif |
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
279 |
|
6476
9010d6830cdf
Show events from all windows (for the legacy fullscreen case)
Sam Lantinga <slouken@libsdl.org>
parents:
6474
diff
changeset
|
280 |
#if 0 |
9010d6830cdf
Show events from all windows (for the legacy fullscreen case)
Sam Lantinga <slouken@libsdl.org>
parents:
6474
diff
changeset
|
281 |
printf("type = %d display = %d window = %d\n", |
9010d6830cdf
Show events from all windows (for the legacy fullscreen case)
Sam Lantinga <slouken@libsdl.org>
parents:
6474
diff
changeset
|
282 |
xevent.type, xevent.xany.display, xevent.xany.window); |
9010d6830cdf
Show events from all windows (for the legacy fullscreen case)
Sam Lantinga <slouken@libsdl.org>
parents:
6474
diff
changeset
|
283 |
#endif |
9010d6830cdf
Show events from all windows (for the legacy fullscreen case)
Sam Lantinga <slouken@libsdl.org>
parents:
6474
diff
changeset
|
284 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 |
data = NULL; |
2324
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
286 |
if (videodata && videodata->windowlist) { |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
287 |
for (i = 0; i < videodata->numwindows; ++i) { |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
288 |
if ((videodata->windowlist[i] != NULL) && |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3322
diff
changeset
|
289 |
(videodata->windowlist[i]->xwindow == xevent.xany.window)) { |
2324
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
290 |
data = videodata->windowlist[i]; |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
291 |
break; |
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
292 |
} |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 |
if (!data) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 |
return; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 |
} |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
298 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 |
switch (xevent.type) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 |
/* Gaining mouse coverage? */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 |
case EnterNotify:{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 |
#ifdef DEBUG_XEVENTS |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
304 |
printf("window %p: EnterNotify! (%d,%d,%d)\n", data, |
4558
4d95152d9e39
Applied the same logic as the fix for bug 894.
Sam Lantinga <slouken@libsdl.org>
parents:
4556
diff
changeset
|
305 |
xevent.xcrossing.x, |
4d95152d9e39
Applied the same logic as the fix for bug 894.
Sam Lantinga <slouken@libsdl.org>
parents:
4556
diff
changeset
|
306 |
xevent.xcrossing.y, |
3195
08747e24a50f
Mouse events now report the correct window id and window enter/leave events are now reported.
Bob Pendleton <bob@pendleton.com>
parents:
3188
diff
changeset
|
307 |
xevent.xcrossing.mode); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 |
if (xevent.xcrossing.mode == NotifyGrab) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 |
printf("Mode: NotifyGrab\n"); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 |
if (xevent.xcrossing.mode == NotifyUngrab) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 |
printf("Mode: NotifyUngrab\n"); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 |
#endif |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
313 |
SDL_SetMouseFocus(data->window); |
7097
84bbd421d62f
Make sure to send MOUSEMOTION on window enter.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
7089
diff
changeset
|
314 |
|
84bbd421d62f
Make sure to send MOUSEMOTION on window enter.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
7089
diff
changeset
|
315 |
if (!SDL_GetMouse()->relative_mode) { |
84bbd421d62f
Make sure to send MOUSEMOTION on window enter.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
7089
diff
changeset
|
316 |
SDL_SendMouseMotion(data->window, 0, 0, xevent.xcrossing.x, xevent.xcrossing.y); |
84bbd421d62f
Make sure to send MOUSEMOTION on window enter.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
7089
diff
changeset
|
317 |
} |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 |
break; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 |
/* Losing mouse coverage? */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 |
case LeaveNotify:{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 |
#ifdef DEBUG_XEVENTS |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
323 |
printf("window %p: LeaveNotify! (%d,%d,%d)\n", data, |
4558
4d95152d9e39
Applied the same logic as the fix for bug 894.
Sam Lantinga <slouken@libsdl.org>
parents:
4556
diff
changeset
|
324 |
xevent.xcrossing.x, |
4d95152d9e39
Applied the same logic as the fix for bug 894.
Sam Lantinga <slouken@libsdl.org>
parents:
4556
diff
changeset
|
325 |
xevent.xcrossing.y, |
3195
08747e24a50f
Mouse events now report the correct window id and window enter/leave events are now reported.
Bob Pendleton <bob@pendleton.com>
parents:
3188
diff
changeset
|
326 |
xevent.xcrossing.mode); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 |
if (xevent.xcrossing.mode == NotifyGrab) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 |
printf("Mode: NotifyGrab\n"); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 |
if (xevent.xcrossing.mode == NotifyUngrab) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 |
printf("Mode: NotifyUngrab\n"); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 |
#endif |
7089
257fc4e541e1
Send mouse leave updates for Windows and X11.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
7021
diff
changeset
|
332 |
if (!SDL_GetMouse()->relative_mode) { |
257fc4e541e1
Send mouse leave updates for Windows and X11.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
7021
diff
changeset
|
333 |
SDL_SendMouseMotion(data->window, 0, 0, xevent.xcrossing.x, xevent.xcrossing.y); |
257fc4e541e1
Send mouse leave updates for Windows and X11.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
7021
diff
changeset
|
334 |
} |
257fc4e541e1
Send mouse leave updates for Windows and X11.
Jørgen P. Tjernø <jorgen@valvesoftware.com>
parents:
7021
diff
changeset
|
335 |
|
4558
4d95152d9e39
Applied the same logic as the fix for bug 894.
Sam Lantinga <slouken@libsdl.org>
parents:
4556
diff
changeset
|
336 |
if (xevent.xcrossing.mode != NotifyGrab && |
4d95152d9e39
Applied the same logic as the fix for bug 894.
Sam Lantinga <slouken@libsdl.org>
parents:
4556
diff
changeset
|
337 |
xevent.xcrossing.mode != NotifyUngrab && |
4d95152d9e39
Applied the same logic as the fix for bug 894.
Sam Lantinga <slouken@libsdl.org>
parents:
4556
diff
changeset
|
338 |
xevent.xcrossing.detail != NotifyInferior) { |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
339 |
SDL_SetMouseFocus(NULL); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 |
break; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 |
/* Gaining input focus? */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 |
case FocusIn:{ |
6660
4fa0723e6874
Don't lose focus if a child window gains focus
Sam Lantinga <slouken@libsdl.org>
parents:
6659
diff
changeset
|
346 |
if (xevent.xfocus.detail == NotifyInferior) { |
4fa0723e6874
Don't lose focus if a child window gains focus
Sam Lantinga <slouken@libsdl.org>
parents:
6659
diff
changeset
|
347 |
#ifdef DEBUG_XEVENTS |
4fa0723e6874
Don't lose focus if a child window gains focus
Sam Lantinga <slouken@libsdl.org>
parents:
6659
diff
changeset
|
348 |
printf("window %p: FocusIn (NotifierInferior, ignoring)\n", data); |
4fa0723e6874
Don't lose focus if a child window gains focus
Sam Lantinga <slouken@libsdl.org>
parents:
6659
diff
changeset
|
349 |
#endif |
4fa0723e6874
Don't lose focus if a child window gains focus
Sam Lantinga <slouken@libsdl.org>
parents:
6659
diff
changeset
|
350 |
break; |
4fa0723e6874
Don't lose focus if a child window gains focus
Sam Lantinga <slouken@libsdl.org>
parents:
6659
diff
changeset
|
351 |
} |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 |
#ifdef DEBUG_XEVENTS |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
353 |
printf("window %p: FocusIn!\n", data); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 |
#endif |
6661
cd8befc0a969
Reset the keyboard when we lose input focus
Sam Lantinga <slouken@libsdl.org>
parents:
6660
diff
changeset
|
355 |
if (data->pending_focus == PENDING_FOCUS_OUT && |
cd8befc0a969
Reset the keyboard when we lose input focus
Sam Lantinga <slouken@libsdl.org>
parents:
6660
diff
changeset
|
356 |
data->window == SDL_GetKeyboardFocus()) { |
cd8befc0a969
Reset the keyboard when we lose input focus
Sam Lantinga <slouken@libsdl.org>
parents:
6660
diff
changeset
|
357 |
/* We want to reset the keyboard here, because we may have |
cd8befc0a969
Reset the keyboard when we lose input focus
Sam Lantinga <slouken@libsdl.org>
parents:
6660
diff
changeset
|
358 |
missed keyboard messages after our previous FocusOut. |
cd8befc0a969
Reset the keyboard when we lose input focus
Sam Lantinga <slouken@libsdl.org>
parents:
6660
diff
changeset
|
359 |
*/ |
7199
6d4cad3fb837
Fixed losing ALT key modifiers on Unity
Sam Lantinga <slouken@libsdl.org>
parents:
7191
diff
changeset
|
360 |
/* Actually, if we do this we clear the ALT key on Unity |
6d4cad3fb837
Fixed losing ALT key modifiers on Unity
Sam Lantinga <slouken@libsdl.org>
parents:
7191
diff
changeset
|
361 |
because it briefly takes focus for their dashboard. |
6d4cad3fb837
Fixed losing ALT key modifiers on Unity
Sam Lantinga <slouken@libsdl.org>
parents:
7191
diff
changeset
|
362 |
|
6d4cad3fb837
Fixed losing ALT key modifiers on Unity
Sam Lantinga <slouken@libsdl.org>
parents:
7191
diff
changeset
|
363 |
I think it's better to think the ALT key is held down |
6d4cad3fb837
Fixed losing ALT key modifiers on Unity
Sam Lantinga <slouken@libsdl.org>
parents:
7191
diff
changeset
|
364 |
when it's not, then always lose the ALT modifier on Unity. |
6d4cad3fb837
Fixed losing ALT key modifiers on Unity
Sam Lantinga <slouken@libsdl.org>
parents:
7191
diff
changeset
|
365 |
*/ |
6d4cad3fb837
Fixed losing ALT key modifiers on Unity
Sam Lantinga <slouken@libsdl.org>
parents:
7191
diff
changeset
|
366 |
/*SDL_ResetKeyboard();*/ |
6661
cd8befc0a969
Reset the keyboard when we lose input focus
Sam Lantinga <slouken@libsdl.org>
parents:
6660
diff
changeset
|
367 |
} |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
368 |
data->pending_focus = PENDING_FOCUS_IN; |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
369 |
data->pending_focus_time = SDL_GetTicks() + PENDING_FOCUS_IN_TIME; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 |
break; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 |
/* Losing input focus? */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
374 |
case FocusOut:{ |
6660
4fa0723e6874
Don't lose focus if a child window gains focus
Sam Lantinga <slouken@libsdl.org>
parents:
6659
diff
changeset
|
375 |
if (xevent.xfocus.detail == NotifyInferior) { |
4fa0723e6874
Don't lose focus if a child window gains focus
Sam Lantinga <slouken@libsdl.org>
parents:
6659
diff
changeset
|
376 |
/* We still have focus if a child gets focus */ |
4fa0723e6874
Don't lose focus if a child window gains focus
Sam Lantinga <slouken@libsdl.org>
parents:
6659
diff
changeset
|
377 |
#ifdef DEBUG_XEVENTS |
4fa0723e6874
Don't lose focus if a child window gains focus
Sam Lantinga <slouken@libsdl.org>
parents:
6659
diff
changeset
|
378 |
printf("window %p: FocusOut (NotifierInferior, ignoring)\n", data); |
4fa0723e6874
Don't lose focus if a child window gains focus
Sam Lantinga <slouken@libsdl.org>
parents:
6659
diff
changeset
|
379 |
#endif |
4fa0723e6874
Don't lose focus if a child window gains focus
Sam Lantinga <slouken@libsdl.org>
parents:
6659
diff
changeset
|
380 |
break; |
4fa0723e6874
Don't lose focus if a child window gains focus
Sam Lantinga <slouken@libsdl.org>
parents:
6659
diff
changeset
|
381 |
} |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 |
#ifdef DEBUG_XEVENTS |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
383 |
printf("window %p: FocusOut!\n", data); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 |
#endif |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
385 |
data->pending_focus = PENDING_FOCUS_OUT; |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
386 |
data->pending_focus_time = SDL_GetTicks() + PENDING_FOCUS_OUT_TIME; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 |
break; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 |
/* Generated upon EnterWindow and FocusIn */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 |
case KeymapNotify:{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 |
#ifdef DEBUG_XEVENTS |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
393 |
printf("window %p: KeymapNotify!\n", data); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 |
#endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 |
/* FIXME: |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 |
X11_SetKeyboardState(SDL_Display, xevent.xkeymap.key_vector); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 |
*/ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 |
break; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 |
|
2305
fbe8ff44c519
First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2300
diff
changeset
|
401 |
/* Has the keyboard layout changed? */ |
fbe8ff44c519
First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2300
diff
changeset
|
402 |
case MappingNotify:{ |
fbe8ff44c519
First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2300
diff
changeset
|
403 |
#ifdef DEBUG_XEVENTS |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
404 |
printf("window %p: MappingNotify!\n", data); |
2305
fbe8ff44c519
First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2300
diff
changeset
|
405 |
#endif |
2306 | 406 |
X11_UpdateKeymap(_this); |
2305
fbe8ff44c519
First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2300
diff
changeset
|
407 |
} |
fbe8ff44c519
First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2300
diff
changeset
|
408 |
break; |
fbe8ff44c519
First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2300
diff
changeset
|
409 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
410 |
/* Key press? */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
411 |
case KeyPress:{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 |
KeyCode keycode = xevent.xkey.keycode; |
2300
c97ad1abe05b
Minimal implementation of textinput events for x11. It only works for latin-1.
Bob Pendleton <bob@pendleton.com>
parents:
2299
diff
changeset
|
413 |
KeySym keysym = NoSymbol; |
2306 | 414 |
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; |
2325
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
415 |
Status status = 0; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 |
#ifdef DEBUG_XEVENTS |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
418 |
printf("window %p: KeyPress (X11 keycode = 0x%X)\n", data, xevent.xkey.keycode); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 |
#endif |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
420 |
SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]); |
4535
ce811c9247da
Added back in a little more debugging for the X11 keyboard code
Sam Lantinga <slouken@libsdl.org>
parents:
4524
diff
changeset
|
421 |
#if 1 |
5981
75caa8a7d559
Fixed a whole slew of compiler warnings that -Wall exposed.
Ryan C. Gordon <icculus@icculus.org>
parents:
5603
diff
changeset
|
422 |
if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN) { |
2305
fbe8ff44c519
First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2300
diff
changeset
|
423 |
int min_keycode, max_keycode; |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
424 |
XDisplayKeycodes(display, &min_keycode, &max_keycode); |
6318
49b2cb56db6e
1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
6316
diff
changeset
|
425 |
#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM |
49b2cb56db6e
1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
6316
diff
changeset
|
426 |
keysym = XkbKeycodeToKeysym(display, keycode, 0, 0); |
49b2cb56db6e
1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
6316
diff
changeset
|
427 |
#else |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
428 |
keysym = XKeycodeToKeysym(display, keycode, 0); |
6318
49b2cb56db6e
1.Fixed a memory leak inside XInput2 code
Dimitris Zenios <dimitris.zenios@gmail.com>
parents:
6316
diff
changeset
|
429 |
#endif |
2299
a7cbc25071b6
Enabled key board auto repeat in X11_InitKeyboard.c. Had to add a couple of new Xlib symbols.
Bob Pendleton <bob@pendleton.com>
parents:
2295
diff
changeset
|
430 |
fprintf(stderr, |
4556
cc06f306c053
Fixed X error when showing debug info about a deleted property
Sam Lantinga <slouken@libsdl.org>
parents:
4535
diff
changeset
|
431 |
"The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list <sdl@libsdl.org> X11 KeyCode %d (%d), X11 KeySym 0x%lX (%s).\n", |
2305
fbe8ff44c519
First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2300
diff
changeset
|
432 |
keycode, keycode - min_keycode, keysym, |
fbe8ff44c519
First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2300
diff
changeset
|
433 |
XKeysymToString(keysym)); |
2299
a7cbc25071b6
Enabled key board auto repeat in X11_InitKeyboard.c. Had to add a couple of new Xlib symbols.
Bob Pendleton <bob@pendleton.com>
parents:
2295
diff
changeset
|
434 |
} |
2295
dbc6d1893869
Checking in Christian Walther's patch for x11 keyboard input. Minor code tweaks by Bob.
Bob Pendleton <bob@pendleton.com>
parents:
2046
diff
changeset
|
435 |
#endif |
2325
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
436 |
/* */ |
2305
fbe8ff44c519
First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2300
diff
changeset
|
437 |
SDL_zero(text); |
2325
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
438 |
#ifdef X_HAVE_UTF8_STRING |
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
439 |
if (data->ic) { |
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
440 |
Xutf8LookupString(data->ic, &xevent.xkey, text, sizeof(text), |
2738
79c1bd651f04
Fixed a bunch of compile warnings on Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2710
diff
changeset
|
441 |
&keysym, &status); |
2325
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
442 |
} |
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
443 |
#else |
2306 | 444 |
XLookupString(&xevent.xkey, text, sizeof(text), &keysym, NULL); |
2325
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :-) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
445 |
#endif |
2305
fbe8ff44c519
First pass of new SDL scancode concept for X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2300
diff
changeset
|
446 |
if (*text) { |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
447 |
SDL_SendKeyboardText(text); |
2300
c97ad1abe05b
Minimal implementation of textinput events for x11. It only works for latin-1.
Bob Pendleton <bob@pendleton.com>
parents:
2299
diff
changeset
|
448 |
} |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
450 |
break; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 |
/* Key release? */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 |
case KeyRelease:{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
454 |
KeyCode keycode = xevent.xkey.keycode; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
455 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
456 |
#ifdef DEBUG_XEVENTS |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
457 |
printf("window %p: KeyRelease (X11 keycode = 0x%X)\n", data, xevent.xkey.keycode); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 |
#endif |
4565
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
459 |
if (X11_KeyRepeat(display, &xevent)) { |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
460 |
/* We're about to get a repeated key down, ignore the key up */ |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
461 |
break; |
e2d46c5c7483
Fixed key repeat detection on X11, and simplified the code for everyone else.
Sam Lantinga <slouken@libsdl.org>
parents:
4560
diff
changeset
|
462 |
} |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
463 |
SDL_SendKeyboardKey(SDL_RELEASED, videodata->key_layout[keycode]); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
464 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
465 |
break; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 |
/* Have we been iconified? */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
468 |
case UnmapNotify:{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
469 |
#ifdef DEBUG_XEVENTS |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
470 |
printf("window %p: UnmapNotify!\n", data); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
471 |
#endif |
6481
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
472 |
X11_DispatchUnmapNotify(data); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
473 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
474 |
break; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
475 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
476 |
/* Have we been restored? */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
477 |
case MapNotify:{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 |
#ifdef DEBUG_XEVENTS |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
479 |
printf("window %p: MapNotify!\n", data); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
480 |
#endif |
6481
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
481 |
X11_DispatchMapNotify(data); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
482 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
483 |
break; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 |
/* Have we been resized or moved? */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
486 |
case ConfigureNotify:{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 |
#ifdef DEBUG_XEVENTS |
6542
5c1b8ed19212
Keep track of the configure events we've received from the X server.
Sam Lantinga <slouken@libsdl.org>
parents:
6504
diff
changeset
|
488 |
printf("window %p: ConfigureNotify! (position: %d,%d, size: %dx%d)\n", data, |
5c1b8ed19212
Keep track of the configure events we've received from the X server.
Sam Lantinga <slouken@libsdl.org>
parents:
6504
diff
changeset
|
489 |
xevent.xconfigure.x, xevent.xconfigure.y, |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 |
xevent.xconfigure.width, xevent.xconfigure.height); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
491 |
#endif |
6542
5c1b8ed19212
Keep track of the configure events we've received from the X server.
Sam Lantinga <slouken@libsdl.org>
parents:
6504
diff
changeset
|
492 |
if (xevent.xconfigure.x != data->last_xconfigure.x || |
5c1b8ed19212
Keep track of the configure events we've received from the X server.
Sam Lantinga <slouken@libsdl.org>
parents:
6504
diff
changeset
|
493 |
xevent.xconfigure.y != data->last_xconfigure.y) { |
5c1b8ed19212
Keep track of the configure events we've received from the X server.
Sam Lantinga <slouken@libsdl.org>
parents:
6504
diff
changeset
|
494 |
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_MOVED, |
5c1b8ed19212
Keep track of the configure events we've received from the X server.
Sam Lantinga <slouken@libsdl.org>
parents:
6504
diff
changeset
|
495 |
xevent.xconfigure.x, xevent.xconfigure.y); |
5c1b8ed19212
Keep track of the configure events we've received from the X server.
Sam Lantinga <slouken@libsdl.org>
parents:
6504
diff
changeset
|
496 |
} |
5c1b8ed19212
Keep track of the configure events we've received from the X server.
Sam Lantinga <slouken@libsdl.org>
parents:
6504
diff
changeset
|
497 |
if (xevent.xconfigure.width != data->last_xconfigure.width || |
5c1b8ed19212
Keep track of the configure events we've received from the X server.
Sam Lantinga <slouken@libsdl.org>
parents:
6504
diff
changeset
|
498 |
xevent.xconfigure.height != data->last_xconfigure.height) { |
5c1b8ed19212
Keep track of the configure events we've received from the X server.
Sam Lantinga <slouken@libsdl.org>
parents:
6504
diff
changeset
|
499 |
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_RESIZED, |
5c1b8ed19212
Keep track of the configure events we've received from the X server.
Sam Lantinga <slouken@libsdl.org>
parents:
6504
diff
changeset
|
500 |
xevent.xconfigure.width, |
5c1b8ed19212
Keep track of the configure events we've received from the X server.
Sam Lantinga <slouken@libsdl.org>
parents:
6504
diff
changeset
|
501 |
xevent.xconfigure.height); |
5c1b8ed19212
Keep track of the configure events we've received from the X server.
Sam Lantinga <slouken@libsdl.org>
parents:
6504
diff
changeset
|
502 |
} |
5c1b8ed19212
Keep track of the configure events we've received from the X server.
Sam Lantinga <slouken@libsdl.org>
parents:
6504
diff
changeset
|
503 |
data->last_xconfigure = xevent.xconfigure; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
504 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
505 |
break; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
506 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
507 |
/* Have we been requested to quit (or another client message?) */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 |
case ClientMessage:{ |
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
509 |
|
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
510 |
int xdnd_version=0; |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
511 |
|
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
512 |
if (xevent.xclient.message_type == videodata->XdndEnter) { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
513 |
SDL_bool use_list = xevent.xclient.data.l[1] & 1; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
514 |
data->xdnd_source = xevent.xclient.data.l[0]; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
515 |
xdnd_version = ( xevent.xclient.data.l[1] >> 24); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
516 |
if (use_list) { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
517 |
/* fetch conversion targets */ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
518 |
SDL_x11Prop p; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
519 |
X11_ReadProperty(&p, display, data->xdnd_source, videodata->XdndTypeList); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
520 |
/* pick one */ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
521 |
data->xdnd_req = X11_PickTarget(display, (Atom*)p.data, p.count); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
522 |
XFree(p.data); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
523 |
} else { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
524 |
/* pick from list of three */ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
525 |
data->xdnd_req = X11_PickTargetFromAtoms(display, xevent.xclient.data.l[2], xevent.xclient.data.l[3], xevent.xclient.data.l[4]); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
526 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
527 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
528 |
else if (xevent.xclient.message_type == videodata->XdndPosition) { |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
529 |
|
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
530 |
/* reply with status */ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
531 |
XClientMessageEvent m; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
532 |
memset(&m, 0, sizeof(XClientMessageEvent)); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
533 |
m.type = ClientMessage; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
534 |
m.display = xevent.xclient.display; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
535 |
m.window = xevent.xclient.data.l[0]; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
536 |
m.message_type = videodata->XdndStatus; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
537 |
m.format=32; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
538 |
m.data.l[0] = data->xwindow; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
539 |
m.data.l[1] = (data->xdnd_req != None); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
540 |
m.data.l[2] = 0; /* specify an empty rectangle */ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
541 |
m.data.l[3] = 0; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
542 |
m.data.l[4] = videodata->XdndActionCopy; /* we only accept copying anyway */ |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
543 |
|
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
544 |
XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
545 |
XFlush(display); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
546 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
547 |
else if(xevent.xclient.message_type == videodata->XdndDrop) { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
548 |
if (data->xdnd_req == None) { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
549 |
/* say again - not interested! */ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
550 |
XClientMessageEvent m; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
551 |
memset(&m, 0, sizeof(XClientMessageEvent)); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
552 |
m.type = ClientMessage; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
553 |
m.display = xevent.xclient.display; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
554 |
m.window = xevent.xclient.data.l[0]; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
555 |
m.message_type = videodata->XdndFinished; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
556 |
m.format=32; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
557 |
m.data.l[0] = data->xwindow; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
558 |
m.data.l[1] = 0; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
559 |
m.data.l[2] = None; /* fail! */ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
560 |
XSendEvent(display, xevent.xclient.data.l[0], False, NoEventMask, (XEvent*)&m); |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
561 |
} else { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
562 |
/* convert */ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
563 |
if(xdnd_version >= 1) { |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
564 |
XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, xevent.xclient.data.l[2]); |
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
565 |
} else { |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
566 |
XConvertSelection(display, videodata->XdndSelection, data->xdnd_req, videodata->PRIMARY, data->xwindow, CurrentTime); |
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
567 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
568 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
569 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
570 |
else if ((xevent.xclient.message_type == videodata->WM_PROTOCOLS) && |
6637
31e3f5b04120
WM_DELETE_WINDOW should check that the event message_type is WM_PROTOCOLS.
Ryan C. Gordon <icculus@icculus.org>
parents:
6542
diff
changeset
|
571 |
(xevent.xclient.format == 32) && |
6638
3d221da309d3
X11: Handle _NET_WM_PING protocol, so window manager knows when app is hung up.
Ryan C. Gordon <icculus@icculus.org>
parents:
6637
diff
changeset
|
572 |
(xevent.xclient.data.l[0] == videodata->_NET_WM_PING)) { |
6659
4016ef96095a
Fixed XBadWindow error when iconified under Unity3D
Sam Lantinga <slouken@libsdl.org>
parents:
6638
diff
changeset
|
573 |
Window root = DefaultRootWindow(display); |
6638
3d221da309d3
X11: Handle _NET_WM_PING protocol, so window manager knows when app is hung up.
Ryan C. Gordon <icculus@icculus.org>
parents:
6637
diff
changeset
|
574 |
|
3d221da309d3
X11: Handle _NET_WM_PING protocol, so window manager knows when app is hung up.
Ryan C. Gordon <icculus@icculus.org>
parents:
6637
diff
changeset
|
575 |
#ifdef DEBUG_XEVENTS |
3d221da309d3
X11: Handle _NET_WM_PING protocol, so window manager knows when app is hung up.
Ryan C. Gordon <icculus@icculus.org>
parents:
6637
diff
changeset
|
576 |
printf("window %p: _NET_WM_PING\n", data); |
3d221da309d3
X11: Handle _NET_WM_PING protocol, so window manager knows when app is hung up.
Ryan C. Gordon <icculus@icculus.org>
parents:
6637
diff
changeset
|
577 |
#endif |
3d221da309d3
X11: Handle _NET_WM_PING protocol, so window manager knows when app is hung up.
Ryan C. Gordon <icculus@icculus.org>
parents:
6637
diff
changeset
|
578 |
xevent.xclient.window = root; |
3d221da309d3
X11: Handle _NET_WM_PING protocol, so window manager knows when app is hung up.
Ryan C. Gordon <icculus@icculus.org>
parents:
6637
diff
changeset
|
579 |
XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, &xevent); |
3d221da309d3
X11: Handle _NET_WM_PING protocol, so window manager knows when app is hung up.
Ryan C. Gordon <icculus@icculus.org>
parents:
6637
diff
changeset
|
580 |
break; |
3d221da309d3
X11: Handle _NET_WM_PING protocol, so window manager knows when app is hung up.
Ryan C. Gordon <icculus@icculus.org>
parents:
6637
diff
changeset
|
581 |
} |
3d221da309d3
X11: Handle _NET_WM_PING protocol, so window manager knows when app is hung up.
Ryan C. Gordon <icculus@icculus.org>
parents:
6637
diff
changeset
|
582 |
|
3d221da309d3
X11: Handle _NET_WM_PING protocol, so window manager knows when app is hung up.
Ryan C. Gordon <icculus@icculus.org>
parents:
6637
diff
changeset
|
583 |
else if ((xevent.xclient.message_type == videodata->WM_PROTOCOLS) && |
3d221da309d3
X11: Handle _NET_WM_PING protocol, so window manager knows when app is hung up.
Ryan C. Gordon <icculus@icculus.org>
parents:
6637
diff
changeset
|
584 |
(xevent.xclient.format == 32) && |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
585 |
(xevent.xclient.data.l[0] == videodata->WM_DELETE_WINDOW)) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
586 |
|
6638
3d221da309d3
X11: Handle _NET_WM_PING protocol, so window manager knows when app is hung up.
Ryan C. Gordon <icculus@icculus.org>
parents:
6637
diff
changeset
|
587 |
#ifdef DEBUG_XEVENTS |
3d221da309d3
X11: Handle _NET_WM_PING protocol, so window manager knows when app is hung up.
Ryan C. Gordon <icculus@icculus.org>
parents:
6637
diff
changeset
|
588 |
printf("window %p: WM_DELETE_WINDOW\n", data); |
3d221da309d3
X11: Handle _NET_WM_PING protocol, so window manager knows when app is hung up.
Ryan C. Gordon <icculus@icculus.org>
parents:
6637
diff
changeset
|
589 |
#endif |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3322
diff
changeset
|
590 |
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_CLOSE, 0, 0); |
6638
3d221da309d3
X11: Handle _NET_WM_PING protocol, so window manager knows when app is hung up.
Ryan C. Gordon <icculus@icculus.org>
parents:
6637
diff
changeset
|
591 |
break; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
592 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
593 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
594 |
break; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
595 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
596 |
/* Do we need to refresh ourselves? */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
597 |
case Expose:{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
598 |
#ifdef DEBUG_XEVENTS |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
599 |
printf("window %p: Expose (count = %d)\n", data, xevent.xexpose.count); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
600 |
#endif |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3322
diff
changeset
|
601 |
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_EXPOSED, 0, 0); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
602 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
603 |
break; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
604 |
|
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
605 |
case MotionNotify:{ |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
606 |
SDL_Mouse *mouse = SDL_GetMouse(); |
6311
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
607 |
if(!mouse->relative_mode) { |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2328
diff
changeset
|
608 |
#ifdef DEBUG_MOTION |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
609 |
printf("window %p: X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y); |
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2328
diff
changeset
|
610 |
#endif |
6311
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
611 |
|
6950
1ddb72193079
Added a mouse ID to the mouse events, which set to the special value SDL_TOUCH_MOUSEID for mouse events simulated by touch input.
Sam Lantinga <slouken@libsdl.org>
parents:
6885
diff
changeset
|
612 |
SDL_SendMouseMotion(data->window, 0, 0, xevent.xmotion.x, xevent.xmotion.y); |
6311
4e5e46f43438
Initial support for XInput2 by Dimitris Zenios
Sam Lantinga <slouken@libsdl.org>
parents:
6184
diff
changeset
|
613 |
} |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
614 |
} |
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
615 |
break; |
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
616 |
|
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
617 |
case ButtonPress:{ |
5530
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
618 |
int ticks = 0; |
6950
1ddb72193079
Added a mouse ID to the mouse events, which set to the special value SDL_TOUCH_MOUSEID for mouse events simulated by touch input.
Sam Lantinga <slouken@libsdl.org>
parents:
6885
diff
changeset
|
619 |
if (X11_IsWheelEvent(display,&xevent,&ticks)) { |
1ddb72193079
Added a mouse ID to the mouse events, which set to the special value SDL_TOUCH_MOUSEID for mouse events simulated by touch input.
Sam Lantinga <slouken@libsdl.org>
parents:
6885
diff
changeset
|
620 |
SDL_SendMouseWheel(data->window, 0, 0, ticks); |
1ddb72193079
Added a mouse ID to the mouse events, which set to the special value SDL_TOUCH_MOUSEID for mouse events simulated by touch input.
Sam Lantinga <slouken@libsdl.org>
parents:
6885
diff
changeset
|
621 |
} else { |
1ddb72193079
Added a mouse ID to the mouse events, which set to the special value SDL_TOUCH_MOUSEID for mouse events simulated by touch input.
Sam Lantinga <slouken@libsdl.org>
parents:
6885
diff
changeset
|
622 |
SDL_SendMouseButton(data->window, 0, SDL_PRESSED, xevent.xbutton.button); |
5530
4e46a7b6773d
Fixed bug 1173 (No mouse wheel event on linux/x11)
Sam Lantinga <slouken@libsdl.org>
parents:
5481
diff
changeset
|
623 |
} |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
624 |
} |
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
625 |
break; |
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
626 |
|
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
627 |
case ButtonRelease:{ |
6950
1ddb72193079
Added a mouse ID to the mouse events, which set to the special value SDL_TOUCH_MOUSEID for mouse events simulated by touch input.
Sam Lantinga <slouken@libsdl.org>
parents:
6885
diff
changeset
|
628 |
SDL_SendMouseButton(data->window, 0, SDL_RELEASED, xevent.xbutton.button); |
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
629 |
} |
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
630 |
break; |
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
631 |
|
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
632 |
case PropertyNotify:{ |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
633 |
#ifdef DEBUG_XEVENTS |
4520
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
634 |
unsigned char *propdata; |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
635 |
int status, real_format; |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
636 |
Atom real_type; |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
637 |
unsigned long items_read, items_left, i; |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
638 |
|
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
639 |
char *name = XGetAtomName(display, xevent.xproperty.atom); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
640 |
if (name) { |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
641 |
printf("window %p: PropertyNotify: %s %s\n", data, name, (xevent.xproperty.state == PropertyDelete) ? "deleted" : "changed"); |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
642 |
XFree(name); |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
643 |
} |
4520
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
644 |
|
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
645 |
status = XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata); |
4556
cc06f306c053
Fixed X error when showing debug info about a deleted property
Sam Lantinga <slouken@libsdl.org>
parents:
4535
diff
changeset
|
646 |
if (status == Success && items_read > 0) { |
4520
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
647 |
if (real_type == XA_INTEGER) { |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
648 |
int *values = (int *)propdata; |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
649 |
|
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
650 |
printf("{"); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
651 |
for (i = 0; i < items_read; i++) { |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
652 |
printf(" %d", values[i]); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
653 |
} |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
654 |
printf(" }\n"); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
655 |
} else if (real_type == XA_CARDINAL) { |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
656 |
if (real_format == 32) { |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
657 |
Uint32 *values = (Uint32 *)propdata; |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
658 |
|
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
659 |
printf("{"); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
660 |
for (i = 0; i < items_read; i++) { |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
661 |
printf(" %d", values[i]); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
662 |
} |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
663 |
printf(" }\n"); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
664 |
} else if (real_format == 16) { |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
665 |
Uint16 *values = (Uint16 *)propdata; |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
666 |
|
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
667 |
printf("{"); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
668 |
for (i = 0; i < items_read; i++) { |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
669 |
printf(" %d", values[i]); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
670 |
} |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
671 |
printf(" }\n"); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
672 |
} else if (real_format == 8) { |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
673 |
Uint8 *values = (Uint8 *)propdata; |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
674 |
|
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
675 |
printf("{"); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
676 |
for (i = 0; i < items_read; i++) { |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
677 |
printf(" %d", values[i]); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
678 |
} |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
679 |
printf(" }\n"); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
680 |
} |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
681 |
} else if (real_type == XA_STRING || |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
682 |
real_type == videodata->UTF8_STRING) { |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
683 |
printf("{ \"%s\" }\n", propdata); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
684 |
} else if (real_type == XA_ATOM) { |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
685 |
Atom *atoms = (Atom *)propdata; |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
686 |
|
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
687 |
printf("{"); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
688 |
for (i = 0; i < items_read; i++) { |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
689 |
char *name = XGetAtomName(display, atoms[i]); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
690 |
if (name) { |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
691 |
printf(" %s", name); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
692 |
XFree(name); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
693 |
} |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
694 |
} |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
695 |
printf(" }\n"); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
696 |
} else { |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
697 |
char *name = XGetAtomName(display, real_type); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
698 |
printf("Unknown type: %ld (%s)\n", real_type, name ? name : "UNKNOWN"); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
699 |
if (name) { |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
700 |
XFree(name); |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
701 |
} |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
702 |
} |
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
703 |
} |
6481
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
704 |
if (status == Success) { |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
705 |
XFree(propdata); |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
706 |
} |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
707 |
#endif /* DEBUG_XEVENTS */ |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
708 |
|
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
709 |
if (xevent.xproperty.atom == data->videodata->_NET_WM_STATE) { |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
710 |
/* Get the new state from the window manager. |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
711 |
Compositing window managers can alter visibility of windows |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
712 |
without ever mapping / unmapping them, so we handle that here, |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
713 |
because they use the NETWM protocol to notify us of changes. |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
714 |
*/ |
6487
b18a011ecc45
Simplified the NetWM code a little bit, and it now operates on X11 Window
Sam Lantinga <slouken@libsdl.org>
parents:
6481
diff
changeset
|
715 |
Uint32 flags = X11_GetNetWMState(_this, xevent.xproperty.window); |
6481
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
716 |
if ((flags^data->window->flags) & SDL_WINDOW_HIDDEN) { |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
717 |
if (flags & SDL_WINDOW_HIDDEN) { |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
718 |
X11_DispatchUnmapNotify(data); |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
719 |
} else { |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
720 |
X11_DispatchMapNotify(data); |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
721 |
} |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
722 |
} |
fab4b15b17e9
Compositing window managers can show and hide windows without ever affecting the mapped state. However they do send NetWM protocol messages to indicate this is happening.
Sam Lantinga <slouken@libsdl.org>
parents:
6476
diff
changeset
|
723 |
} |
4518
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
724 |
} |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
725 |
break; |
a956a315fe67
Lots of prep for the "real" way to support fullscreen mode on modern window managers.
Sam Lantinga <slouken@libsdl.org>
parents:
4508
diff
changeset
|
726 |
|
4508
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
727 |
/* Copy the selection from XA_CUT_BUFFER0 to the requested property */ |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
728 |
case SelectionRequest: { |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
729 |
XSelectionRequestEvent *req; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
730 |
XEvent sevent; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
731 |
int seln_format; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
732 |
unsigned long nbytes; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
733 |
unsigned long overflow; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
734 |
unsigned char *seln_data; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
735 |
|
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
736 |
req = &xevent.xselectionrequest; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
737 |
#ifdef DEBUG_XEVENTS |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
738 |
printf("window %p: SelectionRequest (requestor = %ld, target = %ld)\n", data, |
4508
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
739 |
req->requestor, req->target); |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
740 |
#endif |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
741 |
|
4524
a256e1dadf3f
Zero any fields not explicitly filled in.
Sam Lantinga <slouken@libsdl.org>
parents:
4520
diff
changeset
|
742 |
SDL_zero(sevent); |
4520
0c67c4328678
Much better debugging of property changes
Sam Lantinga <slouken@libsdl.org>
parents:
4519
diff
changeset
|
743 |
sevent.xany.type = SelectionNotify; |
4508
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
744 |
sevent.xselection.selection = req->selection; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
745 |
sevent.xselection.target = None; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
746 |
sevent.xselection.property = None; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
747 |
sevent.xselection.requestor = req->requestor; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
748 |
sevent.xselection.time = req->time; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
749 |
if (XGetWindowProperty(display, DefaultRootWindow(display), |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
750 |
XA_CUT_BUFFER0, 0, INT_MAX/4, False, req->target, |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
751 |
&sevent.xselection.target, &seln_format, &nbytes, |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
752 |
&overflow, &seln_data) == Success) { |
7021
eba9097a07dc
Make SDL support the X11 clipboard TARGETS protocol, which advertises what formats text is available in from the application. This is necessary for many Linux programs to interact well with the clipboard.
Sam Lantinga <slouken@libsdl.org>
parents:
7001
diff
changeset
|
753 |
Atom XA_TARGETS = XInternAtom(display, "TARGETS", 0); |
4508
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
754 |
if (sevent.xselection.target == req->target) { |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
755 |
XChangeProperty(display, req->requestor, req->property, |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
756 |
sevent.xselection.target, seln_format, PropModeReplace, |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
757 |
seln_data, nbytes); |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
758 |
sevent.xselection.property = req->property; |
7021
eba9097a07dc
Make SDL support the X11 clipboard TARGETS protocol, which advertises what formats text is available in from the application. This is necessary for many Linux programs to interact well with the clipboard.
Sam Lantinga <slouken@libsdl.org>
parents:
7001
diff
changeset
|
759 |
} else if (XA_TARGETS == req->target) { |
eba9097a07dc
Make SDL support the X11 clipboard TARGETS protocol, which advertises what formats text is available in from the application. This is necessary for many Linux programs to interact well with the clipboard.
Sam Lantinga <slouken@libsdl.org>
parents:
7001
diff
changeset
|
760 |
Atom SupportedFormats[] = { sevent.xselection.target, XA_TARGETS }; |
eba9097a07dc
Make SDL support the X11 clipboard TARGETS protocol, which advertises what formats text is available in from the application. This is necessary for many Linux programs to interact well with the clipboard.
Sam Lantinga <slouken@libsdl.org>
parents:
7001
diff
changeset
|
761 |
XChangeProperty(display, req->requestor, req->property, |
eba9097a07dc
Make SDL support the X11 clipboard TARGETS protocol, which advertises what formats text is available in from the application. This is necessary for many Linux programs to interact well with the clipboard.
Sam Lantinga <slouken@libsdl.org>
parents:
7001
diff
changeset
|
762 |
XA_ATOM, 32, PropModeReplace, |
eba9097a07dc
Make SDL support the X11 clipboard TARGETS protocol, which advertises what formats text is available in from the application. This is necessary for many Linux programs to interact well with the clipboard.
Sam Lantinga <slouken@libsdl.org>
parents:
7001
diff
changeset
|
763 |
(unsigned char*)SupportedFormats, |
eba9097a07dc
Make SDL support the X11 clipboard TARGETS protocol, which advertises what formats text is available in from the application. This is necessary for many Linux programs to interact well with the clipboard.
Sam Lantinga <slouken@libsdl.org>
parents:
7001
diff
changeset
|
764 |
sizeof(SupportedFormats)/sizeof(*SupportedFormats)); |
eba9097a07dc
Make SDL support the X11 clipboard TARGETS protocol, which advertises what formats text is available in from the application. This is necessary for many Linux programs to interact well with the clipboard.
Sam Lantinga <slouken@libsdl.org>
parents:
7001
diff
changeset
|
765 |
sevent.xselection.property = req->property; |
4508
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
766 |
} |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
767 |
XFree(seln_data); |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
768 |
} |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
769 |
XSendEvent(display, req->requestor, False, 0, &sevent); |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
770 |
XSync(display, False); |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
771 |
} |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
772 |
break; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
773 |
|
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
774 |
case SelectionNotify: { |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
775 |
#ifdef DEBUG_XEVENTS |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
776 |
printf("window %p: SelectionNotify (requestor = %ld, target = %ld)\n", data, |
4508
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
777 |
xevent.xselection.requestor, xevent.xselection.target); |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
778 |
#endif |
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
779 |
Atom target = xevent.xselection.target; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
780 |
if (target == data->xdnd_req) { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
781 |
/* read data */ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
782 |
SDL_x11Prop p; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
783 |
X11_ReadProperty(&p, display, data->xwindow, videodata->PRIMARY); |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
784 |
|
7396
a36ab6149a10
Fixed bug 1953 - Crash at memcpy X11_DispatchEvent(_THIS) Function
Sam Lantinga <slouken@libsdl.org>
parents:
7214
diff
changeset
|
785 |
if (p.format == 8) { |
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
786 |
SDL_bool expect_lf = SDL_FALSE; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
787 |
char *start = NULL; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
788 |
char *scan = (char*)p.data; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
789 |
char *fn; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
790 |
char *uri; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
791 |
int length = 0; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
792 |
while (p.count--) { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
793 |
if (!expect_lf) { |
7396
a36ab6149a10
Fixed bug 1953 - Crash at memcpy X11_DispatchEvent(_THIS) Function
Sam Lantinga <slouken@libsdl.org>
parents:
7214
diff
changeset
|
794 |
if (*scan == 0x0D) { |
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
795 |
expect_lf = SDL_TRUE; |
7396
a36ab6149a10
Fixed bug 1953 - Crash at memcpy X11_DispatchEvent(_THIS) Function
Sam Lantinga <slouken@libsdl.org>
parents:
7214
diff
changeset
|
796 |
} |
a36ab6149a10
Fixed bug 1953 - Crash at memcpy X11_DispatchEvent(_THIS) Function
Sam Lantinga <slouken@libsdl.org>
parents:
7214
diff
changeset
|
797 |
if (start == NULL) { |
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
798 |
start = scan; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
799 |
length = 0; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
800 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
801 |
length++; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
802 |
} else { |
7396
a36ab6149a10
Fixed bug 1953 - Crash at memcpy X11_DispatchEvent(_THIS) Function
Sam Lantinga <slouken@libsdl.org>
parents:
7214
diff
changeset
|
803 |
if (*scan == 0x0A && length > 0) { |
a36ab6149a10
Fixed bug 1953 - Crash at memcpy X11_DispatchEvent(_THIS) Function
Sam Lantinga <slouken@libsdl.org>
parents:
7214
diff
changeset
|
804 |
uri = SDL_malloc(length--); |
a36ab6149a10
Fixed bug 1953 - Crash at memcpy X11_DispatchEvent(_THIS) Function
Sam Lantinga <slouken@libsdl.org>
parents:
7214
diff
changeset
|
805 |
SDL_memcpy(uri, start, length); |
a36ab6149a10
Fixed bug 1953 - Crash at memcpy X11_DispatchEvent(_THIS) Function
Sam Lantinga <slouken@libsdl.org>
parents:
7214
diff
changeset
|
806 |
uri[length] = '\0'; |
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
807 |
fn = X11_URIToLocal(uri); |
7396
a36ab6149a10
Fixed bug 1953 - Crash at memcpy X11_DispatchEvent(_THIS) Function
Sam Lantinga <slouken@libsdl.org>
parents:
7214
diff
changeset
|
808 |
if (fn) { |
a36ab6149a10
Fixed bug 1953 - Crash at memcpy X11_DispatchEvent(_THIS) Function
Sam Lantinga <slouken@libsdl.org>
parents:
7214
diff
changeset
|
809 |
SDL_SendDropFile(fn); |
a36ab6149a10
Fixed bug 1953 - Crash at memcpy X11_DispatchEvent(_THIS) Function
Sam Lantinga <slouken@libsdl.org>
parents:
7214
diff
changeset
|
810 |
} |
a36ab6149a10
Fixed bug 1953 - Crash at memcpy X11_DispatchEvent(_THIS) Function
Sam Lantinga <slouken@libsdl.org>
parents:
7214
diff
changeset
|
811 |
SDL_free(uri); |
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
812 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
813 |
expect_lf = SDL_FALSE; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
814 |
start = NULL; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
815 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
816 |
scan++; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
817 |
} |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
818 |
} |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
819 |
|
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
820 |
XFree(p.data); |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
821 |
|
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
822 |
/* send reply */ |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
823 |
XClientMessageEvent m; |
7396
a36ab6149a10
Fixed bug 1953 - Crash at memcpy X11_DispatchEvent(_THIS) Function
Sam Lantinga <slouken@libsdl.org>
parents:
7214
diff
changeset
|
824 |
SDL_memset(&m, 0, sizeof(XClientMessageEvent)); |
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
825 |
m.type = ClientMessage; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
826 |
m.display = display; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
827 |
m.window = data->xdnd_source; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
828 |
m.message_type = videodata->XdndFinished; |
7396
a36ab6149a10
Fixed bug 1953 - Crash at memcpy X11_DispatchEvent(_THIS) Function
Sam Lantinga <slouken@libsdl.org>
parents:
7214
diff
changeset
|
829 |
m.format = 32; |
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
830 |
m.data.l[0] = data->xwindow; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
831 |
m.data.l[1] = 1; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
832 |
m.data.l[2] = videodata->XdndActionCopy; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
833 |
XSendEvent(display, data->xdnd_source, False, NoEventMask, (XEvent*)&m); |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
834 |
|
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
835 |
XSync(display, False); |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
836 |
|
7001
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
837 |
} else { |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
838 |
videodata->selection_waiting = SDL_FALSE; |
ccc0d3207639
XDnD implementation from Davey Taylor, need some cleanup
Sam Lantinga <slouken@libsdl.org>
parents:
6951
diff
changeset
|
839 |
} |
4508
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
840 |
} |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
841 |
break; |
15d2c6f40c48
Added X11 clipboard support.
Sam Lantinga <slouken@libsdl.org>
parents:
4484
diff
changeset
|
842 |
|
4465
3e69e077cb95
Removed multi-mouse / multi-keyboard support in anticipation of a real multi-mouse and multi-touch API.
Sam Lantinga <slouken@libsdl.org>
parents:
4429
diff
changeset
|
843 |
default:{ |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
844 |
#ifdef DEBUG_XEVENTS |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
845 |
printf("window %p: Unhandled event %d\n", data, xevent.type); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
846 |
#endif |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
847 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
848 |
break; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
849 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
850 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
851 |
|
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
852 |
static void |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
853 |
X11_HandleFocusChanges(_THIS) |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
854 |
{ |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
855 |
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
856 |
int i; |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
857 |
|
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
858 |
if (videodata && videodata->windowlist) { |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
859 |
for (i = 0; i < videodata->numwindows; ++i) { |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
860 |
SDL_WindowData *data = videodata->windowlist[i]; |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
861 |
if (data && data->pending_focus != PENDING_FOCUS_NONE) { |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
862 |
Uint32 now = SDL_GetTicks(); |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
863 |
if ( (int)(data->pending_focus_time-now) <= 0 ) { |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
864 |
if ( data->pending_focus == PENDING_FOCUS_IN ) { |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
865 |
X11_DispatchFocusIn(data); |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
866 |
} else { |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
867 |
X11_DispatchFocusOut(data); |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
868 |
} |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
869 |
data->pending_focus = PENDING_FOCUS_NONE; |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
870 |
} |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
871 |
} |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
872 |
} |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
873 |
} |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
874 |
} |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
875 |
/* Ack! XPending() actually performs a blocking read if no events available */ |
4472
791b3256fb22
Mostly cleaned up warnings with -Wmissing-prototypes
Sam Lantinga <slouken@libsdl.org>
parents:
4465
diff
changeset
|
876 |
static int |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
877 |
X11_Pending(Display * display) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
878 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
879 |
/* Flush the display connection and look to see if events are queued */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
880 |
XFlush(display); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
881 |
if (XEventsQueued(display, QueuedAlready)) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
882 |
return (1); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
883 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
884 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
885 |
/* More drastic measures are required -- see if X is ready to talk */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
886 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
887 |
static struct timeval zero_time; /* static == 0 */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
888 |
int x11_fd; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
889 |
fd_set fdset; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
890 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
891 |
x11_fd = ConnectionNumber(display); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
892 |
FD_ZERO(&fdset); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
893 |
FD_SET(x11_fd, &fdset); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
894 |
if (select(x11_fd + 1, &fdset, NULL, NULL, &zero_time) == 1) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
895 |
return (XPending(display)); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
896 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
897 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
898 |
|
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
899 |
/* Oh well, nothing is ready .. */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
900 |
return (0); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
901 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
902 |
|
5981
75caa8a7d559
Fixed a whole slew of compiler warnings that -Wall exposed.
Ryan C. Gordon <icculus@icculus.org>
parents:
5603
diff
changeset
|
903 |
|
75caa8a7d559
Fixed a whole slew of compiler warnings that -Wall exposed.
Ryan C. Gordon <icculus@icculus.org>
parents:
5603
diff
changeset
|
904 |
/* !!! FIXME: this should be exposed in a header, or something. */ |
75caa8a7d559
Fixed a whole slew of compiler warnings that -Wall exposed.
Ryan C. Gordon <icculus@icculus.org>
parents:
5603
diff
changeset
|
905 |
int SDL_GetNumTouch(void); |
6774
ad8522052ce6
Replaced Gnome screensaver hack with D-Bus messages to org.gnome.ScreenSaver.
Ryan C. Gordon <icculus@icculus.org>
parents:
6661
diff
changeset
|
906 |
void SDL_dbus_screensaver_tickle(_THIS); |
5981
75caa8a7d559
Fixed a whole slew of compiler warnings that -Wall exposed.
Ryan C. Gordon <icculus@icculus.org>
parents:
5603
diff
changeset
|
907 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
908 |
void |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
909 |
X11_PumpEvents(_THIS) |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
910 |
{ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
911 |
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
912 |
|
3025
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
3015
diff
changeset
|
913 |
/* Update activity every 30 seconds to prevent screensaver */ |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
3015
diff
changeset
|
914 |
if (_this->suspend_screensaver) { |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
3015
diff
changeset
|
915 |
Uint32 now = SDL_GetTicks(); |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
3015
diff
changeset
|
916 |
if (!data->screensaver_activity || |
3040 | 917 |
(int) (now - data->screensaver_activity) >= 30000) { |
3025
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
3015
diff
changeset
|
918 |
XResetScreenSaver(data->display); |
6774
ad8522052ce6
Replaced Gnome screensaver hack with D-Bus messages to org.gnome.ScreenSaver.
Ryan C. Gordon <icculus@icculus.org>
parents:
6661
diff
changeset
|
919 |
|
ad8522052ce6
Replaced Gnome screensaver hack with D-Bus messages to org.gnome.ScreenSaver.
Ryan C. Gordon <icculus@icculus.org>
parents:
6661
diff
changeset
|
920 |
#if SDL_USE_LIBDBUS |
ad8522052ce6
Replaced Gnome screensaver hack with D-Bus messages to org.gnome.ScreenSaver.
Ryan C. Gordon <icculus@icculus.org>
parents:
6661
diff
changeset
|
921 |
SDL_dbus_screensaver_tickle(_this); |
ad8522052ce6
Replaced Gnome screensaver hack with D-Bus messages to org.gnome.ScreenSaver.
Ryan C. Gordon <icculus@icculus.org>
parents:
6661
diff
changeset
|
922 |
#endif |
ad8522052ce6
Replaced Gnome screensaver hack with D-Bus messages to org.gnome.ScreenSaver.
Ryan C. Gordon <icculus@icculus.org>
parents:
6661
diff
changeset
|
923 |
|
3025
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
3015
diff
changeset
|
924 |
data->screensaver_activity = now; |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
3015
diff
changeset
|
925 |
} |
7191
75360622e65f
File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents:
7097
diff
changeset
|
926 |
} |
3025
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
3015
diff
changeset
|
927 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
928 |
/* Keep processing pending events */ |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
929 |
while (X11_Pending(data->display)) { |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
930 |
X11_DispatchEvent(_this); |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
931 |
} |
6504
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
932 |
|
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
933 |
/* FIXME: Only need to do this when there are pending focus changes */ |
100c49578dba
We need to queue the focus in/out changes because they may occur during video mode changes and we can respond to them by triggering more mode changes.
Sam Lantinga <slouken@libsdl.org>
parents:
6487
diff
changeset
|
934 |
X11_HandleFocusChanges(_this); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
935 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
936 |
|
3030
f13ad181f5b2
This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents:
3025
diff
changeset
|
937 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
938 |
void |
3025
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
3015
diff
changeset
|
939 |
X11_SuspendScreenSaver(_THIS) |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
940 |
{ |
5408
35a63789c3f2
Dynamically load the Xinerama and xf86vmode extensions
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
941 |
#if SDL_VIDEO_DRIVER_X11_XSCRNSAVER |
3025
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
3015
diff
changeset
|
942 |
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
3015
diff
changeset
|
943 |
int dummy; |
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
3015
diff
changeset
|
944 |
int major_version, minor_version; |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
945 |
|
3030
f13ad181f5b2
This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents:
3025
diff
changeset
|
946 |
if (SDL_X11_HAVE_XSS) { |
f13ad181f5b2
This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents:
3025
diff
changeset
|
947 |
/* XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */ |
f13ad181f5b2
This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents:
3025
diff
changeset
|
948 |
if (!XScreenSaverQueryExtension(data->display, &dummy, &dummy) || |
f13ad181f5b2
This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents:
3025
diff
changeset
|
949 |
!XScreenSaverQueryVersion(data->display, |
f13ad181f5b2
This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents:
3025
diff
changeset
|
950 |
&major_version, &minor_version) || |
f13ad181f5b2
This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents:
3025
diff
changeset
|
951 |
major_version < 1 || (major_version == 1 && minor_version < 1)) { |
f13ad181f5b2
This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents:
3025
diff
changeset
|
952 |
return; |
f13ad181f5b2
This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents:
3025
diff
changeset
|
953 |
} |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
954 |
|
3030
f13ad181f5b2
This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents:
3025
diff
changeset
|
955 |
XScreenSaverSuspend(data->display, _this->suspend_screensaver); |
f13ad181f5b2
This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents:
3025
diff
changeset
|
956 |
XResetScreenSaver(data->display); |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
957 |
} |
3030
f13ad181f5b2
This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents:
3025
diff
changeset
|
958 |
#endif |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
959 |
|
6774
ad8522052ce6
Replaced Gnome screensaver hack with D-Bus messages to org.gnome.ScreenSaver.
Ryan C. Gordon <icculus@icculus.org>
parents:
6661
diff
changeset
|
960 |
#if SDL_USE_LIBDBUS |
3030
f13ad181f5b2
This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents:
3025
diff
changeset
|
961 |
if (_this->suspend_screensaver) { |
6774
ad8522052ce6
Replaced Gnome screensaver hack with D-Bus messages to org.gnome.ScreenSaver.
Ryan C. Gordon <icculus@icculus.org>
parents:
6661
diff
changeset
|
962 |
SDL_dbus_screensaver_tickle(_this); |
3030
f13ad181f5b2
This is so wrong, it hurts.
Sam Lantinga <slouken@libsdl.org>
parents:
3025
diff
changeset
|
963 |
} |
3025
54fac87e1f34
Added an API to enable/disable the screen saver.
Sam Lantinga <slouken@libsdl.org>
parents:
3015
diff
changeset
|
964 |
#endif |
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
965 |
} |
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
966 |
|
5481
22dfc3958dc3
Fixed so code will compile with SDL_config_minimal.h
Sam Lantinga <slouken@libsdl.org>
parents:
5408
diff
changeset
|
967 |
#endif /* SDL_VIDEO_DRIVER_X11 */ |
22dfc3958dc3
Fixed so code will compile with SDL_config_minimal.h
Sam Lantinga <slouken@libsdl.org>
parents:
5408
diff
changeset
|
968 |
|
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
969 |
/* vi: set ts=4 sw=4 expandtab: */ |