mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-13 07:34:45 +00:00
Update SDL to 2.28.4
This commit is contained in:
parent
4fb67ed618
commit
402f7aff99
182 changed files with 2763 additions and 222042 deletions
|
|
@ -18,6 +18,7 @@
|
|||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
#include "../SDL_internal.h"
|
||||
|
||||
/* The high-level video driver subsystem */
|
||||
|
|
@ -127,15 +128,15 @@ static VideoBootStrap *bootstrap[] = {
|
|||
#if SDL_VIDEO_DRIVER_QNX
|
||||
&QNX_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_OFFSCREEN
|
||||
&OFFSCREEN_bootstrap,
|
||||
#if SDL_VIDEO_DRIVER_OS2
|
||||
&OS2DIVE_bootstrap,
|
||||
&OS2VMAN_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_NGAGE
|
||||
&NGAGE_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_OS2
|
||||
&OS2DIVE_bootstrap,
|
||||
&OS2VMAN_bootstrap,
|
||||
#if SDL_VIDEO_DRIVER_OFFSCREEN
|
||||
&OFFSCREEN_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_DUMMY
|
||||
&DUMMY_bootstrap,
|
||||
|
|
@ -1398,6 +1399,9 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen)
|
|||
#endif
|
||||
|
||||
display = SDL_GetDisplayForWindow(window);
|
||||
if (display == NULL) { /* No display connected, nothing to do. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fullscreen) {
|
||||
/* Hide any other fullscreen windows */
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ typedef struct {
|
|||
/* What location we last saw the cursor move to. */
|
||||
CGFloat lastMoveX;
|
||||
CGFloat lastMoveY;
|
||||
/* If we just turned on relative mode, and should skip a single mouse motion event. */
|
||||
SDL_bool justEnabledRelative;
|
||||
} SDL_MouseData;
|
||||
|
||||
@interface NSCursor (InvisibleCursor)
|
||||
|
|
|
|||
|
|
@ -293,8 +293,11 @@ static int Cocoa_SetRelativeMouseMode(SDL_bool enabled)
|
|||
if (enabled) {
|
||||
if (window) {
|
||||
/* make sure the mouse isn't at the corner of the window, as this can confuse things if macOS thinks a window resize is happening on the first click. */
|
||||
SDL_MouseData *mousedriverdata = (SDL_MouseData*)SDL_GetMouse()->driverdata;
|
||||
const CGPoint point = CGPointMake((float)(window->x + (window->w / 2)), (float)(window->y + (window->h / 2)));
|
||||
Cocoa_HandleMouseWarp(point.x, point.y);
|
||||
if (mousedriverdata) {
|
||||
mousedriverdata->justEnabledRelative = SDL_TRUE;
|
||||
}
|
||||
CGWarpMouseCursorPosition(point);
|
||||
}
|
||||
DLog("Turning on.");
|
||||
|
|
@ -465,6 +468,11 @@ void Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
|
|||
seenWarp = driverdata->seenWarp;
|
||||
driverdata->seenWarp = NO;
|
||||
|
||||
if (driverdata->justEnabledRelative) {
|
||||
driverdata->justEnabledRelative = SDL_FALSE;
|
||||
return; // dump the first event back.
|
||||
}
|
||||
|
||||
location = [NSEvent mouseLocation];
|
||||
lastMoveX = driverdata->lastMoveX;
|
||||
lastMoveY = driverdata->lastMoveY;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,15 @@
|
|||
|
||||
#include "../../events/SDL_mouse_c.h"
|
||||
|
||||
/* older Emscriptens don't have this, but we need to for wasm64 compatibility. */
|
||||
#ifndef MAIN_THREAD_EM_ASM_PTR
|
||||
#ifdef __wasm64__
|
||||
#error You need to upgrade your Emscripten compiler to support wasm64
|
||||
#else
|
||||
#define MAIN_THREAD_EM_ASM_PTR MAIN_THREAD_EM_ASM_INT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static SDL_Cursor *Emscripten_CreateCursorFromString(const char *cursor_str, SDL_bool is_custom)
|
||||
{
|
||||
SDL_Cursor *cursor;
|
||||
|
|
@ -60,6 +69,8 @@ static SDL_Cursor *Emscripten_CreateDefaultCursor()
|
|||
return Emscripten_CreateCursorFromString("default", SDL_FALSE);
|
||||
}
|
||||
|
||||
EM_JS_DEPS(sdlmouse, "$stringToUTF8,$UTF8ToString");
|
||||
|
||||
static SDL_Cursor *Emscripten_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y)
|
||||
{
|
||||
const char *cursor_url = NULL;
|
||||
|
|
@ -72,7 +83,7 @@ static SDL_Cursor *Emscripten_CreateCursor(SDL_Surface *surface, int hot_x, int
|
|||
}
|
||||
|
||||
/* *INDENT-OFF* */ /* clang-format off */
|
||||
cursor_url = (const char *)MAIN_THREAD_EM_ASM_INT({
|
||||
cursor_url = (const char *)MAIN_THREAD_EM_ASM_PTR({
|
||||
var w = $0;
|
||||
var h = $1;
|
||||
var hot_x = $2;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -412,6 +412,9 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
|||
SDL_SendKeyboardKey(SDL_PRESSED, scancode);
|
||||
}
|
||||
}
|
||||
if (SDL_IsTextInputActive()) {
|
||||
[super pressesBegan:presses withEvent:event];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
|
||||
|
|
@ -422,6 +425,9 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
|||
SDL_SendKeyboardKey(SDL_RELEASED, scancode);
|
||||
}
|
||||
}
|
||||
if (SDL_IsTextInputActive()) {
|
||||
[super pressesEnded:presses withEvent:event];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pressesCancelled:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
|
||||
|
|
@ -432,11 +438,17 @@ extern int SDL_AppleTVRemoteOpenedAsJoystick;
|
|||
SDL_SendKeyboardKey(SDL_RELEASED, scancode);
|
||||
}
|
||||
}
|
||||
if (SDL_IsTextInputActive()) {
|
||||
[super pressesCancelled:presses withEvent:event];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)pressesChanged:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
|
||||
{
|
||||
/* This is only called when the force of a press changes. */
|
||||
if (SDL_IsTextInputActive()) {
|
||||
[super pressesChanged:presses withEvent:event];
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* TARGET_OS_TV || defined(__IPHONE_9_1) */
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
|
|||
UITextField *textField;
|
||||
BOOL hardwareKeyboard;
|
||||
BOOL showingKeyboard;
|
||||
BOOL hidingKeyboard;
|
||||
BOOL rotatingOrientation;
|
||||
NSString *committedText;
|
||||
NSString *obligateForBackspace;
|
||||
|
|
@ -91,6 +92,7 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
|
|||
[self initKeyboard];
|
||||
hardwareKeyboard = NO;
|
||||
showingKeyboard = NO;
|
||||
hidingKeyboard = NO;
|
||||
rotatingOrientation = NO;
|
||||
#endif
|
||||
|
||||
|
|
@ -277,8 +279,22 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
|
|||
|
||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||
#if !TARGET_OS_TV
|
||||
[center addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
|
||||
[center addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
|
||||
[center addObserver:self
|
||||
selector:@selector(keyboardWillShow:)
|
||||
name:UIKeyboardWillShowNotification
|
||||
object:nil];
|
||||
[center addObserver:self
|
||||
selector:@selector(keyboardDidShow:)
|
||||
name:UIKeyboardDidShowNotification
|
||||
object:nil];
|
||||
[center addObserver:self
|
||||
selector:@selector(keyboardWillHide:)
|
||||
name:UIKeyboardWillHideNotification
|
||||
object:nil];
|
||||
[center addObserver:self
|
||||
selector:@selector(keyboardDidHide:)
|
||||
name:UIKeyboardDidHideNotification
|
||||
object:nil];
|
||||
#endif
|
||||
[center addObserver:self selector:@selector(textFieldTextDidChange:) name:UITextFieldTextDidChangeNotification object:nil];
|
||||
}
|
||||
|
|
@ -341,8 +357,18 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
|
|||
{
|
||||
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
|
||||
#if !TARGET_OS_TV
|
||||
[center removeObserver:self name:UIKeyboardWillShowNotification object:nil];
|
||||
[center removeObserver:self name:UIKeyboardWillHideNotification object:nil];
|
||||
[center removeObserver:self
|
||||
name:UIKeyboardWillShowNotification
|
||||
object:nil];
|
||||
[center removeObserver:self
|
||||
name:UIKeyboardDidShowNotification
|
||||
object:nil];
|
||||
[center removeObserver:self
|
||||
name:UIKeyboardWillHideNotification
|
||||
object:nil];
|
||||
[center removeObserver:self
|
||||
name:UIKeyboardDidHideNotification
|
||||
object:nil];
|
||||
#endif
|
||||
[center removeObserver:self name:UITextFieldTextDidChangeNotification object:nil];
|
||||
}
|
||||
|
|
@ -350,23 +376,40 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
|
|||
/* reveal onscreen virtual keyboard */
|
||||
- (void)showKeyboard
|
||||
{
|
||||
if (keyboardVisible) {
|
||||
return;
|
||||
}
|
||||
|
||||
keyboardVisible = YES;
|
||||
if (textField.window) {
|
||||
showingKeyboard = YES;
|
||||
[textField becomeFirstResponder];
|
||||
showingKeyboard = NO;
|
||||
}
|
||||
}
|
||||
|
||||
/* hide onscreen virtual keyboard */
|
||||
- (void)hideKeyboard
|
||||
{
|
||||
if (!keyboardVisible) {
|
||||
return;
|
||||
}
|
||||
|
||||
keyboardVisible = NO;
|
||||
[textField resignFirstResponder];
|
||||
if (textField.window) {
|
||||
hidingKeyboard = YES;
|
||||
[textField resignFirstResponder];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)keyboardWillShow:(NSNotification *)notification
|
||||
{
|
||||
BOOL shouldStartTextInput = NO;
|
||||
|
||||
if (!SDL_IsTextInputActive() && !hidingKeyboard && !rotatingOrientation) {
|
||||
shouldStartTextInput = YES;
|
||||
}
|
||||
|
||||
showingKeyboard = YES;
|
||||
#if !TARGET_OS_TV
|
||||
CGRect kbrect = [[notification userInfo][UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
||||
|
||||
|
|
@ -376,14 +419,36 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
|
|||
|
||||
[self setKeyboardHeight:(int)kbrect.size.height];
|
||||
#endif
|
||||
|
||||
if (shouldStartTextInput) {
|
||||
SDL_StartTextInput();
|
||||
}
|
||||
}
|
||||
|
||||
- (void)keyboardDidShow:(NSNotification *)notification
|
||||
{
|
||||
showingKeyboard = NO;
|
||||
}
|
||||
|
||||
- (void)keyboardWillHide:(NSNotification *)notification
|
||||
{
|
||||
if (!showingKeyboard && !rotatingOrientation) {
|
||||
BOOL shouldStopTextInput = NO;
|
||||
|
||||
if (SDL_IsTextInputActive() && !showingKeyboard && !rotatingOrientation) {
|
||||
shouldStopTextInput = YES;
|
||||
}
|
||||
|
||||
hidingKeyboard = YES;
|
||||
[self setKeyboardHeight:0];
|
||||
|
||||
if (shouldStopTextInput) {
|
||||
SDL_StopTextInput();
|
||||
}
|
||||
[self setKeyboardHeight:0];
|
||||
}
|
||||
|
||||
- (void)keyboardDidHide:(NSNotification *)notification
|
||||
{
|
||||
hidingKeyboard = NO;
|
||||
}
|
||||
|
||||
- (void)textFieldTextDidChange:(NSNotification *)notification
|
||||
|
|
@ -402,8 +467,8 @@ SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *o
|
|||
size_t deleteLength = SDL_utf8strlen([[committedText substringFromIndex:matchLength] UTF8String]);
|
||||
while (deleteLength > 0) {
|
||||
/* Send distinct down and up events for each backspace action */
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_BACKSPACE);
|
||||
SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_BACKSPACE);
|
||||
SDL_SendVirtualKeyboardKey(SDL_PRESSED, SDL_SCANCODE_BACKSPACE);
|
||||
SDL_SendVirtualKeyboardKey(SDL_RELEASED, SDL_SCANCODE_BACKSPACE);
|
||||
--deleteLength;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,34 +37,30 @@ typedef struct
|
|||
const char *libname;
|
||||
} waylanddynlib;
|
||||
|
||||
#ifndef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL
|
||||
#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL NULL
|
||||
#endif
|
||||
#ifndef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR
|
||||
#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR NULL
|
||||
#endif
|
||||
#ifndef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON
|
||||
#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON NULL
|
||||
#endif
|
||||
#ifndef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR
|
||||
#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR NULL
|
||||
#endif
|
||||
|
||||
static waylanddynlib waylandlibs[] = {
|
||||
{ NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC },
|
||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL
|
||||
{ NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL },
|
||||
#endif
|
||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR
|
||||
{ NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR },
|
||||
#endif
|
||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON
|
||||
{ NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON },
|
||||
{ NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR }
|
||||
#endif
|
||||
#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR
|
||||
{ NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR },
|
||||
#endif
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static void *WAYLAND_GetSym(const char *fnname, int *pHasModule, SDL_bool required)
|
||||
{
|
||||
int i;
|
||||
void *fn = NULL;
|
||||
for (i = 0; i < SDL_TABLESIZE(waylandlibs); i++) {
|
||||
if (waylandlibs[i].lib != NULL) {
|
||||
fn = SDL_LoadFunction(waylandlibs[i].lib, fnname);
|
||||
waylanddynlib *dynlib;
|
||||
for (dynlib = waylandlibs; dynlib->libname; dynlib++) {
|
||||
if (dynlib->lib != NULL) {
|
||||
fn = SDL_LoadFunction(dynlib->lib, fnname);
|
||||
if (fn != NULL) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -72,10 +68,11 @@ static void *WAYLAND_GetSym(const char *fnname, int *pHasModule, SDL_bool requir
|
|||
}
|
||||
|
||||
#if DEBUG_DYNAMIC_WAYLAND
|
||||
if (fn != NULL)
|
||||
SDL_Log("WAYLAND: Found '%s' in %s (%p)\n", fnname, waylandlibs[i].libname, fn);
|
||||
else
|
||||
if (fn != NULL) {
|
||||
SDL_Log("WAYLAND: Found '%s' in %s (%p)\n", fnname, dynlib->libname, fn);
|
||||
} else {
|
||||
SDL_Log("WAYLAND: Symbol '%s' NOT FOUND!\n", fnname);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fn == NULL && required) {
|
||||
|
|
|
|||
|
|
@ -33,162 +33,220 @@
|
|||
|
||||
#include "SDL_waylandmessagebox.h"
|
||||
|
||||
#define ZENITY_VERSION_LEN 32 /* Number of bytes to read from zenity --version (including NUL)*/
|
||||
|
||||
#define MAX_BUTTONS 8 /* Maximum number of buttons supported */
|
||||
|
||||
int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
{
|
||||
int fd_pipe[2]; /* fd_pipe[0]: read end of pipe, fd_pipe[1]: write end of pipe */
|
||||
static int run_zenity(const char **args, int fd_pipe[2]) {
|
||||
int status;
|
||||
pid_t pid1;
|
||||
|
||||
if (messageboxdata->numbuttons > MAX_BUTTONS) {
|
||||
return SDL_SetError("Too many buttons (%d max allowed)", MAX_BUTTONS);
|
||||
}
|
||||
|
||||
if (pipe(fd_pipe) != 0) { /* create a pipe */
|
||||
return SDL_SetError("pipe() failed: %s", strerror(errno));
|
||||
}
|
||||
|
||||
pid1 = fork();
|
||||
if (pid1 == 0) { /* child process */
|
||||
int argc = 5, i;
|
||||
const char *argv[5 + 2 /* icon name */ + 2 /* title */ + 2 /* message */ + 2 * MAX_BUTTONS + 1 /* NULL */] = {
|
||||
"zenity", "--question", "--switch", "--no-wrap", "--no-markup"
|
||||
};
|
||||
|
||||
close(fd_pipe[0]); /* no reading from pipe */
|
||||
/* write stdout in pipe */
|
||||
if (dup2(fd_pipe[1], STDOUT_FILENO) == -1) {
|
||||
_exit(128);
|
||||
}
|
||||
|
||||
argv[argc++] = "--icon-name";
|
||||
switch (messageboxdata->flags) {
|
||||
case SDL_MESSAGEBOX_ERROR:
|
||||
argv[argc++] = "dialog-error";
|
||||
break;
|
||||
case SDL_MESSAGEBOX_WARNING:
|
||||
argv[argc++] = "dialog-warning";
|
||||
break;
|
||||
case SDL_MESSAGEBOX_INFORMATION:
|
||||
default:
|
||||
argv[argc++] = "dialog-information";
|
||||
break;
|
||||
}
|
||||
|
||||
if (messageboxdata->title && messageboxdata->title[0]) {
|
||||
argv[argc++] = "--title";
|
||||
argv[argc++] = messageboxdata->title;
|
||||
} else {
|
||||
argv[argc++] = "--title=\"\"";
|
||||
}
|
||||
|
||||
if (messageboxdata->message && messageboxdata->message[0]) {
|
||||
argv[argc++] = "--text";
|
||||
argv[argc++] = messageboxdata->message;
|
||||
} else {
|
||||
argv[argc++] = "--text=\"\"";
|
||||
}
|
||||
|
||||
for (i = 0; i < messageboxdata->numbuttons; ++i) {
|
||||
if (messageboxdata->buttons[i].text && messageboxdata->buttons[i].text[0]) {
|
||||
argv[argc++] = "--extra-button";
|
||||
argv[argc++] = messageboxdata->buttons[i].text;
|
||||
} else {
|
||||
argv[argc++] = "--extra-button=\"\"";
|
||||
}
|
||||
}
|
||||
argv[argc] = NULL;
|
||||
|
||||
/* const casting argv is fine:
|
||||
* https://pubs.opengroup.org/onlinepubs/9699919799/functions/fexecve.html -> rational
|
||||
*/
|
||||
execvp("zenity", (char **)argv);
|
||||
execvp("zenity", (char **)args);
|
||||
_exit(129);
|
||||
} else if (pid1 < 0) {
|
||||
close(fd_pipe[0]);
|
||||
close(fd_pipe[1]);
|
||||
} else if (pid1 < 0) { /* fork() failed */
|
||||
return SDL_SetError("fork() failed: %s", strerror(errno));
|
||||
} else {
|
||||
int status;
|
||||
if (waitpid(pid1, &status, 0) == pid1) {
|
||||
if (WIFEXITED(status)) {
|
||||
if (WEXITSTATUS(status) < 128) {
|
||||
int i;
|
||||
size_t output_len = 1;
|
||||
char *output = NULL;
|
||||
char *tmp = NULL;
|
||||
FILE *outputfp = NULL;
|
||||
|
||||
close(fd_pipe[1]); /* no writing to pipe */
|
||||
/* At this point, if no button ID is needed, we can just bail as soon as the
|
||||
* process has completed.
|
||||
*/
|
||||
if (buttonid == NULL) {
|
||||
close(fd_pipe[0]);
|
||||
return 0;
|
||||
}
|
||||
*buttonid = -1;
|
||||
|
||||
/* find button with longest text */
|
||||
for (i = 0; i < messageboxdata->numbuttons; ++i) {
|
||||
if (messageboxdata->buttons[i].text != NULL) {
|
||||
const size_t button_len = SDL_strlen(messageboxdata->buttons[i].text);
|
||||
if (button_len > output_len) {
|
||||
output_len = button_len;
|
||||
}
|
||||
}
|
||||
}
|
||||
output = SDL_malloc(output_len + 1);
|
||||
if (output == NULL) {
|
||||
close(fd_pipe[0]);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
output[0] = '\0';
|
||||
|
||||
outputfp = fdopen(fd_pipe[0], "r");
|
||||
if (outputfp == NULL) {
|
||||
SDL_free(output);
|
||||
close(fd_pipe[0]);
|
||||
return SDL_SetError("Couldn't open pipe for reading: %s", strerror(errno));
|
||||
}
|
||||
tmp = fgets(output, output_len + 1, outputfp);
|
||||
(void)fclose(outputfp);
|
||||
|
||||
if ((tmp == NULL) || (*tmp == '\0') || (*tmp == '\n')) {
|
||||
SDL_free(output);
|
||||
return 0; /* User simply closed the dialog */
|
||||
}
|
||||
|
||||
/* It likes to add a newline... */
|
||||
tmp = SDL_strrchr(output, '\n');
|
||||
if (tmp != NULL) {
|
||||
*tmp = '\0';
|
||||
}
|
||||
|
||||
/* Check which button got pressed */
|
||||
for (i = 0; i < messageboxdata->numbuttons; i += 1) {
|
||||
if (messageboxdata->buttons[i].text != NULL) {
|
||||
if (SDL_strcmp(output, messageboxdata->buttons[i].text) == 0) {
|
||||
*buttonid = messageboxdata->buttons[i].buttonid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_free(output);
|
||||
return 0; /* success! */
|
||||
} else {
|
||||
return SDL_SetError("zenity reported error or failed to launch: %d", WEXITSTATUS(status));
|
||||
}
|
||||
} else {
|
||||
return SDL_SetError("zenity failed for some reason");
|
||||
}
|
||||
} else {
|
||||
} else { /* parent process */
|
||||
close(fd_pipe[1]); /* no writing to the pipe */
|
||||
if (waitpid(pid1, &status, 0) != pid1) {
|
||||
return SDL_SetError("Waiting on zenity failed: %s", strerror(errno));
|
||||
}
|
||||
|
||||
if (!WIFEXITED(status)) {
|
||||
return SDL_SetError("zenity failed for some reason");
|
||||
}
|
||||
|
||||
if (WEXITSTATUS(status) >= 128) {
|
||||
return SDL_SetError("zenity reported error or failed to launch: %d", WEXITSTATUS(status));
|
||||
}
|
||||
|
||||
return 0; /* success! */
|
||||
}
|
||||
}
|
||||
|
||||
static int get_zenity_version(int *major, int *minor) {
|
||||
int fd_pipe[2]; /* fd_pipe[0]: read end of pipe, fd_pipe[1]: write end of pipe */
|
||||
const char *argv[] = { "zenity", "--version", NULL };
|
||||
|
||||
if (pipe(fd_pipe) != 0) { /* create a pipe */
|
||||
return SDL_SetError("pipe() failed: %s", strerror(errno));
|
||||
}
|
||||
|
||||
if (run_zenity(argv, fd_pipe) == 0) {
|
||||
FILE *outputfp = NULL;
|
||||
char version_str[ZENITY_VERSION_LEN];
|
||||
char *version_ptr = NULL, *end_ptr = NULL;
|
||||
int tmp;
|
||||
|
||||
outputfp = fdopen(fd_pipe[0], "r");
|
||||
if (outputfp == NULL) {
|
||||
close(fd_pipe[0]);
|
||||
return SDL_SetError("failed to open pipe for reading: %s", strerror(errno));
|
||||
}
|
||||
|
||||
version_ptr = fgets(version_str, ZENITY_VERSION_LEN, outputfp);
|
||||
(void)fclose(outputfp); /* will close underlying fd */
|
||||
|
||||
/* we expect the version string is in the form of MAJOR.MINOR.MICRO
|
||||
* as described in meson.build. We'll ignore everything after that.
|
||||
*/
|
||||
tmp = (int) SDL_strtol(version_ptr, &end_ptr, 10);
|
||||
if (tmp == 0 && end_ptr == version_ptr) {
|
||||
return SDL_SetError("failed to get zenity major version number");
|
||||
}
|
||||
*major = tmp;
|
||||
|
||||
version_ptr = end_ptr + 1; /* skip the dot */
|
||||
tmp = (int) SDL_strtol(version_ptr, &end_ptr, 10);
|
||||
if (tmp == 0 && end_ptr == version_ptr) {
|
||||
return SDL_SetError("failed to get zenity minor version number");
|
||||
}
|
||||
*minor = tmp;
|
||||
|
||||
return 0; /* success */
|
||||
}
|
||||
|
||||
close(fd_pipe[0]);
|
||||
close(fd_pipe[1]);
|
||||
return -1; /* run_zenity should've called SDL_SetError() */
|
||||
}
|
||||
|
||||
int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) {
|
||||
int fd_pipe[2]; /* fd_pipe[0]: read end of pipe, fd_pipe[1]: write end of pipe */
|
||||
int zenity_major = 0, zenity_minor = 0, output_len = 0;
|
||||
int argc = 5, i;
|
||||
const char *argv[5 + 2 /* icon name */ + 2 /* title */ + 2 /* message */ + 2 * MAX_BUTTONS + 1 /* NULL */] = {
|
||||
"zenity", "--question", "--switch", "--no-wrap", "--no-markup"
|
||||
};
|
||||
|
||||
if (messageboxdata->numbuttons > MAX_BUTTONS) {
|
||||
return SDL_SetError("Too many buttons (%d max allowed)", MAX_BUTTONS);
|
||||
}
|
||||
|
||||
/* get zenity version so we know which arg to use */
|
||||
if (get_zenity_version(&zenity_major, &zenity_minor) != 0) {
|
||||
return -1; /* get_zenity_version() calls SDL_SetError(), so message is already set */
|
||||
}
|
||||
|
||||
if (pipe(fd_pipe) != 0) { /* create a pipe */
|
||||
return SDL_SetError("pipe() failed: %s", strerror(errno));
|
||||
}
|
||||
|
||||
/* https://gitlab.gnome.org/GNOME/zenity/-/commit/c686bdb1b45e95acf010efd9ca0c75527fbb4dea
|
||||
* This commit removed --icon-name without adding a deprecation notice.
|
||||
* We need to handle it gracefully, otherwise no message box will be shown.
|
||||
*/
|
||||
argv[argc++] = zenity_major > 3 || (zenity_major == 3 && zenity_minor >= 90) ? "--icon" : "--icon-name";
|
||||
switch (messageboxdata->flags) {
|
||||
case SDL_MESSAGEBOX_ERROR:
|
||||
argv[argc++] = "dialog-error";
|
||||
break;
|
||||
case SDL_MESSAGEBOX_WARNING:
|
||||
argv[argc++] = "dialog-warning";
|
||||
break;
|
||||
case SDL_MESSAGEBOX_INFORMATION:
|
||||
default:
|
||||
argv[argc++] = "dialog-information";
|
||||
break;
|
||||
}
|
||||
|
||||
if (messageboxdata->title && messageboxdata->title[0]) {
|
||||
argv[argc++] = "--title";
|
||||
argv[argc++] = messageboxdata->title;
|
||||
} else {
|
||||
argv[argc++] = "--title=\"\"";
|
||||
}
|
||||
|
||||
if (messageboxdata->message && messageboxdata->message[0]) {
|
||||
argv[argc++] = "--text";
|
||||
argv[argc++] = messageboxdata->message;
|
||||
} else {
|
||||
argv[argc++] = "--text=\"\"";
|
||||
}
|
||||
|
||||
for (i = 0; i < messageboxdata->numbuttons; ++i) {
|
||||
if (messageboxdata->buttons[i].text && messageboxdata->buttons[i].text[0]) {
|
||||
int len = SDL_strlen(messageboxdata->buttons[i].text);
|
||||
if (len > output_len) {
|
||||
output_len = len;
|
||||
}
|
||||
|
||||
argv[argc++] = "--extra-button";
|
||||
argv[argc++] = messageboxdata->buttons[i].text;
|
||||
} else {
|
||||
argv[argc++] = "--extra-button=\"\"";
|
||||
}
|
||||
}
|
||||
argv[argc] = NULL;
|
||||
|
||||
if (run_zenity(argv, fd_pipe) == 0) {
|
||||
FILE *outputfp = NULL;
|
||||
char *output = NULL;
|
||||
char *tmp = NULL;
|
||||
|
||||
if (buttonid == NULL) {
|
||||
/* if we don't need buttonid, we can return immediately */
|
||||
close(fd_pipe[0]);
|
||||
return 0; /* success */
|
||||
}
|
||||
*buttonid = -1;
|
||||
|
||||
output = SDL_malloc(output_len + 1);
|
||||
if (output == NULL) {
|
||||
close(fd_pipe[0]);
|
||||
return SDL_OutOfMemory();
|
||||
}
|
||||
output[0] = '\0';
|
||||
|
||||
outputfp = fdopen(fd_pipe[0], "r");
|
||||
if (outputfp == NULL) {
|
||||
SDL_free(output);
|
||||
close(fd_pipe[0]);
|
||||
return SDL_SetError("Couldn't open pipe for reading: %s", strerror(errno));
|
||||
}
|
||||
tmp = fgets(output, output_len + 1, outputfp);
|
||||
(void)fclose(outputfp);
|
||||
|
||||
if ((tmp == NULL) || (*tmp == '\0') || (*tmp == '\n')) {
|
||||
SDL_free(output);
|
||||
return 0; /* User simply closed the dialog */
|
||||
}
|
||||
|
||||
/* It likes to add a newline... */
|
||||
tmp = SDL_strrchr(output, '\n');
|
||||
if (tmp != NULL) {
|
||||
*tmp = '\0';
|
||||
}
|
||||
|
||||
/* Check which button got pressed */
|
||||
for (i = 0; i < messageboxdata->numbuttons; i += 1) {
|
||||
if (messageboxdata->buttons[i].text != NULL) {
|
||||
if (SDL_strcmp(output, messageboxdata->buttons[i].text) == 0) {
|
||||
*buttonid = messageboxdata->buttons[i].buttonid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_free(output);
|
||||
return 0; /* success! */
|
||||
}
|
||||
|
||||
close(fd_pipe[0]);
|
||||
close(fd_pipe[1]);
|
||||
return -1; /* run_zenity() calls SDL_SetError(), so message is already set */
|
||||
}
|
||||
|
||||
#endif /* SDL_VIDEO_DRIVER_WAYLAND */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
|||
|
|
@ -59,12 +59,13 @@ SDL_FORCE_INLINE SDL_bool FloatEqual(float a, float b)
|
|||
static void GetFullScreenDimensions(SDL_Window *window, int *width, int *height, int *drawable_width, int *drawable_height)
|
||||
{
|
||||
SDL_WindowData *wind = (SDL_WindowData *)window->driverdata;
|
||||
SDL_WaylandOutputData *output = (SDL_WaylandOutputData *)SDL_GetDisplayForWindow(window)->driverdata;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
SDL_WaylandOutputData *output = display ? (SDL_WaylandOutputData *)display->driverdata : NULL;
|
||||
|
||||
int fs_width, fs_height;
|
||||
int buf_width, buf_height;
|
||||
const int output_width = wind->fs_output_width ? wind->fs_output_width : output->width;
|
||||
const int output_height = wind->fs_output_height ? wind->fs_output_height : output->height;
|
||||
const int output_width = wind->fs_output_width ? wind->fs_output_width : (output ? output->width : wind->window_width);
|
||||
const int output_height = wind->fs_output_height ? wind->fs_output_height : (output ? output->height : wind->window_height);
|
||||
|
||||
/*
|
||||
* Fullscreen desktop mandates a desktop sized window, so that's what applications will get.
|
||||
|
|
@ -133,7 +134,10 @@ static SDL_bool NeedViewport(SDL_Window *window)
|
|||
{
|
||||
SDL_WindowData *wind = window->driverdata;
|
||||
SDL_VideoData *video = wind->waylandData;
|
||||
SDL_WaylandOutputData *output = ((SDL_WaylandOutputData *)SDL_GetDisplayForWindow(window)->driverdata);
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
SDL_WaylandOutputData *output = display ? ((SDL_WaylandOutputData *)display->driverdata) : NULL;
|
||||
const int output_width = wind->fs_output_width ? wind->fs_output_width : (output ? output->width : wind->window_width);
|
||||
const int output_height = wind->fs_output_height ? wind->fs_output_height : (output ? output->height : wind->window_height);
|
||||
int fs_width, fs_height;
|
||||
|
||||
/*
|
||||
|
|
@ -144,7 +148,7 @@ static SDL_bool NeedViewport(SDL_Window *window)
|
|||
if (video->viewporter != NULL) {
|
||||
if (FullscreenModeEmulation(window)) {
|
||||
GetFullScreenDimensions(window, &fs_width, &fs_height, NULL, NULL);
|
||||
if (fs_width != output->width || fs_height != output->height) {
|
||||
if (fs_width != output_width || fs_height != output_height) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
} else if (SurfaceScaleIsFractional(window) && (window->flags & SDL_WINDOW_ALLOW_HIGHDPI)) {
|
||||
|
|
@ -217,7 +221,8 @@ static void ConfigureWindowGeometry(SDL_Window *window)
|
|||
{
|
||||
SDL_WindowData *data = window->driverdata;
|
||||
SDL_VideoData *viddata = data->waylandData;
|
||||
SDL_WaylandOutputData *output = (SDL_WaylandOutputData *)SDL_GetDisplayForWindow(window)->driverdata;
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
|
||||
SDL_WaylandOutputData *output = display ? (SDL_WaylandOutputData *)display->driverdata : NULL;
|
||||
struct wl_region *region;
|
||||
const int old_dw = data->drawable_width;
|
||||
const int old_dh = data->drawable_height;
|
||||
|
|
@ -237,8 +242,8 @@ static void ConfigureWindowGeometry(SDL_Window *window)
|
|||
|
||||
if (FullscreenModeEmulation(window) && NeedViewport(window)) {
|
||||
int fs_width, fs_height;
|
||||
const int output_width = data->fs_output_width ? data->fs_output_width : output->width;
|
||||
const int output_height = data->fs_output_height ? data->fs_output_height : output->height;
|
||||
const int output_width = data->fs_output_width ? data->fs_output_width : (output ? output->width : data->window_width);
|
||||
const int output_height = data->fs_output_height ? data->fs_output_height : (output ? output->height : data->window_height);
|
||||
|
||||
window_size_changed = data->window_width != output_width || data->window_height != output_height;
|
||||
|
||||
|
|
@ -559,7 +564,6 @@ static void handle_configure_xdg_toplevel(void *data,
|
|||
{
|
||||
SDL_WindowData *wind = (SDL_WindowData *)data;
|
||||
SDL_Window *window = wind->sdlwindow;
|
||||
SDL_WaylandOutputData *driverdata;
|
||||
|
||||
enum xdg_toplevel_state *state;
|
||||
SDL_bool fullscreen = SDL_FALSE;
|
||||
|
|
@ -586,8 +590,6 @@ static void handle_configure_xdg_toplevel(void *data,
|
|||
}
|
||||
}
|
||||
|
||||
driverdata = (SDL_WaylandOutputData *)SDL_GetDisplayForWindow(window)->driverdata;
|
||||
|
||||
UpdateWindowFullscreen(window, fullscreen);
|
||||
|
||||
if (!fullscreen) {
|
||||
|
|
@ -664,12 +666,6 @@ static void handle_configure_xdg_toplevel(void *data,
|
|||
window->h = height;
|
||||
wind->needs_resize_event = SDL_TRUE;
|
||||
}
|
||||
|
||||
/* This part is good though. */
|
||||
if ((window->flags & SDL_WINDOW_ALLOW_HIGHDPI) && !FloatEqual(wind->scale_factor, driverdata->scale_factor)) {
|
||||
wind->scale_factor = driverdata->scale_factor;
|
||||
wind->needs_resize_event = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -819,12 +815,10 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
|
|||
{
|
||||
SDL_WindowData *wind = (SDL_WindowData *)user_data;
|
||||
SDL_Window *window = wind->sdlwindow;
|
||||
SDL_WaylandOutputData *driverdata;
|
||||
struct libdecor_state *state;
|
||||
|
||||
enum libdecor_window_state window_state;
|
||||
int width, height;
|
||||
float scale_factor = wind->scale_factor;
|
||||
|
||||
SDL_bool focused = SDL_FALSE;
|
||||
SDL_bool fullscreen = SDL_FALSE;
|
||||
|
|
@ -844,8 +838,6 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
|
|||
}
|
||||
floating = !(fullscreen || maximized || tiled);
|
||||
|
||||
driverdata = (SDL_WaylandOutputData *)SDL_GetDisplayForWindow(window)->driverdata;
|
||||
|
||||
UpdateWindowFullscreen(window, fullscreen);
|
||||
|
||||
if (!fullscreen) {
|
||||
|
|
@ -887,11 +879,6 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
|
|||
if (FullscreenModeEmulation(window)) {
|
||||
GetFullScreenDimensions(window, &width, &height, NULL, NULL);
|
||||
}
|
||||
|
||||
/* This part is good though. */
|
||||
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
|
||||
scale_factor = driverdata->scale_factor;
|
||||
}
|
||||
} else if (!(window->flags & SDL_WINDOW_RESIZABLE) || (floating && wind->floating_resize_pending)) {
|
||||
width = window->windowed.w;
|
||||
height = window->windowed.h;
|
||||
|
|
@ -936,7 +923,7 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
|
|||
wind->was_floating = floating;
|
||||
|
||||
/* Do the resize on the SDL side (this will set window->w/h)... */
|
||||
Wayland_HandleResize(window, width, height, scale_factor);
|
||||
Wayland_HandleResize(window, width, height, wind->scale_factor);
|
||||
|
||||
/* ... then commit the changes on the libdecor side. */
|
||||
state = libdecor_state_new(wind->window_width, wind->window_height);
|
||||
|
|
@ -1003,7 +990,7 @@ static const struct qt_extended_surface_listener extended_surface_listener = {
|
|||
|
||||
static void update_scale_factor(SDL_WindowData *window)
|
||||
{
|
||||
float old_factor = window->scale_factor;
|
||||
const float old_factor = window->scale_factor;
|
||||
float new_factor;
|
||||
int i;
|
||||
|
||||
|
|
@ -1012,14 +999,18 @@ static void update_scale_factor(SDL_WindowData *window)
|
|||
return;
|
||||
}
|
||||
|
||||
if (FULLSCREEN_VISIBLE(window->sdlwindow)) {
|
||||
if (window->num_outputs == 0) {
|
||||
/* No display connected, just fall back. */
|
||||
new_factor = old_factor;
|
||||
} else if (FULLSCREEN_VISIBLE(window->sdlwindow)) {
|
||||
/* For fullscreen, use the active display's scale factor */
|
||||
SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window->sdlwindow);
|
||||
SDL_WaylandOutputData *driverdata = display->driverdata;
|
||||
new_factor = driverdata->scale_factor;
|
||||
} else if (window->num_outputs == 0) {
|
||||
/* No monitor (somehow)? Just fall back. */
|
||||
new_factor = old_factor;
|
||||
if (display) {
|
||||
SDL_WaylandOutputData *driverdata = display->driverdata;
|
||||
new_factor = driverdata->scale_factor;
|
||||
} else {
|
||||
new_factor = old_factor;
|
||||
}
|
||||
} else {
|
||||
/* Check every display's factor, use the highest */
|
||||
new_factor = 0.0f;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "SDL_windowsvideo.h"
|
||||
#include "SDL_windowswindow.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "../../events/SDL_clipboardevents_c.h"
|
||||
|
||||
#ifdef UNICODE
|
||||
|
|
@ -102,23 +103,31 @@ int WIN_SetClipboardText(_THIS, const char *text)
|
|||
|
||||
char *WIN_GetClipboardText(_THIS)
|
||||
{
|
||||
char *text;
|
||||
char *text = NULL;
|
||||
|
||||
text = NULL;
|
||||
if (IsClipboardFormatAvailable(TEXT_FORMAT) &&
|
||||
OpenClipboard(GetWindowHandle(_this))) {
|
||||
HANDLE hMem;
|
||||
LPTSTR tstr;
|
||||
if (IsClipboardFormatAvailable(TEXT_FORMAT)) {
|
||||
/* Retry to open the clipboard in case another application has it open */
|
||||
const int MAX_ATTEMPTS = 3;
|
||||
int attempt;
|
||||
|
||||
hMem = GetClipboardData(TEXT_FORMAT);
|
||||
if (hMem) {
|
||||
tstr = (LPTSTR)GlobalLock(hMem);
|
||||
text = WIN_StringToUTF8(tstr);
|
||||
GlobalUnlock(hMem);
|
||||
} else {
|
||||
WIN_SetError("Couldn't get clipboard data");
|
||||
for (attempt = 0; attempt < MAX_ATTEMPTS; ++attempt) {
|
||||
if (OpenClipboard(GetWindowHandle(_this))) {
|
||||
HANDLE hMem;
|
||||
LPTSTR tstr;
|
||||
|
||||
hMem = GetClipboardData(TEXT_FORMAT);
|
||||
if (hMem) {
|
||||
tstr = (LPTSTR)GlobalLock(hMem);
|
||||
text = WIN_StringToUTF8(tstr);
|
||||
GlobalUnlock(hMem);
|
||||
} else {
|
||||
WIN_SetError("Couldn't get clipboard data");
|
||||
}
|
||||
CloseClipboard();
|
||||
break;
|
||||
}
|
||||
SDL_Delay(10);
|
||||
}
|
||||
CloseClipboard();
|
||||
}
|
||||
if (text == NULL) {
|
||||
text = SDL_strdup("");
|
||||
|
|
|
|||
|
|
@ -318,10 +318,13 @@ static void WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info,
|
|||
if (SDL_wcscmp(driverdata->DeviceName, info->szDevice) == 0) {
|
||||
SDL_bool moved = (index != i);
|
||||
|
||||
if (index >= _this->num_displays) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (moved) {
|
||||
SDL_VideoDisplay tmp;
|
||||
|
||||
SDL_assert(index < _this->num_displays);
|
||||
SDL_memcpy(&tmp, &_this->displays[index], sizeof(tmp));
|
||||
SDL_memcpy(&_this->displays[index], &_this->displays[i], sizeof(tmp));
|
||||
SDL_memcpy(&_this->displays[i], &tmp, sizeof(tmp));
|
||||
|
|
|
|||
|
|
@ -132,10 +132,7 @@ static int SetSelectionText(_THIS, const char *text, Atom selection_type)
|
|||
X11_GetSDLCutBufferClipboardInternalFormat(display, SDL_X11_CLIPBOARD_MIME_TYPE_STRING), 8, PropModeReplace,
|
||||
(const unsigned char *)text, SDL_strlen(text));
|
||||
|
||||
if (X11_XGetSelectionOwner(display, selection_type) != window) {
|
||||
X11_XSetSelectionOwner(display, selection_type, window, CurrentTime);
|
||||
}
|
||||
|
||||
X11_XSetSelectionOwner(display, selection_type, window, CurrentTime);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -643,8 +643,9 @@ int X11_InitModes(_THIS)
|
|||
int xrandr_major, xrandr_minor;
|
||||
/* require at least XRandR v1.3 */
|
||||
if (CheckXRandR(data->display, &xrandr_major, &xrandr_minor) &&
|
||||
(xrandr_major >= 2 || (xrandr_major == 1 && xrandr_minor >= 3))) {
|
||||
return X11_InitModes_XRandR(_this);
|
||||
(xrandr_major >= 2 || (xrandr_major == 1 && xrandr_minor >= 3)) &&
|
||||
X11_InitModes_XRandR(_this) == 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif /* SDL_VIDEO_DRIVER_X11_XRANDR */
|
||||
|
|
|
|||
|
|
@ -1180,33 +1180,6 @@ void X11_ShowWindow(_THIS, SDL_Window *window)
|
|||
if (data->border_left == 0 && data->border_right == 0 && data->border_top == 0 && data->border_bottom == 0) {
|
||||
X11_GetBorderValues(data);
|
||||
}
|
||||
|
||||
/* Check if the window manager moved us somewhere unexpected, just in case. */
|
||||
{
|
||||
int (*prev_handler)(Display *, XErrorEvent *) = NULL;
|
||||
Window childReturn, root, parent;
|
||||
Window *children;
|
||||
unsigned int childCount;
|
||||
XWindowAttributes attrs;
|
||||
int x, y;
|
||||
|
||||
X11_XSync(display, False);
|
||||
prev_handler = X11_XSetErrorHandler(X11_CatchAnyError);
|
||||
caught_x11_error = SDL_FALSE;
|
||||
X11_XQueryTree(display, data->xwindow, &root, &parent, &children, &childCount);
|
||||
X11_XGetWindowAttributes(display, data->xwindow, &attrs);
|
||||
X11_XTranslateCoordinates(display, parent, DefaultRootWindow(display),
|
||||
attrs.x, attrs.y, &x, &y, &childReturn);
|
||||
|
||||
if (!caught_x11_error) {
|
||||
/* if these values haven't changed from our current beliefs, these don't actually generate events. */
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y);
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, attrs.width, attrs.height);
|
||||
}
|
||||
|
||||
X11_XSetErrorHandler(prev_handler);
|
||||
caught_x11_error = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void X11_HideWindow(_THIS, SDL_Window *window)
|
||||
|
|
@ -1328,7 +1301,7 @@ static void SetWindowMaximized(_THIS, SDL_Window *window, SDL_bool maximized)
|
|||
X11_XSync(display, False);
|
||||
prev_handler = X11_XSetErrorHandler(X11_CatchAnyError);
|
||||
|
||||
timeout = SDL_GetTicks64() + 1000;
|
||||
timeout = SDL_GetTicks64() + 100;
|
||||
while (SDL_TRUE) {
|
||||
caught_x11_error = SDL_FALSE;
|
||||
X11_XSync(display, False);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue