update sdl Merge commit '4d48f9d23713d94b861da7b5d41baf2a41334994'

This commit is contained in:
2023-08-12 20:17:29 +02:00
215 changed files with 12672 additions and 17114 deletions

View File

@ -158,6 +158,7 @@ void SDL_WAYLAND_UnloadSymbols(void);
#define libdecor_frame_is_visible (*WAYLAND_libdecor_frame_is_visible)
#define libdecor_frame_is_floating (*WAYLAND_libdecor_frame_is_floating)
#define libdecor_frame_set_parent (*WAYLAND_libdecor_frame_set_parent)
#define libdecor_frame_show_window_menu (*WAYLAND_libdecor_frame_show_window_menu)
#define libdecor_frame_get_xdg_surface (*WAYLAND_libdecor_frame_get_xdg_surface)
#define libdecor_frame_get_xdg_toplevel (*WAYLAND_libdecor_frame_get_xdg_toplevel)
#define libdecor_frame_translate_coordinate (*WAYLAND_libdecor_frame_translate_coordinate)

View File

@ -311,12 +311,25 @@ static SDL_bool keyboard_repeat_key_is_set(SDL_WaylandKeyboardRepeat *repeat_inf
return repeat_info->is_initialized && repeat_info->is_key_down && key == repeat_info->key;
}
static void sync_done_handler(void *data, struct wl_callback *callback, uint32_t callback_data)
{
/* Nothing to do, just destroy the callback */
wl_callback_destroy(callback);
}
static struct wl_callback_listener sync_listener = {
sync_done_handler
};
void Wayland_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window)
{
SDL_VideoData *d = _this->driverdata;
/* TODO: Maybe use a pipe to avoid the compositor roundtrip? */
wl_display_sync(d->display);
/* Queue a sync event to unblock the event queue fd if it's empty and being waited on.
* TODO: Maybe use a pipe to avoid the compositor roundtrip?
*/
struct wl_callback *cb = wl_display_sync(d->display);
wl_callback_add_listener(cb, &sync_listener, NULL);
WAYLAND_wl_display_flush(d->display);
}
@ -541,6 +554,19 @@ static void pointer_handle_leave(void *data, struct wl_pointer *pointer,
}
if (input->pointer_focus) {
SDL_WindowData *wind = (SDL_WindowData *)wl_surface_get_user_data(surface);
if (wind) {
/* Clear the capture flag and raise all buttons */
wind->sdlwindow->flags &= ~SDL_WINDOW_MOUSE_CAPTURE;
SDL_SendMouseButton(Wayland_GetPointerTimestamp(input, 0), wind->sdlwindow, 0, SDL_RELEASED, SDL_BUTTON_LEFT);
SDL_SendMouseButton(Wayland_GetPointerTimestamp(input, 0), wind->sdlwindow, 0, SDL_RELEASED, SDL_BUTTON_RIGHT);
SDL_SendMouseButton(Wayland_GetPointerTimestamp(input, 0), wind->sdlwindow, 0, SDL_RELEASED, SDL_BUTTON_MIDDLE);
SDL_SendMouseButton(Wayland_GetPointerTimestamp(input, 0), wind->sdlwindow, 0, SDL_RELEASED, SDL_BUTTON_X1);
SDL_SendMouseButton(Wayland_GetPointerTimestamp(input, 0), wind->sdlwindow, 0, SDL_RELEASED, SDL_BUTTON_X2);
}
SDL_SetMouseFocus(NULL);
input->pointer_focus = NULL;
}
@ -2705,6 +2731,9 @@ void Wayland_display_destroy_input(SDL_VideoData *d)
if (input->primary_selection_device->selection_source != NULL) {
Wayland_primary_selection_source_destroy(input->primary_selection_device->selection_source);
}
if (input->primary_selection_device->primary_selection_device != NULL) {
zwp_primary_selection_device_v1_destroy(input->primary_selection_device->primary_selection_device);
}
SDL_free(input->primary_selection_device);
}

View File

@ -204,6 +204,7 @@ SDL_WAYLAND_SYM(bool, libdecor_frame_is_visible, (struct libdecor_frame *))
SDL_WAYLAND_SYM(bool, libdecor_frame_is_floating, (struct libdecor_frame *))
SDL_WAYLAND_SYM(void, libdecor_frame_set_parent, (struct libdecor_frame *,\
struct libdecor_frame *))
SDL_WAYLAND_SYM(void, libdecor_frame_show_window_menu, (struct libdecor_frame *, struct wl_seat *, uint32_t, int, int))
SDL_WAYLAND_SYM(struct xdg_surface *, libdecor_frame_get_xdg_surface, (struct libdecor_frame *))
SDL_WAYLAND_SYM(struct xdg_toplevel *, libdecor_frame_get_xdg_toplevel, (struct libdecor_frame *))
SDL_WAYLAND_SYM(void, libdecor_frame_translate_coordinate, (struct libdecor_frame *, int, int, int *, int *))

View File

@ -209,6 +209,7 @@ static SDL_VideoDevice *Wayland_CreateDevice(void)
device->SetWindowHitTest = Wayland_SetWindowHitTest;
device->FlashWindow = Wayland_FlashWindow;
device->HasScreenKeyboardSupport = Wayland_HasScreenKeyboardSupport;
device->ShowWindowSystemMenu = Wayland_ShowWindowSystemMenu;
#ifdef SDL_USE_LIBDBUS
if (SDL_SystemTheme_Init())
@ -672,6 +673,10 @@ static void Wayland_free_display(SDL_VideoDisplay *display)
SDL_DisplayData *display_data = display->driverdata;
int i;
if (display_data->xdg_output) {
zxdg_output_v1_destroy(display_data->xdg_output);
}
if (wl_output_get_version(display_data->output) >= WL_OUTPUT_RELEASE_SINCE_VERSION) {
wl_output_release(display_data->output);
} else {
@ -931,7 +936,7 @@ static void Wayland_VideoCleanup(SDL_VideoDevice *_this)
Wayland_FiniMouse(data);
for (i = _this->num_displays - 1; i >= 0; --i) {
SDL_VideoDisplay *display = &_this->displays[i];
SDL_VideoDisplay *display = _this->displays[i];
Wayland_free_display(display);
}

View File

@ -2154,7 +2154,7 @@ int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window)
if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) {
int i;
for (i = 0; i < _this->num_displays; i++) {
float scale = _this->displays[i].driverdata->scale_factor;
float scale = _this->displays[i]->driverdata->scale_factor;
data->windowed_scale_factor = SDL_max(data->windowed_scale_factor, scale);
}
}
@ -2357,6 +2357,23 @@ void Wayland_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window)
WAYLAND_wl_display_flush(viddata->display);
}
void Wayland_ShowWindowSystemMenu(SDL_Window *window, int x, int y)
{
SDL_WindowData *wind = window->driverdata;
#ifdef HAVE_LIBDECOR_H
if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) {
if (wind->shell_surface.libdecor.frame) {
libdecor_frame_show_window_menu(wind->shell_surface.libdecor.frame, wind->waylandData->input->seat, wind->waylandData->input->last_implicit_grab_serial, x, y);
}
} else
#endif
if (wind->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL) {
if (wind->shell_surface.xdg.roleobj.toplevel) {
xdg_toplevel_show_window_menu(wind->shell_surface.xdg.roleobj.toplevel, wind->waylandData->input->seat, wind->waylandData->input->last_implicit_grab_serial, x, y);
}
}
}
int Wayland_SuspendScreenSaver(SDL_VideoDevice *_this)
{
SDL_VideoData *data = _this->driverdata;

View File

@ -150,6 +150,7 @@ extern void Wayland_SetWindowMaximumSize(SDL_VideoDevice *_this, SDL_Window *win
extern void Wayland_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h);
extern int Wayland_SetWindowModalFor(SDL_VideoDevice *_this, SDL_Window *modal_window, SDL_Window *parent_window);
extern void Wayland_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window);
extern void Wayland_ShowWindowSystemMenu(SDL_Window *window, int x, int y);
extern void Wayland_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window);
extern int Wayland_SuspendScreenSaver(SDL_VideoDevice *_this);