Updated SDL 1.3 to rev. 4563, fixed compilation
This commit is contained in:
@@ -10,4 +10,5 @@ MultiABI=n
|
||||
AppVersionCode=110003
|
||||
AppVersionName="1.1.0.p3"
|
||||
CompiledLibraries="sdl_mixer sdl_image"
|
||||
AppCflags='-finline-functions -O2'
|
||||
ReadmeText='^Use accelerometer to navigate menus and control ship^Press "Menu" to select menu and for secondary fire^Press "Call" or touch screen for primary fire^Press "Volume Up/Down" to cycle through weapons'
|
||||
|
||||
@@ -25,7 +25,7 @@ SDL_VIDEO_RENDER_RESIZE := 1
|
||||
|
||||
COMPILED_LIBRARIES := sdl_mixer sdl_image
|
||||
|
||||
APPLICATION_ADDITIONAL_CFLAGS :=
|
||||
APPLICATION_ADDITIONAL_CFLAGS := -finline-functions -O2
|
||||
|
||||
# If SDL_Mixer should link to libMAD
|
||||
SDL_MIXER_USE_LIBMAD :=
|
||||
|
||||
@@ -4,9 +4,7 @@ include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := application
|
||||
|
||||
APP_SUBDIRS := $(patsubst $(LOCAL_PATH)/%, %, $(shell find $(LOCAL_PATH)/src -type d))
|
||||
|
||||
# Add more subdirs here, like src/subdir1 src/subdir2
|
||||
APP_SUBDIRS := $(patsubst $(LOCAL_PATH)/%, %, $(shell find $(LOCAL_PATH)/src/ -type d))
|
||||
|
||||
LOCAL_CFLAGS := $(foreach D, $(APP_SUBDIRS), -I$(LOCAL_PATH)/$(D)) \
|
||||
-I$(LOCAL_PATH)/../sdl/include \
|
||||
|
||||
@@ -40,6 +40,10 @@
|
||||
/*@}*/
|
||||
|
||||
#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */
|
||||
#ifdef __linux__
|
||||
#include <endian.h>
|
||||
#define SDL_BYTEORDER __BYTE_ORDER
|
||||
#else /* __linux __ */
|
||||
#if defined(__hppa__) || \
|
||||
defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
|
||||
(defined(__MIPS__) && defined(__MISPEB__)) || \
|
||||
@@ -49,6 +53,7 @@
|
||||
#else
|
||||
#define SDL_BYTEORDER SDL_LIL_ENDIAN
|
||||
#endif
|
||||
#endif /* __linux __ */
|
||||
#endif /* !SDL_BYTEORDER */
|
||||
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ typedef struct SDL_KeyboardEvent
|
||||
Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
|
||||
Uint32 windowID; /**< The window with keyboard focus, if any */
|
||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
||||
Uint8 padding1;
|
||||
Uint8 repeat; /**< Non-zero if this is a key repeat */
|
||||
Uint8 padding2;
|
||||
Uint8 padding3;
|
||||
SDL_keysym keysym; /**< The key that was pressed or released */
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define SDL_REVISION "hg-4510:6f8175ad0335"
|
||||
#define SDL_REVISION "hg-4563:ffd169948438"
|
||||
|
||||
@@ -213,7 +213,7 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo;
|
||||
/**
|
||||
* \brief This function allows access to driver-dependent window information.
|
||||
*
|
||||
* \param windowID The window about which information is being requested
|
||||
* \param window The window about which information is being requested
|
||||
* \param info This structure must be initialized with the SDL version, and is
|
||||
* then filled in with information about the given window.
|
||||
*
|
||||
|
||||
@@ -74,15 +74,15 @@ extern AudioBootStrap ANDROIDAUD_bootstrap;
|
||||
|
||||
/* Available audio drivers */
|
||||
static const AudioBootStrap *const bootstrap[] = {
|
||||
#if SDL_AUDIO_DRIVER_BSD
|
||||
&BSD_AUDIO_bootstrap,
|
||||
#endif
|
||||
#if SDL_AUDIO_DRIVER_PULSEAUDIO
|
||||
&PULSEAUDIO_bootstrap,
|
||||
#endif
|
||||
#if SDL_AUDIO_DRIVER_ALSA
|
||||
&ALSA_bootstrap,
|
||||
#endif
|
||||
#if SDL_AUDIO_DRIVER_BSD
|
||||
&BSD_AUDIO_bootstrap,
|
||||
#endif
|
||||
#if SDL_AUDIO_DRIVER_OSS
|
||||
&DSP_bootstrap,
|
||||
&DMA_bootstrap,
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h> /* For close() */
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_audiodev_c.h"
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
#ifndef _directx_h
|
||||
#define _directx_h
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define NONAMELESSUNION
|
||||
#endif
|
||||
|
||||
/* Include all of the DirectX 5.0 headers and adds any necessary tweaks */
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
@@ -566,7 +566,7 @@ SDL_ResetKeyboard(void)
|
||||
|
||||
for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
|
||||
if (keyboard->keystate[scancode] == SDL_PRESSED) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, scancode);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, scancode, SDL_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -627,7 +627,7 @@ SDL_SetKeyboardFocus(SDL_Window * window)
|
||||
}
|
||||
|
||||
int
|
||||
SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode)
|
||||
SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode, SDL_bool repeat)
|
||||
{
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
int posted;
|
||||
@@ -732,7 +732,7 @@ SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode)
|
||||
}
|
||||
|
||||
/* Drop events that don't change state */
|
||||
if (keyboard->keystate[scancode] == state) {
|
||||
if (keyboard->keystate[scancode] == state && !repeat) {
|
||||
#if 0
|
||||
printf("Keyboard event didn't change state - dropped!\n");
|
||||
#endif
|
||||
@@ -748,6 +748,7 @@ SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode)
|
||||
SDL_Event event;
|
||||
event.key.type = type;
|
||||
event.key.state = state;
|
||||
event.key.repeat = repeat ? 1 : 0;
|
||||
event.key.keysym.scancode = scancode;
|
||||
event.key.keysym.sym = keyboard->keymap[scancode];
|
||||
event.key.keysym.mod = modstate;
|
||||
@@ -764,6 +765,11 @@ SDL_SendKeyboardText(const char *text)
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
int posted;
|
||||
|
||||
/* Don't post text events for unprintable characters */
|
||||
if (*text < ' ' || *text == 127) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Post the event, if desired */
|
||||
posted = 0;
|
||||
if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
|
||||
|
||||
@@ -49,7 +49,7 @@ extern void SDL_SetScancodeName(SDL_scancode scancode, const char *name);
|
||||
extern void SDL_SetKeyboardFocus(SDL_Window * window);
|
||||
|
||||
/* Send a keyboard key event */
|
||||
extern int SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode);
|
||||
extern int SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode, SDL_bool repeat);
|
||||
|
||||
/* Send keyboard text input */
|
||||
extern int SDL_SendKeyboardText(const char *text);
|
||||
|
||||
@@ -203,14 +203,14 @@ static const SDL_scancode win32_scancode_table[] = {
|
||||
/* 173, 0xad */ SDL_SCANCODE_AUDIOMUTE,
|
||||
/* 174, 0xae */ SDL_SCANCODE_VOLUMEDOWN,
|
||||
/* 175, 0xaf */ SDL_SCANCODE_VOLUMEUP,
|
||||
/* 176, 0xb0 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 177, 0xb1 */ SDL_SCANCODE_KP_000,
|
||||
/* 178, 0xb2 */ SDL_SCANCODE_KP_EQUALS,
|
||||
/* 179, 0xb3 */ SDL_SCANCODE_KP_00,
|
||||
/* 180, 0xb4 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 181, 0xb5 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 182, 0xb6 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 183, 0xb7 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 176, 0xb0 */ SDL_SCANCODE_AUDIONEXT,
|
||||
/* 177, 0xb1 */ SDL_SCANCODE_AUDIOPREV,
|
||||
/* 178, 0xb2 */ SDL_SCANCODE_AUDIOSTOP,
|
||||
/* 179, 0xb3 */ SDL_SCANCODE_AUDIOPLAY,
|
||||
/* 180, 0xb4 */ SDL_SCANCODE_MAIL,
|
||||
/* 181, 0xb5 */ SDL_SCANCODE_MEDIASELECT,
|
||||
/* 182, 0xb6 */ SDL_SCANCODE_UNKNOWN, /* VK_LAUNCH_APP1 */
|
||||
/* 183, 0xb7 */ SDL_SCANCODE_UNKNOWN, /* VK_LAUNCH_APP2 */
|
||||
/* 184, 0xb8 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 185, 0xb9 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 186, 0xba */ SDL_SCANCODE_SEMICOLON,
|
||||
|
||||
@@ -262,24 +262,24 @@ static const SDL_scancode xfree86_scancode_table2[] = {
|
||||
/* 81 */ SDL_SCANCODE_KP_3,
|
||||
/* 82 */ SDL_SCANCODE_KP_0,
|
||||
/* 83 */ SDL_SCANCODE_KP_PERIOD,
|
||||
/* 84 */ SDL_SCANCODE_SYSREQ, /* ???? */
|
||||
/* 85 */ SDL_SCANCODE_MODE, /* ???? */
|
||||
/* 84 */ SDL_SCANCODE_SYSREQ, /* ???? */
|
||||
/* 85 */ SDL_SCANCODE_MODE, /* ???? */
|
||||
/* 86 */ SDL_SCANCODE_NONUSBACKSLASH,
|
||||
/* 87 */ SDL_SCANCODE_F11,
|
||||
/* 88 */ SDL_SCANCODE_F12,
|
||||
/* 89 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 90 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 91 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 92 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 93 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 94 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 90 */ SDL_SCANCODE_UNKNOWN, /* Katakana */
|
||||
/* 91 */ SDL_SCANCODE_UNKNOWN, /* Hiragana */
|
||||
/* 92 */ SDL_SCANCODE_UNKNOWN, /* Henkan_Mode */
|
||||
/* 93 */ SDL_SCANCODE_UNKNOWN, /* Hiragana_Katakana */
|
||||
/* 94 */ SDL_SCANCODE_UNKNOWN, /* Muhenkan */
|
||||
/* 95 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 96 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 96 */ SDL_SCANCODE_KP_ENTER,
|
||||
/* 97 */ SDL_SCANCODE_RCTRL,
|
||||
/* 98 */ SDL_SCANCODE_KP_DIVIDE,
|
||||
/* 99 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 100 */ SDL_SCANCODE_RALT, /* ISO_Level3_Shift, ALTGR, RALT */
|
||||
/* 101 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 99 */ SDL_SCANCODE_PRINTSCREEN,
|
||||
/* 100 */ SDL_SCANCODE_RALT, /* ISO_Level3_Shift, ALTGR, RALT */
|
||||
/* 101 */ SDL_SCANCODE_UNKNOWN, /* Linefeed */
|
||||
/* 102 */ SDL_SCANCODE_HOME,
|
||||
/* 103 */ SDL_SCANCODE_UP,
|
||||
/* 104 */ SDL_SCANCODE_PAGEUP,
|
||||
@@ -291,40 +291,132 @@ static const SDL_scancode xfree86_scancode_table2[] = {
|
||||
/* 110 */ SDL_SCANCODE_INSERT,
|
||||
/* 111 */ SDL_SCANCODE_DELETE,
|
||||
/* 112 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 113 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 114 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 115 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 116 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 117 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 118 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 119 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 120 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 121 */ SDL_SCANCODE_PAUSE,
|
||||
/* 122 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 123 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 113 */ SDL_SCANCODE_MUTE,
|
||||
/* 114 */ SDL_SCANCODE_VOLUMEDOWN,
|
||||
/* 115 */ SDL_SCANCODE_VOLUMEUP,
|
||||
/* 116 */ SDL_SCANCODE_POWER,
|
||||
/* 117 */ SDL_SCANCODE_KP_EQUALS,
|
||||
/* 118 */ SDL_SCANCODE_UNKNOWN, /* plusminus */
|
||||
/* 119 */ SDL_SCANCODE_PAUSE,
|
||||
/* 120 */ SDL_SCANCODE_UNKNOWN, /* XF86LaunchA */
|
||||
/* 121 */ SDL_SCANCODE_UNKNOWN, /* KP_Decimal */
|
||||
/* 122 */ SDL_SCANCODE_UNKNOWN, /* Hangul */
|
||||
/* 123 */ SDL_SCANCODE_UNKNOWN, /* Hangul_Hanja */
|
||||
/* 124 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 125 */ SDL_SCANCODE_LGUI,
|
||||
/* 126 */ SDL_SCANCODE_RGUI,
|
||||
/* 127 */ SDL_SCANCODE_APPLICATION,
|
||||
/* 128 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 129 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 130 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 131 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 132 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 133 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 134 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 135 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 136 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 137 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 138 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 139 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 140 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 141 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 142 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 143 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 144 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 145 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 146 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 125 */ SDL_SCANCODE_LGUI,
|
||||
/* 126 */ SDL_SCANCODE_RGUI,
|
||||
/* 127 */ SDL_SCANCODE_APPLICATION,
|
||||
/* 128 */ SDL_SCANCODE_CANCEL,
|
||||
/* 129 */ SDL_SCANCODE_AGAIN,
|
||||
/* 130 */ SDL_SCANCODE_UNKNOWN, /* SunProps */
|
||||
/* 131 */ SDL_SCANCODE_UNDO,
|
||||
/* 132 */ SDL_SCANCODE_UNKNOWN, /* SunFront */
|
||||
/* 133 */ SDL_SCANCODE_COPY,
|
||||
/* 134 */ SDL_SCANCODE_UNKNOWN, /* SunOpen */
|
||||
/* 135 */ SDL_SCANCODE_PASTE,
|
||||
/* 136 */ SDL_SCANCODE_FIND,
|
||||
/* 137 */ SDL_SCANCODE_CUT,
|
||||
/* 138 */ SDL_SCANCODE_HELP,
|
||||
/* 139 */ SDL_SCANCODE_UNKNOWN, /* XF86MenuKB */
|
||||
/* 140 */ SDL_SCANCODE_CALCULATOR,
|
||||
/* 141 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 142 */ SDL_SCANCODE_SLEEP,
|
||||
/* 143 */ SDL_SCANCODE_UNKNOWN, /* XF86WakeUp */
|
||||
/* 144 */ SDL_SCANCODE_UNKNOWN, /* XF86Explorer */
|
||||
/* 145 */ SDL_SCANCODE_UNKNOWN, /* XF86Send */
|
||||
/* 146 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 147 */ SDL_SCANCODE_UNKNOWN, /* XF86Xfer */
|
||||
/* 148 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch1 */
|
||||
/* 149 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch2 */
|
||||
/* 150 */ SDL_SCANCODE_WWW,
|
||||
/* 151 */ SDL_SCANCODE_UNKNOWN, /* XF86DOS */
|
||||
/* 152 */ SDL_SCANCODE_UNKNOWN, /* XF86ScreenSaver */
|
||||
/* 153 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 154 */ SDL_SCANCODE_UNKNOWN, /* XF86RotateWindows */
|
||||
/* 155 */ SDL_SCANCODE_MAIL,
|
||||
/* 156 */ SDL_SCANCODE_UNKNOWN, /* XF86Favorites */
|
||||
/* 157 */ SDL_SCANCODE_COMPUTER,
|
||||
/* 158 */ SDL_SCANCODE_AC_BACK,
|
||||
/* 159 */ SDL_SCANCODE_AC_FORWARD,
|
||||
/* 160 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 161 */ SDL_SCANCODE_EJECT,
|
||||
/* 162 */ SDL_SCANCODE_EJECT,
|
||||
/* 163 */ SDL_SCANCODE_AUDIONEXT,
|
||||
/* 164 */ SDL_SCANCODE_AUDIOPLAY,
|
||||
/* 165 */ SDL_SCANCODE_AUDIOPREV,
|
||||
/* 166 */ SDL_SCANCODE_AUDIOSTOP,
|
||||
/* 167 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioRecord */
|
||||
/* 168 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioRewind */
|
||||
/* 169 */ SDL_SCANCODE_UNKNOWN, /* XF86Phone */
|
||||
/* 170 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 171 */ SDL_SCANCODE_UNKNOWN, /* XF86Tools */
|
||||
/* 172 */ SDL_SCANCODE_AC_HOME,
|
||||
/* 173 */ SDL_SCANCODE_AC_REFRESH,
|
||||
/* 174 */ SDL_SCANCODE_UNKNOWN, /* XF86Close */
|
||||
/* 175 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 176 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 177 */ SDL_SCANCODE_UNKNOWN, /* XF86ScrollUp */
|
||||
/* 178 */ SDL_SCANCODE_UNKNOWN, /* XF86ScrollDown */
|
||||
/* 179 */ SDL_SCANCODE_UNKNOWN, /* parenleft */
|
||||
/* 180 */ SDL_SCANCODE_UNKNOWN, /* parenright */
|
||||
/* 181 */ SDL_SCANCODE_UNKNOWN, /* XF86New */
|
||||
/* 182 */ SDL_SCANCODE_AGAIN,
|
||||
/* 183 */ SDL_SCANCODE_UNKNOWN, /* XF86Tools */
|
||||
/* 184 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch5 */
|
||||
/* 185 */ SDL_SCANCODE_UNKNOWN, /* XF86MenuKB */
|
||||
/* 186 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 187 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 188 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 189 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 190 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 191 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 192 */ SDL_SCANCODE_UNKNOWN, /* XF86TouchpadToggle */
|
||||
/* 193 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 194 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 195 */ SDL_SCANCODE_MODE,
|
||||
/* 196 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 197 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 198 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 199 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 200 */ SDL_SCANCODE_AUDIOPLAY,
|
||||
/* 201 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioPause */
|
||||
/* 202 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch3 */
|
||||
/* 203 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch4 */
|
||||
/* 204 */ SDL_SCANCODE_UNKNOWN, /* XF86LaunchB */
|
||||
/* 205 */ SDL_SCANCODE_UNKNOWN, /* XF86Suspend */
|
||||
/* 206 */ SDL_SCANCODE_UNKNOWN, /* XF86Close */
|
||||
/* 207 */ SDL_SCANCODE_AUDIOPLAY,
|
||||
/* 208 */ SDL_SCANCODE_AUDIONEXT,
|
||||
/* 209 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 210 */ SDL_SCANCODE_PRINTSCREEN,
|
||||
/* 211 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 212 */ SDL_SCANCODE_UNKNOWN, /* XF86WebCam */
|
||||
/* 213 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 214 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 215 */ SDL_SCANCODE_MAIL,
|
||||
/* 216 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 217 */ SDL_SCANCODE_AC_SEARCH,
|
||||
/* 218 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 219 */ SDL_SCANCODE_UNKNOWN, /* XF86Finance */
|
||||
/* 220 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 221 */ SDL_SCANCODE_UNKNOWN, /* XF86Shop */
|
||||
/* 222 */ SDL_SCANCODE_UNKNOWN,
|
||||
/* 223 */ SDL_SCANCODE_STOP,
|
||||
/* 224 */ SDL_SCANCODE_BRIGHTNESSDOWN,
|
||||
/* 225 */ SDL_SCANCODE_BRIGHTNESSUP,
|
||||
/* 226 */ SDL_SCANCODE_MEDIASELECT,
|
||||
/* 227 */ SDL_SCANCODE_DISPLAYSWITCH,
|
||||
/* 228 */ SDL_SCANCODE_KBDILLUMTOGGLE,
|
||||
/* 229 */ SDL_SCANCODE_KBDILLUMDOWN,
|
||||
/* 230 */ SDL_SCANCODE_KBDILLUMUP,
|
||||
/* 231 */ SDL_SCANCODE_UNKNOWN, /* XF86Send */
|
||||
/* 232 */ SDL_SCANCODE_UNKNOWN, /* XF86Reply */
|
||||
/* 233 */ SDL_SCANCODE_UNKNOWN, /* XF86MailForward */
|
||||
/* 234 */ SDL_SCANCODE_UNKNOWN, /* XF86Save */
|
||||
/* 235 */ SDL_SCANCODE_UNKNOWN, /* XF86Documents */
|
||||
/* 236 */ SDL_SCANCODE_UNKNOWN, /* XF86Battery */
|
||||
/* 237 */ SDL_SCANCODE_UNKNOWN, /* XF86Bluetooth */
|
||||
/* 238 */ SDL_SCANCODE_UNKNOWN, /* XF86WLAN */
|
||||
};
|
||||
|
||||
/* *INDENT-ON* */
|
||||
|
||||
@@ -254,8 +254,6 @@ SDL_SYS_HapticName(int index)
|
||||
static int
|
||||
SDL_SYS_HapticOpenFromFD(SDL_Haptic * haptic, int fd)
|
||||
{
|
||||
const char *name;
|
||||
|
||||
/* Allocate the hwdata */
|
||||
haptic->hwdata = (struct haptic_hwdata *)
|
||||
SDL_malloc(sizeof(*haptic->hwdata));
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
#include <libusbhid.h>
|
||||
#endif
|
||||
|
||||
#ifdef __FREEBSD__
|
||||
#ifdef defined(__FREEBSD__) || defined(__FreeBSD_kernel__)
|
||||
#ifndef __DragonFly__
|
||||
#include <osreldate.h>
|
||||
#endif
|
||||
@@ -78,7 +78,7 @@
|
||||
#define MAX_JOY_JOYS 2
|
||||
#define MAX_JOYS (MAX_UHID_JOYS + MAX_JOY_JOYS)
|
||||
|
||||
#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)
|
||||
#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) && false
|
||||
struct usb_ctl_report {
|
||||
int ucr_report;
|
||||
u_char ucr_data[1024]; /* filled data size will vary */
|
||||
@@ -149,7 +149,7 @@ static char *joydevnames[MAX_JOYS];
|
||||
static int report_alloc(struct report *, struct report_desc *, int);
|
||||
static void report_free(struct report *);
|
||||
|
||||
#if defined(USBHID_UCR_DATA) || (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063))
|
||||
#if defined(USBHID_UCR_DATA) || (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)) || defined(__FreeBSD_kernel__)
|
||||
#define REP_BUF_DATA(rep) ((rep)->buf->ucr_data)
|
||||
#else
|
||||
#define REP_BUF_DATA(rep) ((rep)->buf->data)
|
||||
@@ -308,7 +308,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy)
|
||||
goto usberr;
|
||||
}
|
||||
rep = &hw->inreport;
|
||||
#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)
|
||||
#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) || defined(__FreeBSD_kernel__)
|
||||
rep->rid = hid_get_report_id(fd);
|
||||
if (rep->rid < 0) {
|
||||
#else
|
||||
@@ -324,7 +324,7 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joy)
|
||||
hw->path);
|
||||
goto usberr;
|
||||
}
|
||||
#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111)
|
||||
#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__)
|
||||
hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid);
|
||||
#else
|
||||
hdata = hid_start_parse(hw->repdesc, 1 << hid_input);
|
||||
@@ -409,7 +409,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joy)
|
||||
int nbutton, naxe = -1;
|
||||
Sint32 v;
|
||||
|
||||
#if defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
|
||||
#if defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H || defined(__FreeBSD_kernel__)
|
||||
struct joystick gameport;
|
||||
static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0;
|
||||
|
||||
@@ -466,7 +466,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joy)
|
||||
if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) {
|
||||
return;
|
||||
}
|
||||
#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111)
|
||||
#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__)
|
||||
hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid);
|
||||
#else
|
||||
hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input);
|
||||
|
||||
@@ -71,6 +71,7 @@ ParseCommandLine(char *cmdline, char **argv)
|
||||
++argc;
|
||||
}
|
||||
/* Skip over word */
|
||||
lastp = bufp;
|
||||
while (*bufp && (*bufp != '"' || *lastp == '\\')) {
|
||||
lastp = bufp;
|
||||
++bufp;
|
||||
|
||||
@@ -38,4 +38,5 @@ extern int SDL_SYS_StartTimer(void);
|
||||
|
||||
/* Stop a previously started timer */
|
||||
extern void SDL_SYS_StopTimer(void);
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "../SDL_systimer.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
|
||||
/* The clock_gettime provides monotonous time, so we should use it if
|
||||
|
||||
@@ -795,7 +795,6 @@ SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||
const SDL_Rect * srcrect, const SDL_Rect * dstrect)
|
||||
{
|
||||
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
|
||||
SDL_Window *window = renderer->window;
|
||||
int status;
|
||||
|
||||
if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
|
||||
|
||||
@@ -80,7 +80,7 @@ generate_rowbytes(int src_w, int dst_w, int bpp)
|
||||
|
||||
int i;
|
||||
int pos, inc;
|
||||
unsigned char *eip;
|
||||
unsigned char *eip, *fence;
|
||||
unsigned char load, store;
|
||||
|
||||
/* See if we need to regenerate the copy buffer */
|
||||
@@ -116,14 +116,21 @@ generate_rowbytes(int src_w, int dst_w, int bpp)
|
||||
pos = 0x10000;
|
||||
inc = (src_w << 16) / dst_w;
|
||||
eip = copy_row;
|
||||
fence = copy_row + sizeof(copy_row)-2;
|
||||
for (i = 0; i < dst_w; ++i) {
|
||||
while (pos >= 0x10000L) {
|
||||
if (eip == fence) {
|
||||
return -1;
|
||||
}
|
||||
if (bpp == 2) {
|
||||
*eip++ = PREFIX16;
|
||||
}
|
||||
*eip++ = load;
|
||||
pos -= 0x10000L;
|
||||
}
|
||||
if (eip == fence) {
|
||||
return -1;
|
||||
}
|
||||
if (bpp == 2) {
|
||||
*eip++ = PREFIX16;
|
||||
}
|
||||
@@ -132,11 +139,6 @@ generate_rowbytes(int src_w, int dst_w, int bpp)
|
||||
}
|
||||
*eip++ = RETURN;
|
||||
|
||||
/* Verify that we didn't overflow (too late!!!) */
|
||||
if (eip > (copy_row + sizeof(copy_row))) {
|
||||
SDL_SetError("Copy buffer overflow");
|
||||
return (-1);
|
||||
}
|
||||
#ifdef HAVE_MPROTECT
|
||||
/* Make the code executable but not writeable */
|
||||
if (mprotect(copy_row, sizeof(copy_row), PROT_READ | PROT_EXEC) < 0) {
|
||||
|
||||
@@ -3451,7 +3451,7 @@ SDL_GL_SwapWindow(SDL_Window * window)
|
||||
void
|
||||
SDL_GL_DeleteContext(SDL_GLContext context)
|
||||
{
|
||||
if (!_this || !context) {
|
||||
if (!_this || !_this->gl_data || !context) {
|
||||
return;
|
||||
}
|
||||
_this->GL_MakeCurrent(_this, NULL, NULL);
|
||||
|
||||
@@ -219,14 +219,14 @@ DoUnsidedModifiers(unsigned short scancode,
|
||||
if (oldMask && oldMask != newMask) { /* modifier up event */
|
||||
/* If this was Caps Lock, we need some additional voodoo to make SDL happy */
|
||||
if (bit == NSAlphaShiftKeyMask) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, mapping[i]);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, mapping[i], SDL_FALSE);
|
||||
}
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, mapping[i]);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, mapping[i], SDL_FALSE);
|
||||
} else if (newMask && oldMask != newMask) { /* modifier down event */
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, mapping[i]);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, mapping[i], SDL_FALSE);
|
||||
/* If this was Caps Lock, we need some additional voodoo to make SDL happy */
|
||||
if (bit == NSAlphaShiftKeyMask) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, mapping[i]);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, mapping[i], SDL_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,9 +251,9 @@ HandleNonDeviceModifier(unsigned int device_independent_mask,
|
||||
newMask = newMods & device_independent_mask;
|
||||
|
||||
if (oldMask && oldMask != newMask) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, scancode);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, scancode, SDL_FALSE);
|
||||
} else if (newMask && oldMask != newMask) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, scancode);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, scancode, SDL_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,9 +278,9 @@ HandleModifierOneSide(unsigned int oldMods, unsigned int newMods,
|
||||
* find out which it is.
|
||||
*/
|
||||
if (new_dep_mask && old_dep_mask != new_dep_mask) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, scancode);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, scancode, SDL_FALSE);
|
||||
} else {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, scancode);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, scancode, SDL_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ ReleaseModifierSide(unsigned int device_independent_mask,
|
||||
/* In this case, we can't detect the keyboard, so use the left side
|
||||
* to represent both, and release it.
|
||||
*/
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, left_scancode);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, left_scancode, SDL_FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -362,10 +362,10 @@ ReleaseModifierSide(unsigned int device_independent_mask,
|
||||
* so I hope this doesn't cause other problems.
|
||||
*/
|
||||
if ( left_device_dependent_mask & oldMods ) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, left_scancode);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, left_scancode, SDL_FALSE);
|
||||
}
|
||||
if ( right_device_dependent_mask & oldMods ) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, right_scancode);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, right_scancode, SDL_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,16 +382,16 @@ HandleCapsLock(unsigned short scancode,
|
||||
newMask = newMods & NSAlphaShiftKeyMask;
|
||||
|
||||
if (oldMask != newMask) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK, SDL_FALSE);
|
||||
}
|
||||
|
||||
oldMask = oldMods & NSNumericPadKeyMask;
|
||||
newMask = newMods & NSNumericPadKeyMask;
|
||||
|
||||
if (oldMask != newMask) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR, SDL_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -670,6 +670,7 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
unsigned short scancode = [event keyCode];
|
||||
SDL_scancode code;
|
||||
SDL_bool repeat;
|
||||
#if 0
|
||||
const char *text;
|
||||
#endif
|
||||
@@ -688,17 +689,18 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
||||
|
||||
switch ([event type]) {
|
||||
case NSKeyDown:
|
||||
if (![event isARepeat]) {
|
||||
repeat = [event isARepeat] ? SDL_TRUE : SDL_FALSE;
|
||||
if (!repeat) {
|
||||
/* See if we need to rebuild the keyboard layout */
|
||||
UpdateKeymap(data);
|
||||
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, code);
|
||||
#if 1
|
||||
if (code == SDL_SCANCODE_UNKNOWN) {
|
||||
fprintf(stderr, "The key you just pressed is not recognized by SDL. To help get this fixed, report this to the SDL mailing list <sdl@libsdl.org> or to Christian Walther <cwalther@gmx.ch>. Mac virtual key code is %d.\n", scancode);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, code, repeat);
|
||||
#if 1
|
||||
if (code == SDL_SCANCODE_UNKNOWN) {
|
||||
fprintf(stderr, "The key you just pressed is not recognized by SDL. To help get this fixed, report this to the SDL mailing list <sdl@libsdl.org> or to Christian Walther <cwalther@gmx.ch>. Mac virtual key code is %d.\n", scancode);
|
||||
}
|
||||
#endif
|
||||
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
|
||||
/* FIXME CW 2007-08-16: only send those events to the field editor for which we actually want text events, not e.g. esc or function keys. Arrow keys in particular seem to produce crashes sometimes. */
|
||||
[data->fieldEdit interpretKeyEvents:[NSArray arrayWithObject:event]];
|
||||
@@ -712,7 +714,7 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
||||
}
|
||||
break;
|
||||
case NSKeyUp:
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, code);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, code, SDL_FALSE);
|
||||
break;
|
||||
case NSFlagsChanged:
|
||||
/* FIXME CW 2007-08-14: check if this whole mess that takes up half of this file is really necessary */
|
||||
|
||||
@@ -245,8 +245,8 @@
|
||||
|
||||
if ([string length] == 0) {
|
||||
/* it wants to replace text with nothing, ie a delete */
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE, SDL_FALSE);
|
||||
}
|
||||
else {
|
||||
/* go through all the characters in the string we've been sent
|
||||
@@ -272,14 +272,14 @@
|
||||
|
||||
if (mod & KMOD_SHIFT) {
|
||||
/* If character uses shift, press shift down */
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT, SDL_FALSE);
|
||||
}
|
||||
/* send a keydown and keyup even for the character */
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, code);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, code);
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, code, SDL_FALSE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, code, SDL_FALSE);
|
||||
if (mod & KMOD_SHIFT) {
|
||||
/* If character uses shift, press shift back up */
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT, SDL_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,10 +83,14 @@ RemapVKEY(WPARAM wParam, LPARAM lParam)
|
||||
except they don't have the extended bit (0x1000000) set.
|
||||
*/
|
||||
if (!(lParam & 0x1000000)) {
|
||||
for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) {
|
||||
if (scancode == keypad_scancodes[i]) {
|
||||
wParam = VK_NUMPAD0 + i;
|
||||
break;
|
||||
if (wParam == VK_DELETE) {
|
||||
wParam = VK_DECIMAL;
|
||||
} else {
|
||||
for (i = 0; i < SDL_arraysize(keypad_scancodes); ++i) {
|
||||
if (scancode == keypad_scancodes[i]) {
|
||||
wParam = VK_NUMPAD0 + i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -201,10 +205,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
case WM_SYSKEYDOWN:
|
||||
case WM_KEYDOWN:
|
||||
{
|
||||
/* Ignore repeated keys */
|
||||
SDL_bool repeat;
|
||||
|
||||
if (lParam & REPEATED_KEYMASK) {
|
||||
returnCode = 0;
|
||||
break;
|
||||
repeat = SDL_TRUE;
|
||||
} else {
|
||||
repeat = SDL_FALSE;
|
||||
}
|
||||
|
||||
wParam = RemapVKEY(wParam, lParam);
|
||||
@@ -244,7 +250,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
if (wParam < 256) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED,
|
||||
data->videodata->key_layout[wParam]);
|
||||
data->videodata->key_layout[wParam],
|
||||
repeat);
|
||||
}
|
||||
}
|
||||
returnCode = 0;
|
||||
@@ -294,11 +301,13 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
&& SDL_GetKeyboardState(NULL)[SDL_SCANCODE_PRINTSCREEN] ==
|
||||
SDL_RELEASED) {
|
||||
SDL_SendKeyboardKey(SDL_PRESSED,
|
||||
data->videodata->key_layout[wParam]);
|
||||
data->videodata->key_layout[wParam],
|
||||
SDL_FALSE);
|
||||
}
|
||||
if (wParam < 256) {
|
||||
SDL_SendKeyboardKey(SDL_RELEASED,
|
||||
data->videodata->key_layout[wParam]);
|
||||
data->videodata->key_layout[wParam],
|
||||
SDL_FALSE);
|
||||
}
|
||||
}
|
||||
returnCode = 0;
|
||||
|
||||
@@ -101,8 +101,7 @@ WIN_UpdateKeymap()
|
||||
|
||||
/* Make sure this scancode is a valid character scancode */
|
||||
scancode = win32_scancode_table[i];
|
||||
if (scancode == SDL_SCANCODE_UNKNOWN ||
|
||||
(keymap[scancode] & SDLK_SCANCODE_MASK)) {
|
||||
if (scancode == SDL_SCANCODE_UNKNOWN || keymap[scancode] >= 127) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
|
||||
/* If you don't support UTF-8, you might use XA_STRING here */
|
||||
#if 1
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
#define TEXT_FORMAT XInternAtom(display, "UTF8_STRING", False)
|
||||
#else
|
||||
#define TEXT_FORMAT XA_STRING
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h> /* For INT_MAX */
|
||||
#include <limits.h> /* For INT_MAX */
|
||||
|
||||
#include "SDL_x11video.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
@@ -40,12 +40,13 @@ static void
|
||||
X11_DispatchEvent(_THIS)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||
Display *display = videodata->display;
|
||||
SDL_WindowData *data;
|
||||
XEvent xevent;
|
||||
int i;
|
||||
|
||||
SDL_zero(xevent); /* valgrind fix. --ryan. */
|
||||
XNextEvent(videodata->display, &xevent);
|
||||
XNextEvent(display, &xevent);
|
||||
|
||||
/* filter events catchs XIM events and sends them to the correct
|
||||
handler */
|
||||
@@ -80,6 +81,7 @@ X11_DispatchEvent(_THIS)
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
||||
#if 0
|
||||
printf("type = %d display = %d window = %d\n",
|
||||
xevent.type, xevent.xany.display, xevent.xany.window);
|
||||
@@ -90,8 +92,8 @@ X11_DispatchEvent(_THIS)
|
||||
case EnterNotify:{
|
||||
#ifdef DEBUG_XEVENTS
|
||||
printf("EnterNotify! (%d,%d,%d)\n",
|
||||
xevent.xcrossing.x,
|
||||
xevent.xcrossing.y,
|
||||
xevent.xcrossing.x,
|
||||
xevent.xcrossing.y,
|
||||
xevent.xcrossing.mode);
|
||||
if (xevent.xcrossing.mode == NotifyGrab)
|
||||
printf("Mode: NotifyGrab\n");
|
||||
@@ -106,15 +108,17 @@ X11_DispatchEvent(_THIS)
|
||||
case LeaveNotify:{
|
||||
#ifdef DEBUG_XEVENTS
|
||||
printf("LeaveNotify! (%d,%d,%d)\n",
|
||||
xevent.xcrossing.x,
|
||||
xevent.xcrossing.y,
|
||||
xevent.xcrossing.x,
|
||||
xevent.xcrossing.y,
|
||||
xevent.xcrossing.mode);
|
||||
if (xevent.xcrossing.mode == NotifyGrab)
|
||||
printf("Mode: NotifyGrab\n");
|
||||
if (xevent.xcrossing.mode == NotifyUngrab)
|
||||
printf("Mode: NotifyUngrab\n");
|
||||
#endif
|
||||
if (xevent.xcrossing.detail != NotifyInferior) {
|
||||
if (xevent.xcrossing.mode != NotifyGrab &&
|
||||
xevent.xcrossing.mode != NotifyUngrab &&
|
||||
xevent.xcrossing.detail != NotifyInferior) {
|
||||
SDL_SetMouseFocus(NULL);
|
||||
}
|
||||
}
|
||||
@@ -178,15 +182,15 @@ X11_DispatchEvent(_THIS)
|
||||
#ifdef DEBUG_XEVENTS
|
||||
printf("KeyPress (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
|
||||
#endif
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]);
|
||||
#if 0
|
||||
/* FIXME: How do we tell if this was a key repeat? */
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode], SDL_FALSE);
|
||||
#if 1
|
||||
if (videodata->key_layout[keycode] == SDLK_UNKNOWN) {
|
||||
int min_keycode, max_keycode;
|
||||
XDisplayKeycodes(videodata->display, &min_keycode,
|
||||
&max_keycode);
|
||||
keysym = XKeycodeToKeysym(videodata->display, keycode, 0);
|
||||
XDisplayKeycodes(display, &min_keycode, &max_keycode);
|
||||
keysym = XKeycodeToKeysym(display, keycode, 0);
|
||||
fprintf(stderr,
|
||||
"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%X (%s).\n",
|
||||
"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",
|
||||
keycode, keycode - min_keycode, keysym,
|
||||
XKeysymToString(keysym));
|
||||
}
|
||||
@@ -214,7 +218,7 @@ X11_DispatchEvent(_THIS)
|
||||
#ifdef DEBUG_XEVENTS
|
||||
printf("KeyRelease (X11 keycode = 0x%X)\n", xevent.xkey.keycode);
|
||||
#endif
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, videodata->key_layout[keycode]);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, videodata->key_layout[keycode], SDL_FALSE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -289,9 +293,84 @@ X11_DispatchEvent(_THIS)
|
||||
}
|
||||
break;
|
||||
|
||||
case PropertyNotify:{
|
||||
#ifdef DEBUG_XEVENTS
|
||||
unsigned char *propdata;
|
||||
int status, real_format;
|
||||
Atom real_type;
|
||||
unsigned long items_read, items_left, i;
|
||||
|
||||
char *name = XGetAtomName(display, xevent.xproperty.atom);
|
||||
if (name) {
|
||||
printf("PropertyNotify: %s %s\n", name, (xevent.xproperty.state == PropertyDelete) ? "deleted" : "changed");
|
||||
XFree(name);
|
||||
}
|
||||
|
||||
status = XGetWindowProperty(display, data->xwindow, xevent.xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata);
|
||||
if (status == Success && items_read > 0) {
|
||||
if (real_type == XA_INTEGER) {
|
||||
int *values = (int *)propdata;
|
||||
|
||||
printf("{");
|
||||
for (i = 0; i < items_read; i++) {
|
||||
printf(" %d", values[i]);
|
||||
}
|
||||
printf(" }\n");
|
||||
} else if (real_type == XA_CARDINAL) {
|
||||
if (real_format == 32) {
|
||||
Uint32 *values = (Uint32 *)propdata;
|
||||
|
||||
printf("{");
|
||||
for (i = 0; i < items_read; i++) {
|
||||
printf(" %d", values[i]);
|
||||
}
|
||||
printf(" }\n");
|
||||
} else if (real_format == 16) {
|
||||
Uint16 *values = (Uint16 *)propdata;
|
||||
|
||||
printf("{");
|
||||
for (i = 0; i < items_read; i++) {
|
||||
printf(" %d", values[i]);
|
||||
}
|
||||
printf(" }\n");
|
||||
} else if (real_format == 8) {
|
||||
Uint8 *values = (Uint8 *)propdata;
|
||||
|
||||
printf("{");
|
||||
for (i = 0; i < items_read; i++) {
|
||||
printf(" %d", values[i]);
|
||||
}
|
||||
printf(" }\n");
|
||||
}
|
||||
} else if (real_type == XA_STRING ||
|
||||
real_type == videodata->UTF8_STRING) {
|
||||
printf("{ \"%s\" }\n", propdata);
|
||||
} else if (real_type == XA_ATOM) {
|
||||
Atom *atoms = (Atom *)propdata;
|
||||
|
||||
printf("{");
|
||||
for (i = 0; i < items_read; i++) {
|
||||
char *name = XGetAtomName(display, atoms[i]);
|
||||
if (name) {
|
||||
printf(" %s", name);
|
||||
XFree(name);
|
||||
}
|
||||
}
|
||||
printf(" }\n");
|
||||
} else {
|
||||
char *name = XGetAtomName(display, real_type);
|
||||
printf("Unknown type: %ld (%s)\n", real_type, name ? name : "UNKNOWN");
|
||||
if (name) {
|
||||
XFree(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
/* Copy the selection from XA_CUT_BUFFER0 to the requested property */
|
||||
case SelectionRequest: {
|
||||
Display *display = videodata->display;
|
||||
XSelectionRequestEvent *req;
|
||||
XEvent sevent;
|
||||
int seln_format;
|
||||
@@ -305,8 +384,8 @@ X11_DispatchEvent(_THIS)
|
||||
req->requestor, req->target);
|
||||
#endif
|
||||
|
||||
sevent.xselection.type = SelectionNotify;
|
||||
sevent.xselection.display = req->display;
|
||||
SDL_zero(sevent);
|
||||
sevent.xany.type = SelectionNotify;
|
||||
sevent.xselection.selection = req->selection;
|
||||
sevent.xselection.target = None;
|
||||
sevent.xselection.property = None;
|
||||
|
||||
@@ -211,7 +211,9 @@ X11_InitKeyboard(_THIS)
|
||||
}
|
||||
}
|
||||
if (j == SDL_arraysize(fingerprint)) {
|
||||
/* printf("Using scancode set %d\n", i); */
|
||||
#ifdef DEBUG_KEYBOARD
|
||||
printf("Using scancode set %d, min_keycode = %d, max_keycode = %d, table_size = %d\n", i, min_keycode, max_keycode, scancode_set[i].table_size);
|
||||
#endif
|
||||
SDL_memcpy(&data->key_layout[min_keycode], scancode_set[i].table,
|
||||
sizeof(SDL_scancode) * scancode_set[i].table_size);
|
||||
fingerprint_detected = SDL_TRUE;
|
||||
|
||||
@@ -23,10 +23,7 @@
|
||||
|
||||
#include "SDL_x11video.h"
|
||||
|
||||
//#define X11MODES_DEBUG
|
||||
#undef SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
#undef SDL_VIDEO_DRIVER_X11_XRANDR
|
||||
#undef SDL_VIDEO_DRIVER_X11_VIDMODE
|
||||
/*#define X11MODES_DEBUG*/
|
||||
|
||||
static int
|
||||
get_visualinfo(Display * display, int screen, XVisualInfo * vinfo)
|
||||
@@ -253,6 +250,7 @@ CheckVidMode(Display * display, int *major, int *minor)
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
static
|
||||
Bool SDL_NAME(XF86VidModeGetModeInfo) (Display * dpy, int scr,
|
||||
SDL_NAME(XF86VidModeModeInfo) * info)
|
||||
{
|
||||
@@ -296,6 +294,7 @@ save_mode(Display * display, SDL_DisplayData * data)
|
||||
&data->saved_view.y);
|
||||
}
|
||||
|
||||
/*
|
||||
static void
|
||||
restore_mode(Display * display, SDL_DisplayData * data)
|
||||
{
|
||||
@@ -313,6 +312,7 @@ restore_mode(Display * display, SDL_DisplayData * data)
|
||||
data->saved_view.y);
|
||||
}
|
||||
}
|
||||
*/
|
||||
#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
|
||||
|
||||
void
|
||||
|
||||
@@ -121,28 +121,29 @@ X11_GL_LoadLibrary(_THIS, const char *path)
|
||||
/* Load function pointers */
|
||||
handle = _this->gl_config.dll_handle;
|
||||
_this->gl_data->glXGetProcAddress =
|
||||
(void *(*)(const GLubyte *)) GL_LoadFunction(handle,
|
||||
"glXGetProcAddressARB");
|
||||
(void *(*)(const GLubyte *))
|
||||
GL_LoadFunction(handle, "glXGetProcAddressARB");
|
||||
_this->gl_data->glXChooseVisual =
|
||||
(XVisualInfo * (*)(Display *, int, int *)) GL_LoadFunction(handle,
|
||||
"glXChooseVisual");
|
||||
(XVisualInfo * (*)(Display *, int, int *))
|
||||
X11_GL_GetProcAddress(_this, "glXChooseVisual");
|
||||
_this->gl_data->glXCreateContext =
|
||||
(GLXContext(*)(Display *, XVisualInfo *, GLXContext, int))
|
||||
GL_LoadFunction(handle, "glXCreateContext");
|
||||
X11_GL_GetProcAddress(_this, "glXCreateContext");
|
||||
_this->gl_data->glXDestroyContext =
|
||||
(void (*)(Display *, GLXContext)) GL_LoadFunction(handle,
|
||||
"glXDestroyContext");
|
||||
(void (*)(Display *, GLXContext))
|
||||
X11_GL_GetProcAddress(_this, "glXDestroyContext");
|
||||
_this->gl_data->glXMakeCurrent =
|
||||
(int (*)(Display *, GLXDrawable, GLXContext)) GL_LoadFunction(handle,
|
||||
"glXMakeCurrent");
|
||||
(int (*)(Display *, GLXDrawable, GLXContext))
|
||||
X11_GL_GetProcAddress(_this, "glXMakeCurrent");
|
||||
_this->gl_data->glXSwapBuffers =
|
||||
(void (*)(Display *, GLXDrawable)) GL_LoadFunction(handle,
|
||||
"glXSwapBuffers");
|
||||
(void (*)(Display *, GLXDrawable))
|
||||
X11_GL_GetProcAddress(_this, "glXSwapBuffers");
|
||||
|
||||
if (!_this->gl_data->glXChooseVisual ||
|
||||
!_this->gl_data->glXCreateContext ||
|
||||
!_this->gl_data->glXDestroyContext ||
|
||||
!_this->gl_data->glXMakeCurrent || !_this->gl_data->glXSwapBuffers) {
|
||||
!_this->gl_data->glXMakeCurrent ||
|
||||
!_this->gl_data->glXSwapBuffers) {
|
||||
SDL_SetError("Could not retrieve OpenGL functions");
|
||||
return -1;
|
||||
}
|
||||
@@ -156,13 +157,10 @@ X11_GL_LoadLibrary(_THIS, const char *path)
|
||||
void *
|
||||
X11_GL_GetProcAddress(_THIS, const char *proc)
|
||||
{
|
||||
void *handle;
|
||||
|
||||
handle = _this->gl_config.dll_handle;
|
||||
if (_this->gl_data->glXGetProcAddress) {
|
||||
return _this->gl_data->glXGetProcAddress((const GLubyte *) proc);
|
||||
}
|
||||
return GL_LoadFunction(handle, proc);
|
||||
return GL_LoadFunction(_this->gl_config.dll_handle, proc);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -67,12 +67,14 @@ SDL_X11_SYM(int,XFreeCursor,(Display* a,Cursor b),(a,b),return)
|
||||
SDL_X11_SYM(int,XFreeGC,(Display* a,GC b),(a,b),return)
|
||||
SDL_X11_SYM(int,XFreeModifiermap,(XModifierKeymap* a),(a),return)
|
||||
SDL_X11_SYM(int,XFreePixmap,(Display* a,Pixmap b),(a,b),return)
|
||||
SDL_X11_SYM(char*,XGetAtomName,(Display *a,Atom b),(a,b),return)
|
||||
SDL_X11_SYM(int,XGetErrorDatabaseText,(Display* a,_Xconst char* b,_Xconst char* c,_Xconst char* d,char* e,int f),(a,b,c,d,e,f),return)
|
||||
SDL_X11_SYM(XImage*,XGetImage,(Display* a,Drawable b,int c,int d,unsigned int e,unsigned int f,unsigned long g, int h),(a,b,c,d,e,f,g,h),return)
|
||||
SDL_X11_SYM(XModifierKeymap*,XGetModifierMapping,(Display* a),(a),return)
|
||||
SDL_X11_SYM(int,XGetPointerControl,(Display* a,int* b,int* c,int* d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(int,XGetRGBColormaps,(Display* a,Window b,XStandardColormap **c,int *d,Atom e),(a,b,c,d,e),return)
|
||||
SDL_X11_SYM(Window,XGetSelectionOwner,(Display* a,Atom b),(a,b),return)
|
||||
SDL_X11_SYM(Status,XGetTextProperty,(Display *a,Window b,XTextProperty *c,Atom d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(XVisualInfo*,XGetVisualInfo,(Display* a,long b,XVisualInfo* c,int* d),(a,b,c,d),return)
|
||||
SDL_X11_SYM(Status,XGetWindowAttributes,(Display* a,Window b,XWindowAttributes* c),(a,b,c),return)
|
||||
SDL_X11_SYM(int,XGetWindowProperty,(Display* a,Window b,Atom c,long d,long e,Bool f,Atom g,Atom* h,int* i,unsigned long* j,unsigned long *k,unsigned char **l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
|
||||
|
||||
@@ -241,6 +241,73 @@ VideoBootStrap X11_bootstrap = {
|
||||
X11_Available, X11_CreateDevice
|
||||
};
|
||||
|
||||
static int (*handler) (Display *, XErrorEvent *) = NULL;
|
||||
static int
|
||||
X11_CheckWindowManagerErrorHandler(Display * d, XErrorEvent * e)
|
||||
{
|
||||
if (e->error_code == BadWindow) {
|
||||
return (0);
|
||||
} else {
|
||||
return (handler(d, e));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
X11_CheckWindowManager(_THIS)
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
Display *display = data->display;
|
||||
Atom _NET_SUPPORTING_WM_CHECK;
|
||||
int status, real_format;
|
||||
Atom real_type;
|
||||
unsigned long items_read, items_left;
|
||||
unsigned char *propdata;
|
||||
Window wm_window = 0;
|
||||
#ifdef DEBUG_WINDOW_MANAGER
|
||||
char *wm_name;
|
||||
#endif
|
||||
|
||||
/* Set up a handler to gracefully catch errors */
|
||||
XSync(display, False);
|
||||
handler = XSetErrorHandler(X11_CheckWindowManagerErrorHandler);
|
||||
|
||||
_NET_SUPPORTING_WM_CHECK = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False);
|
||||
status = XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
|
||||
if (status == Success && items_read) {
|
||||
wm_window = ((Window*)propdata)[0];
|
||||
}
|
||||
if (propdata) {
|
||||
XFree(propdata);
|
||||
}
|
||||
|
||||
if (wm_window) {
|
||||
status = XGetWindowProperty(display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata);
|
||||
if (status != Success || !items_read || wm_window != ((Window*)propdata)[0]) {
|
||||
wm_window = None;
|
||||
}
|
||||
if (propdata) {
|
||||
XFree(propdata);
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset the error handler, we're done checking */
|
||||
XSync(display, False);
|
||||
XSetErrorHandler(handler);
|
||||
|
||||
if (!wm_window) {
|
||||
#ifdef DEBUG_WINDOW_MANAGER
|
||||
printf("Couldn't get _NET_SUPPORTING_WM_CHECK property\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
data->net_wm = SDL_TRUE;
|
||||
|
||||
#ifdef DEBUG_WINDOW_MANAGER
|
||||
wm_name = X11_GetWindowTitle(_this, wm_window);
|
||||
printf("Window manager: %s\n", wm_name);
|
||||
SDL_free(wm_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
X11_VideoInit(_THIS)
|
||||
@@ -259,8 +326,20 @@ X11_VideoInit(_THIS)
|
||||
#endif
|
||||
|
||||
/* Look up some useful Atoms */
|
||||
data->WM_DELETE_WINDOW =
|
||||
XInternAtom(data->display, "WM_DELETE_WINDOW", False);
|
||||
#define GET_ATOM(X) data->X = XInternAtom(data->display, #X, False)
|
||||
GET_ATOM(WM_DELETE_WINDOW);
|
||||
GET_ATOM(_NET_WM_STATE);
|
||||
GET_ATOM(_NET_WM_STATE_HIDDEN);
|
||||
GET_ATOM(_NET_WM_STATE_MAXIMIZED_VERT);
|
||||
GET_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ);
|
||||
GET_ATOM(_NET_WM_STATE_FULLSCREEN);
|
||||
GET_ATOM(_NET_WM_NAME);
|
||||
GET_ATOM(_NET_WM_ICON_NAME);
|
||||
GET_ATOM(_NET_WM_ICON);
|
||||
GET_ATOM(UTF8_STRING);
|
||||
|
||||
/* Detect the window manager */
|
||||
X11_CheckWindowManager(_this);
|
||||
|
||||
if (X11_InitModes(_this) < 0) {
|
||||
return -1;
|
||||
|
||||
@@ -68,7 +68,22 @@ typedef struct SDL_VideoData
|
||||
int numwindows;
|
||||
SDL_WindowData **windowlist;
|
||||
int windowlistlength;
|
||||
|
||||
/* This is true for ICCCM2.0-compliant window managers */
|
||||
SDL_bool net_wm;
|
||||
|
||||
/* Useful atoms */
|
||||
Atom WM_DELETE_WINDOW;
|
||||
Atom _NET_WM_STATE;
|
||||
Atom _NET_WM_STATE_HIDDEN;
|
||||
Atom _NET_WM_STATE_MAXIMIZED_VERT;
|
||||
Atom _NET_WM_STATE_MAXIMIZED_HORZ;
|
||||
Atom _NET_WM_STATE_FULLSCREEN;
|
||||
Atom _NET_WM_NAME;
|
||||
Atom _NET_WM_ICON_NAME;
|
||||
Atom _NET_WM_ICON;
|
||||
Atom UTF8_STRING;
|
||||
|
||||
SDL_scancode key_layout[256];
|
||||
SDL_bool selection_waiting;
|
||||
} SDL_VideoData;
|
||||
|
||||
@@ -42,6 +42,50 @@
|
||||
#define _NET_WM_STATE_ADD 1l
|
||||
#define _NET_WM_STATE_TOGGLE 2l
|
||||
|
||||
static SDL_bool
|
||||
X11_IsWindowOldFullscreen(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||
|
||||
/* ICCCM2.0-compliant window managers can handle fullscreen windows */
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN) && !videodata->net_wm) {
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
X11_IsWindowMapped(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
|
||||
XWindowAttributes attr;
|
||||
|
||||
XGetWindowAttributes(videodata->display, data->xwindow, &attr);
|
||||
if (attr.map_state != IsUnmapped) {
|
||||
return SDL_TRUE;
|
||||
} else {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
X11_GetWMStateProperty(_THIS, SDL_Window * window, Atom atoms[3])
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
int count = 0;
|
||||
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
atoms[count++] = data->_NET_WM_STATE_FULLSCREEN;
|
||||
}
|
||||
if (window->flags & SDL_WINDOW_MAXIMIZED) {
|
||||
atoms[count++] = data->_NET_WM_STATE_MAXIMIZED_VERT;
|
||||
atoms[count++] = data->_NET_WM_STATE_MAXIMIZED_HORZ;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static void
|
||||
X11_GetDisplaySize(_THIS, SDL_Window * window, int *w, int *h)
|
||||
{
|
||||
@@ -128,14 +172,10 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
|
||||
}
|
||||
|
||||
{
|
||||
Atom _NET_WM_STATE =
|
||||
XInternAtom(data->videodata->display, "_NET_WM_STATE", False);
|
||||
Atom _NET_WM_STATE_MAXIMIZED_VERT =
|
||||
XInternAtom(data->videodata->display,
|
||||
"_NET_WM_STATE_MAXIMIZED_VERT", False);
|
||||
Atom _NET_WM_STATE_MAXIMIZED_HORZ =
|
||||
XInternAtom(data->videodata->display,
|
||||
"_NET_WM_STATE_MAXIMIZED_HORZ", False);
|
||||
Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE;
|
||||
Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_NET_WM_STATE_MAXIMIZED_VERT;
|
||||
Atom _NET_WM_STATE_MAXIMIZED_HORZ = data->videodata->_NET_WM_STATE_MAXIMIZED_HORZ;
|
||||
Atom _NET_WM_STATE_FULLSCREEN = data->videodata->_NET_WM_STATE_FULLSCREEN;
|
||||
Atom actualType;
|
||||
int actualFormat;
|
||||
unsigned long i, numItems, bytesAfter;
|
||||
@@ -148,19 +188,21 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
|
||||
&propertyValue) == Success) {
|
||||
Atom *atoms = (Atom *) propertyValue;
|
||||
int maximized = 0;
|
||||
int fullscreen = 0;
|
||||
|
||||
for (i = 0; i < numItems; ++i) {
|
||||
if (atoms[i] == _NET_WM_STATE_MAXIMIZED_VERT) {
|
||||
maximized |= 1;
|
||||
} else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_HORZ) {
|
||||
maximized |= 2;
|
||||
} else if ( atoms[i] == _NET_WM_STATE_FULLSCREEN) {
|
||||
fullscreen = 1;
|
||||
}
|
||||
/* Might also want to check the following properties:
|
||||
_NET_WM_STATE_ABOVE, _NET_WM_STATE_FULLSCREEN
|
||||
*/
|
||||
}
|
||||
if (maximized == 3) {
|
||||
window->flags |= SDL_WINDOW_MAXIMIZED;
|
||||
} else if (fullscreen == 1) {
|
||||
window->flags |= SDL_WINDOW_FULLSCREEN;
|
||||
}
|
||||
XFree(propertyValue);
|
||||
}
|
||||
@@ -180,11 +222,6 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created)
|
||||
} else {
|
||||
window->flags &= ~SDL_WINDOW_RESIZABLE;
|
||||
}
|
||||
if (style & WS_MAXIMIZE) {
|
||||
window->flags |= SDL_WINDOW_MAXIMIZED;
|
||||
} else {
|
||||
window->flags &= ~SDL_WINDOW_MAXIMIZED;
|
||||
}
|
||||
if (style & WS_MINIMIZE) {
|
||||
window->flags |= SDL_WINDOW_MINIMIZED;
|
||||
} else {
|
||||
@@ -217,6 +254,8 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
SDL_DisplayData *displaydata =
|
||||
(SDL_DisplayData *) window->display->driverdata;
|
||||
Display *display = data->display;
|
||||
int screen = displaydata->screen;
|
||||
Visual *visual;
|
||||
int depth;
|
||||
XSetWindowAttributes xattr;
|
||||
@@ -225,6 +264,14 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
XSizeHints *sizehints;
|
||||
XWMHints *wmhints;
|
||||
XClassHint *classhints;
|
||||
SDL_bool oldstyle_fullscreen;
|
||||
Atom _NET_WM_WINDOW_TYPE;
|
||||
Atom _NET_WM_WINDOW_TYPE_NORMAL;
|
||||
int wmstate_count;
|
||||
Atom wmstate_atoms[3];
|
||||
|
||||
/* ICCCM2.0-compliant window managers can handle fullscreen windows */
|
||||
oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window);
|
||||
|
||||
#if SDL_VIDEO_DRIVER_X11_XINERAMA
|
||||
/* FIXME
|
||||
@@ -238,7 +285,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
if (window->flags & SDL_WINDOW_OPENGL) {
|
||||
XVisualInfo *vinfo;
|
||||
|
||||
vinfo = X11_GL_GetVisual(_this, data->display, displaydata->screen);
|
||||
vinfo = X11_GL_GetVisual(_this, display, screen);
|
||||
if (!vinfo) {
|
||||
return -1;
|
||||
}
|
||||
@@ -251,7 +298,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
if (window->flags & SDL_WINDOW_OPENGL) {
|
||||
XVisualInfo *vinfo;
|
||||
|
||||
vinfo = X11_GLES_GetVisual(_this, data->display, displaydata->screen);
|
||||
vinfo = X11_GLES_GetVisual(_this, display, screen);
|
||||
if (!vinfo) {
|
||||
return -1;
|
||||
}
|
||||
@@ -265,7 +312,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
depth = displaydata->depth;
|
||||
}
|
||||
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
if (oldstyle_fullscreen) {
|
||||
xattr.override_redirect = True;
|
||||
} else {
|
||||
xattr.override_redirect = False;
|
||||
@@ -290,15 +337,12 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
|
||||
/* Is the colormap we need already registered in SDL? */
|
||||
if ((colormap =
|
||||
X11_LookupColormap(data->display,
|
||||
displaydata->screen, visual->visualid))) {
|
||||
X11_LookupColormap(display, screen, visual->visualid))) {
|
||||
xattr.colormap = colormap;
|
||||
/* printf("found existing colormap\n"); */
|
||||
} else {
|
||||
/* The colormap is not known to SDL so we will create it */
|
||||
colormap = XCreateColormap(data->display,
|
||||
RootWindow(data->display,
|
||||
displaydata->screen),
|
||||
colormap = XCreateColormap(display, RootWindow(display, screen),
|
||||
visual, AllocAll);
|
||||
/* printf("colormap = %x\n", colormap); */
|
||||
|
||||
@@ -377,11 +421,10 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
}
|
||||
|
||||
/* status = */
|
||||
/* XStoreColors(data->display, colormap, colorcells, ncolors); */
|
||||
/* XStoreColors(display, colormap, colorcells, ncolors); */
|
||||
|
||||
xattr.colormap = colormap;
|
||||
X11_TrackColormap(data->display, displaydata->screen,
|
||||
colormap, visual, NULL);
|
||||
X11_TrackColormap(display, screen, colormap, visual, NULL);
|
||||
|
||||
SDL_free(colorcells);
|
||||
}
|
||||
@@ -397,15 +440,12 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
|
||||
/* Is the colormap we need already registered in SDL? */
|
||||
if ((colormap =
|
||||
X11_LookupColormap(data->display,
|
||||
displaydata->screen, visual->visualid))) {
|
||||
X11_LookupColormap(display, screen, visual->visualid))) {
|
||||
xattr.colormap = colormap;
|
||||
/* printf("found existing colormap\n"); */
|
||||
} else {
|
||||
/* The colormap is not known to SDL so we will create it */
|
||||
colormap = XCreateColormap(data->display,
|
||||
RootWindow(data->display,
|
||||
displaydata->screen),
|
||||
colormap = XCreateColormap(display, RootWindow(display, screen),
|
||||
visual, AllocAll);
|
||||
/* printf("colormap = %x\n", colormap); */
|
||||
|
||||
@@ -417,7 +457,6 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
}
|
||||
|
||||
/* OK, we got a colormap, now fill it in as best as we can */
|
||||
|
||||
colorcells = SDL_malloc(visual->map_entries * sizeof(XColor));
|
||||
if (NULL == colorcells) {
|
||||
SDL_SetError("out of memory in X11_CreateWindow");
|
||||
@@ -479,22 +518,20 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
}
|
||||
|
||||
status =
|
||||
XStoreColors(data->display, colormap, colorcells, ncolors);
|
||||
XStoreColors(display, colormap, colorcells, ncolors);
|
||||
|
||||
xattr.colormap = colormap;
|
||||
X11_TrackColormap(data->display, displaydata->screen,
|
||||
colormap, visual, colorcells);
|
||||
X11_TrackColormap(display, screen, colormap, visual, colorcells);
|
||||
|
||||
SDL_free(colorcells);
|
||||
}
|
||||
} else {
|
||||
xattr.colormap =
|
||||
XCreateColormap(data->display,
|
||||
RootWindow(data->display, displaydata->screen),
|
||||
XCreateColormap(display, RootWindow(display, screen),
|
||||
visual, AllocNone);
|
||||
}
|
||||
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
if (oldstyle_fullscreen
|
||||
|| window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
X11_GetDisplaySize(_this, window, &x, NULL);
|
||||
x = (x - window->w) / 2;
|
||||
@@ -503,7 +540,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
} else {
|
||||
x = window->x;
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
if (oldstyle_fullscreen
|
||||
|| window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
X11_GetDisplaySize(_this, window, NULL, &y);
|
||||
y = (y - window->h) / 2;
|
||||
@@ -513,8 +550,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
y = window->y;
|
||||
}
|
||||
|
||||
w = XCreateWindow(data->display,
|
||||
RootWindow(data->display, displaydata->screen), x, y,
|
||||
w = XCreateWindow(display, RootWindow(display, screen), x, y,
|
||||
window->w, window->h, 0, depth, InputOutput, visual,
|
||||
(CWOverrideRedirect | CWBackPixel | CWBorderPixel |
|
||||
CWColormap), &xattr);
|
||||
@@ -539,23 +575,23 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
sizehints = XAllocSizeHints();
|
||||
if (sizehints) {
|
||||
if (!(window->flags & SDL_WINDOW_RESIZABLE)
|
||||
|| (window->flags & SDL_WINDOW_FULLSCREEN)) {
|
||||
|| oldstyle_fullscreen) {
|
||||
sizehints->min_width = sizehints->max_width = window->w;
|
||||
sizehints->min_height = sizehints->max_height = window->h;
|
||||
sizehints->flags = PMaxSize | PMinSize;
|
||||
}
|
||||
if (!(window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
if (!oldstyle_fullscreen
|
||||
&& window->x != SDL_WINDOWPOS_UNDEFINED
|
||||
&& window->y != SDL_WINDOWPOS_UNDEFINED) {
|
||||
sizehints->x = x;
|
||||
sizehints->y = y;
|
||||
sizehints->flags |= USPosition;
|
||||
}
|
||||
XSetWMNormalHints(data->display, w, sizehints);
|
||||
XSetWMNormalHints(display, w, sizehints);
|
||||
XFree(sizehints);
|
||||
}
|
||||
|
||||
if (window->flags & (SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN)) {
|
||||
if ((window->flags & SDL_WINDOW_BORDERLESS) || oldstyle_fullscreen) {
|
||||
SDL_bool set;
|
||||
Atom WM_HINTS;
|
||||
|
||||
@@ -563,7 +599,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
set = SDL_FALSE;
|
||||
|
||||
/* First try to set MWM hints */
|
||||
WM_HINTS = XInternAtom(data->display, "_MOTIF_WM_HINTS", True);
|
||||
WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True);
|
||||
if (WM_HINTS != None) {
|
||||
/* Hints used by Motif compliant window managers */
|
||||
struct
|
||||
@@ -576,40 +612,36 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
} MWMHints = {
|
||||
(1L << 1), 0, 0, 0, 0};
|
||||
|
||||
XChangeProperty(data->display, w, WM_HINTS, WM_HINTS, 32,
|
||||
XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32,
|
||||
PropModeReplace, (unsigned char *) &MWMHints,
|
||||
sizeof(MWMHints) / sizeof(long));
|
||||
sizeof(MWMHints) / 4);
|
||||
set = SDL_TRUE;
|
||||
}
|
||||
/* Now try to set KWM hints */
|
||||
WM_HINTS = XInternAtom(data->display, "KWM_WIN_DECORATION", True);
|
||||
WM_HINTS = XInternAtom(display, "KWM_WIN_DECORATION", True);
|
||||
if (WM_HINTS != None) {
|
||||
long KWMHints = 0;
|
||||
|
||||
XChangeProperty(data->display, w,
|
||||
WM_HINTS, WM_HINTS, 32,
|
||||
XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32,
|
||||
PropModeReplace,
|
||||
(unsigned char *) &KWMHints,
|
||||
sizeof(KWMHints) / sizeof(long));
|
||||
sizeof(KWMHints) / 4);
|
||||
set = SDL_TRUE;
|
||||
}
|
||||
/* Now try to set GNOME hints */
|
||||
WM_HINTS = XInternAtom(data->display, "_WIN_HINTS", True);
|
||||
WM_HINTS = XInternAtom(display, "_WIN_HINTS", True);
|
||||
if (WM_HINTS != None) {
|
||||
long GNOMEHints = 0;
|
||||
|
||||
XChangeProperty(data->display, w,
|
||||
WM_HINTS, WM_HINTS, 32,
|
||||
XChangeProperty(display, w, WM_HINTS, WM_HINTS, 32,
|
||||
PropModeReplace,
|
||||
(unsigned char *) &GNOMEHints,
|
||||
sizeof(GNOMEHints) / sizeof(long));
|
||||
sizeof(GNOMEHints) / 4);
|
||||
set = SDL_TRUE;
|
||||
}
|
||||
/* Finally set the transient hints if necessary */
|
||||
if (!set) {
|
||||
XSetTransientForHint(data->display, w,
|
||||
RootWindow(data->display,
|
||||
displaydata->screen));
|
||||
XSetTransientForHint(display, w, RootWindow(display, screen));
|
||||
}
|
||||
} else {
|
||||
SDL_bool set;
|
||||
@@ -619,53 +651,35 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
set = SDL_FALSE;
|
||||
|
||||
/* First try to unset MWM hints */
|
||||
WM_HINTS = XInternAtom(data->display, "_MOTIF_WM_HINTS", True);
|
||||
WM_HINTS = XInternAtom(display, "_MOTIF_WM_HINTS", True);
|
||||
if (WM_HINTS != None) {
|
||||
XDeleteProperty(data->display, w, WM_HINTS);
|
||||
XDeleteProperty(display, w, WM_HINTS);
|
||||
set = SDL_TRUE;
|
||||
}
|
||||
/* Now try to unset KWM hints */
|
||||
WM_HINTS = XInternAtom(data->display, "KWM_WIN_DECORATION", True);
|
||||
WM_HINTS = XInternAtom(display, "KWM_WIN_DECORATION", True);
|
||||
if (WM_HINTS != None) {
|
||||
XDeleteProperty(data->display, w, WM_HINTS);
|
||||
XDeleteProperty(display, w, WM_HINTS);
|
||||
set = SDL_TRUE;
|
||||
}
|
||||
/* Now try to unset GNOME hints */
|
||||
WM_HINTS = XInternAtom(data->display, "_WIN_HINTS", True);
|
||||
WM_HINTS = XInternAtom(display, "_WIN_HINTS", True);
|
||||
if (WM_HINTS != None) {
|
||||
XDeleteProperty(data->display, w, WM_HINTS);
|
||||
XDeleteProperty(display, w, WM_HINTS);
|
||||
set = SDL_TRUE;
|
||||
}
|
||||
/* Finally unset the transient hints if necessary */
|
||||
if (!set) {
|
||||
/* NOTE: Does this work? */
|
||||
XSetTransientForHint(data->display, w, None);
|
||||
XDeleteProperty(display, w, XA_WM_TRANSIENT_FOR);
|
||||
}
|
||||
}
|
||||
|
||||
/* Tell KDE to keep fullscreen windows on top */
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
XEvent ev;
|
||||
|
||||
SDL_zero(ev);
|
||||
ev.xclient.type = ClientMessage;
|
||||
ev.xclient.window = RootWindow(data->display, displaydata->screen);
|
||||
ev.xclient.message_type =
|
||||
XInternAtom(data->display, "KWM_KEEP_ON_TOP", False);
|
||||
ev.xclient.format = 32;
|
||||
ev.xclient.data.l[0] = w;
|
||||
ev.xclient.data.l[1] = CurrentTime;
|
||||
XSendEvent(data->display,
|
||||
RootWindow(data->display, displaydata->screen), False,
|
||||
SubstructureRedirectMask, &ev);
|
||||
}
|
||||
|
||||
/* Set the input hints so we get keyboard input */
|
||||
wmhints = XAllocWMHints();
|
||||
if (wmhints) {
|
||||
wmhints->input = True;
|
||||
wmhints->flags = InputHint;
|
||||
XSetWMHints(data->display, w, wmhints);
|
||||
XSetWMHints(display, w, wmhints);
|
||||
XFree(wmhints);
|
||||
}
|
||||
|
||||
@@ -674,15 +688,32 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
if (classhints != NULL) {
|
||||
classhints->res_name = data->classname;
|
||||
classhints->res_class = data->classname;
|
||||
XSetClassHint(data->display, w, classhints);
|
||||
XSetClassHint(display, w, classhints);
|
||||
XFree(classhints);
|
||||
}
|
||||
|
||||
/* Set the window manager state */
|
||||
wmstate_count = X11_GetWMStateProperty(_this, window, wmstate_atoms);
|
||||
if (wmstate_count > 0) {
|
||||
XChangeProperty(display, w, data->_NET_WM_STATE, XA_ATOM, 32,
|
||||
PropModeReplace,
|
||||
(unsigned char *)wmstate_atoms, wmstate_count);
|
||||
} else {
|
||||
XDeleteProperty(display, w, data->_NET_WM_STATE);
|
||||
}
|
||||
|
||||
/* Let the window manager know we're a "normal" window */
|
||||
_NET_WM_WINDOW_TYPE = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False);
|
||||
_NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(display, "_NET_WM_WINDOW_TYPE_NORMAL", False);
|
||||
XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32,
|
||||
PropModeReplace,
|
||||
(unsigned char *)&_NET_WM_WINDOW_TYPE_NORMAL, 1);
|
||||
|
||||
/* Allow the window to be deleted by the window manager */
|
||||
XSetWMProtocols(data->display, w, &data->WM_DELETE_WINDOW, 1);
|
||||
XSetWMProtocols(display, w, &data->WM_DELETE_WINDOW, 1);
|
||||
|
||||
if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) {
|
||||
XDestroyWindow(data->display, w);
|
||||
XDestroyWindow(display, w);
|
||||
return -1;
|
||||
}
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
@@ -690,7 +721,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
Uint32 fevent = 0;
|
||||
pXGetICValues(((SDL_WindowData *) window->driverdata)->ic,
|
||||
XNFilterEvents, &fevent, NULL);
|
||||
XSelectInput(data->display, w,
|
||||
XSelectInput(display, w,
|
||||
(FocusChangeMask | EnterWindowMask | LeaveWindowMask |
|
||||
ExposureMask | ButtonPressMask | ButtonReleaseMask |
|
||||
PointerMotionMask | KeyPressMask | KeyReleaseMask |
|
||||
@@ -699,7 +730,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||
}
|
||||
#else
|
||||
{
|
||||
XSelectInput(data->display, w,
|
||||
XSelectInput(display, w,
|
||||
(FocusChangeMask | EnterWindowMask | LeaveWindowMask |
|
||||
ExposureMask | ButtonPressMask | ButtonReleaseMask |
|
||||
PointerMotionMask | KeyPressMask | KeyReleaseMask |
|
||||
@@ -716,7 +747,7 @@ X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
|
||||
{
|
||||
Window w = (Window) data;
|
||||
|
||||
/* FIXME: Query the title from the existing window */
|
||||
window->title = X11_GetWindowTitle(_this, w);
|
||||
|
||||
if (SetupWindowData(_this, window, w, SDL_FALSE) < 0) {
|
||||
return -1;
|
||||
@@ -724,6 +755,36 @@ X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
X11_GetWindowTitle(_THIS, Window xwindow)
|
||||
{
|
||||
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
|
||||
Display *display = data->display;
|
||||
int status, real_format;
|
||||
Atom real_type;
|
||||
unsigned long items_read, items_left;
|
||||
unsigned char *propdata;
|
||||
char *title = NULL;
|
||||
|
||||
status = XGetWindowProperty(display, xwindow, data->_NET_WM_NAME,
|
||||
0L, 8192L, False, data->UTF8_STRING, &real_type, &real_format,
|
||||
&items_read, &items_left, &propdata);
|
||||
if (status == Success) {
|
||||
title = SDL_strdup(SDL_static_cast(char*, propdata));
|
||||
XFree(propdata);
|
||||
} else {
|
||||
status = XGetWindowProperty(display, xwindow, XA_WM_NAME,
|
||||
0L, 8192L, False, XA_STRING, &real_type, &real_format,
|
||||
&items_read, &items_left, &propdata);
|
||||
if (status == Success) {
|
||||
title = SDL_iconv_string("UTF-8", "", SDL_static_cast(char*, propdata), items_read+1);
|
||||
} else {
|
||||
title = SDL_strdup("");
|
||||
}
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
void
|
||||
X11_SetWindowTitle(_THIS, SDL_Window * window)
|
||||
{
|
||||
@@ -735,14 +796,8 @@ X11_SetWindowTitle(_THIS, SDL_Window * window)
|
||||
const char *icon = NULL;
|
||||
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
Atom _NET_WM_NAME = 0;
|
||||
Atom _NET_WM_ICON_NAME = 0;
|
||||
|
||||
/* Look up some useful Atoms */
|
||||
if (SDL_X11_HAVE_UTF8) {
|
||||
_NET_WM_NAME = XInternAtom(display, "_NET_WM_NAME", False);
|
||||
_NET_WM_ICON_NAME = XInternAtom(display, "_NET_WM_ICON_NAME", False);
|
||||
}
|
||||
Atom _NET_WM_NAME = data->videodata->_NET_WM_NAME;
|
||||
Atom _NET_WM_ICON_NAME = data->videodata->_NET_WM_ICON_NAME;
|
||||
#endif
|
||||
|
||||
if (title != NULL) {
|
||||
@@ -803,13 +858,13 @@ X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
Display *display = data->videodata->display;
|
||||
Atom _NET_WM_ICON = XInternAtom(display, "_NET_WM_ICON", False);
|
||||
Atom _NET_WM_ICON = data->videodata->_NET_WM_ICON;
|
||||
|
||||
if (icon) {
|
||||
SDL_PixelFormat format;
|
||||
SDL_Surface *surface;
|
||||
int propsize;
|
||||
Uint32 *propdata;
|
||||
long *propdata;
|
||||
|
||||
/* Convert the icon to ARGB for modern window managers */
|
||||
SDL_InitFormat(&format, 32, 0x00FF0000, 0x0000FF00, 0x000000FF,
|
||||
@@ -823,10 +878,19 @@ X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon)
|
||||
propsize = 2 + (icon->w * icon->h);
|
||||
propdata = SDL_malloc(propsize * sizeof(Uint32));
|
||||
if (propdata) {
|
||||
int x, y;
|
||||
Uint32 *src;
|
||||
long *dst;
|
||||
|
||||
propdata[0] = icon->w;
|
||||
propdata[1] = icon->h;
|
||||
SDL_memcpy(&propdata[2], surface->pixels,
|
||||
surface->h * surface->pitch);
|
||||
dst = &propdata[2];
|
||||
for (y = 0; y < icon->h; ++y) {
|
||||
src = (Uint32*)((Uint8*)surface->pixels + y * surface->pitch);
|
||||
for (x = 0; x < icon->w; ++x) {
|
||||
*dst++ = *src++;
|
||||
}
|
||||
}
|
||||
XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL,
|
||||
32, PropModeReplace, (unsigned char *) propdata,
|
||||
propsize);
|
||||
@@ -842,16 +906,20 @@ X11_SetWindowPosition(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
Display *display = data->videodata->display;
|
||||
SDL_bool oldstyle_fullscreen;
|
||||
int x, y;
|
||||
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
/* ICCCM2.0-compliant window managers can handle fullscreen windows */
|
||||
oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window);
|
||||
|
||||
if (oldstyle_fullscreen
|
||||
|| window->x == SDL_WINDOWPOS_CENTERED) {
|
||||
X11_GetDisplaySize(_this, window, &x, NULL);
|
||||
x = (x - window->w) / 2;
|
||||
} else {
|
||||
x = window->x;
|
||||
}
|
||||
if ((window->flags & SDL_WINDOW_FULLSCREEN)
|
||||
if (oldstyle_fullscreen
|
||||
|| window->y == SDL_WINDOWPOS_CENTERED) {
|
||||
X11_GetDisplaySize(_this, window, NULL, &y);
|
||||
y = (y - window->h) / 2;
|
||||
@@ -904,26 +972,45 @@ X11_SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized)
|
||||
SDL_DisplayData *displaydata =
|
||||
(SDL_DisplayData *) window->display->driverdata;
|
||||
Display *display = data->videodata->display;
|
||||
Atom _NET_WM_STATE = XInternAtom(display, "_NET_WM_STATE", False);
|
||||
Atom _NET_WM_STATE_MAXIMIZED_VERT =
|
||||
XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
|
||||
Atom _NET_WM_STATE_MAXIMIZED_HORZ =
|
||||
XInternAtom(display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
|
||||
XEvent e;
|
||||
Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE;
|
||||
Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_NET_WM_STATE_MAXIMIZED_VERT;
|
||||
Atom _NET_WM_STATE_MAXIMIZED_HORZ = data->videodata->_NET_WM_STATE_MAXIMIZED_HORZ;
|
||||
Atom _NET_WM_STATE_FULLSCREEN = data->videodata->_NET_WM_STATE_FULLSCREEN;
|
||||
|
||||
e.xany.type = ClientMessage;
|
||||
e.xany.window = data->xwindow;
|
||||
e.xclient.message_type = _NET_WM_STATE;
|
||||
e.xclient.format = 32;
|
||||
e.xclient.data.l[0] =
|
||||
maximized ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
|
||||
e.xclient.data.l[1] = _NET_WM_STATE_MAXIMIZED_VERT;
|
||||
e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ;
|
||||
e.xclient.data.l[3] = 0l;
|
||||
e.xclient.data.l[4] = 0l;
|
||||
if (X11_IsWindowMapped(_this, window)) {
|
||||
XEvent e;
|
||||
|
||||
XSendEvent(display, RootWindow(display, displaydata->screen), 0,
|
||||
SubstructureNotifyMask | SubstructureRedirectMask, &e);
|
||||
SDL_zero(e);
|
||||
e.xany.type = ClientMessage;
|
||||
e.xclient.message_type = _NET_WM_STATE;
|
||||
e.xclient.format = 32;
|
||||
e.xclient.window = data->xwindow;
|
||||
e.xclient.data.l[0] =
|
||||
maximized ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
|
||||
e.xclient.data.l[1] = _NET_WM_STATE_MAXIMIZED_VERT;
|
||||
e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ;
|
||||
e.xclient.data.l[3] = 0l;
|
||||
|
||||
XSendEvent(display, RootWindow(display, displaydata->screen), 0,
|
||||
SubstructureNotifyMask | SubstructureRedirectMask, &e);
|
||||
} else {
|
||||
int count = 0;
|
||||
Atom atoms[3];
|
||||
|
||||
if (window->flags & SDL_WINDOW_FULLSCREEN) {
|
||||
atoms[count++] = _NET_WM_STATE_FULLSCREEN;
|
||||
}
|
||||
if (maximized) {
|
||||
atoms[count++] = _NET_WM_STATE_MAXIMIZED_VERT;
|
||||
atoms[count++] = _NET_WM_STATE_MAXIMIZED_HORZ;
|
||||
}
|
||||
if (count > 0) {
|
||||
XChangeProperty(display, data->xwindow, _NET_WM_STATE, XA_ATOM, 32,
|
||||
PropModeReplace, (unsigned char *)atoms, count);
|
||||
} else {
|
||||
XDeleteProperty(display, data->xwindow, _NET_WM_STATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -935,7 +1022,12 @@ X11_MaximizeWindow(_THIS, SDL_Window * window)
|
||||
void
|
||||
X11_MinimizeWindow(_THIS, SDL_Window * window)
|
||||
{
|
||||
X11_HideWindow(_this, window);
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
SDL_DisplayData *displaydata =
|
||||
(SDL_DisplayData *) window->display->driverdata;
|
||||
Display *display = data->videodata->display;
|
||||
|
||||
XIconifyWindow(display, data->xwindow, displaydata->screen);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -950,8 +1042,12 @@ X11_SetWindowGrab(_THIS, SDL_Window * window)
|
||||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
Display *display = data->videodata->display;
|
||||
SDL_bool oldstyle_fullscreen;
|
||||
|
||||
if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN))
|
||||
/* ICCCM2.0-compliant window managers can handle fullscreen windows */
|
||||
oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window);
|
||||
|
||||
if (((window->flags & SDL_WINDOW_INPUT_GRABBED) || oldstyle_fullscreen)
|
||||
&& (window->flags & SDL_WINDOW_INPUT_FOCUS)) {
|
||||
/* Try to grab the mouse */
|
||||
for (;;) {
|
||||
|
||||
@@ -35,6 +35,7 @@ typedef struct
|
||||
|
||||
extern int X11_CreateWindow(_THIS, SDL_Window * window);
|
||||
extern int X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
|
||||
extern char *X11_GetWindowTitle(_THIS, Window xwindow);
|
||||
extern void X11_SetWindowTitle(_THIS, SDL_Window * window);
|
||||
extern void X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
|
||||
extern void X11_SetWindowPosition(_THIS, SDL_Window * window);
|
||||
|
||||
Reference in New Issue
Block a user