Mercurial > sdl-ios-xcode
annotate src/video/gem/SDL_gemwm.c @ 3978:b966761fef6c SDL-1.2
Significantly improved XIM support.
Fixes Bugzilla #429.
Selected notes from the patch's README:
= FIXES =
This patch fixes the above issues as follows.
== X11 events ==
Moved XFilterEvent just after XNextEvent so that all events are passed
to it. Also, XFilterEvent will receive masks indicated by IM through
XNFilterEvents IC value as well as masks surpplied by SDL.
X11_KeyRepeat is called between XNextEvent and XFilterEvent, after
testing an event is a KeyRelease. I'm not 100% comfortable to do so,
but I couldn't find a better timing to call it, and use of the
function is inevitable.
== Xutf8LookupString ==
Used a longer buffer to receive UTF-8 string. If it is insufficient,
a dynamic storage of the requested size will be allocated. The
initial size of the buffer is set to 32, because the Japanese text
converted from the most widely used benchmark key sequence for
Japanese IM, "WATASHINONAMAEHANAKANODESU." has ten Japanese characters
in it, that occupies 30 bytes when encoded in UTF-8.
== SDL_keysym.unicode ==
On Windows version of SDL implementation, SDL_keysym.unicode stores
UTF-16 encoded unicode characters, one UTF-16 encoding unit per an SDL
event. A Unicode supplementary characters are sent to an application
as two events. (One with a high surrogate and another with a low
surrogate.) The behavior seems reasonable since it is upward
compatible with existing handling of BMP characters.
I wrote a UTF-8 to UTF-16 conversion function for the purpose. It is
designed with the execution speed in mind, having a minimum set of
features that my patch requires.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Mon, 25 Jun 2007 19:58:32 +0000 |
parents | 5d14acfdf84d |
children | a1b03ba2fcd0 |
rev | line source |
---|---|
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1080
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1080
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1080
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1080
diff
changeset
|
13 Lesser General Public License for more details. |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1080
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1080
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1080
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
22 #include "SDL_config.h" |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 /* |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
25 GEM SDL video driver |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
26 Window manager functions |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
27 |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
28 Patrice Mandin |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
29 */ |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 /* Mint includes */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 #include <gem.h> |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 #include "SDL_gemwm_c.h" |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 /* Defines */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 #define ICONWIDTH 64 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 #define ICONHEIGHT 64 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 /* Functions */ |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 void GEM_SetCaption(_THIS, const char *title, const char *icon) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 { |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
45 if (title) { |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 GEM_title_name = title; |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
47 GEM_refresh_name = SDL_TRUE; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
50 if (icon) { |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
51 GEM_icon_name = icon; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
52 GEM_refresh_name = SDL_TRUE; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 void GEM_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 { |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
58 SDL_Surface *sicon; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
59 SDL_Rect bounds; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
60 |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
61 #if 0 |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
62 if ((GEM_wfeatures & (1<<WF_ICONIFY))==0) { |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
63 return; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
64 } |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
65 #endif |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
66 |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
67 if (icon == NULL) { |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 return; |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
69 } |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
70 |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
71 /* Convert icon to the screen format */ |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
72 sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h, |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
73 VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, 0); |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
74 if ( sicon == NULL ) { |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
75 return; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
76 } |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
78 bounds.x = 0; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
79 bounds.y = 0; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
80 bounds.w = icon->w; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
81 bounds.h = icon->h; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
82 if ( SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0 ) { |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
83 SDL_FreeSurface(sicon); |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
84 return; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
85 } |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
86 |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
87 GEM_icon = sicon; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 int GEM_IconifyWindow(_THIS) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 { |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 if ((GEM_wfeatures & (1<<WF_ICONIFY))==0) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 return 0; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
95 GEM_message[0] = WM_ICONIFY; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
96 GEM_message[1] = gl_apid; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
97 GEM_message[2] = 0; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
98 GEM_message[3] = GEM_handle; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
99 GEM_message[4] = 0; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
100 GEM_message[5] = GEM_desk_h-ICONHEIGHT; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
101 GEM_message[6] = ICONWIDTH; |
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
102 GEM_message[7] = ICONHEIGHT; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 |
736
028e03e273c8
Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents:
557
diff
changeset
|
104 appl_write(gl_apid, sizeof(GEM_message), GEM_message); |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 return 1; |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 } |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 SDL_GrabMode GEM_GrabInput(_THIS, SDL_GrabMode mode) |
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 { |
3859
5d14acfdf84d
Allow grabing mouse by locking its position
Patrice Mandin <patmandin@gmail.com>
parents:
1402
diff
changeset
|
111 if (this->screen == NULL) { |
5d14acfdf84d
Allow grabing mouse by locking its position
Patrice Mandin <patmandin@gmail.com>
parents:
1402
diff
changeset
|
112 return SDL_GRAB_OFF; |
5d14acfdf84d
Allow grabing mouse by locking its position
Patrice Mandin <patmandin@gmail.com>
parents:
1402
diff
changeset
|
113 } |
5d14acfdf84d
Allow grabing mouse by locking its position
Patrice Mandin <patmandin@gmail.com>
parents:
1402
diff
changeset
|
114 |
5d14acfdf84d
Allow grabing mouse by locking its position
Patrice Mandin <patmandin@gmail.com>
parents:
1402
diff
changeset
|
115 return mode; |
281
c5010ab8ba35
Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 } |