wayland: Small optimization for output removal function
In the case where an output is being removed, the SDL_DisplayData is already known, so no need to retrieve it from the wl_output user data.
This commit is contained in:
@@ -951,7 +951,7 @@ static void Wayland_free_display(SDL_VideoDisplay *display)
|
|||||||
* so ensure that no window continues to hold a reference to a removed output.
|
* so ensure that no window continues to hold a reference to a removed output.
|
||||||
*/
|
*/
|
||||||
for (SDL_Window *window = SDL_GetVideoDevice()->windows; window; window = window->next) {
|
for (SDL_Window *window = SDL_GetVideoDevice()->windows; window; window = window->next) {
|
||||||
Wayland_RemoveOutputFromWindow(window->driverdata, display_data->output);
|
Wayland_RemoveOutputFromWindow(window->driverdata, display_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_free(display_data->wl_output_name);
|
SDL_free(display_data->wl_output_name);
|
||||||
|
|||||||
@@ -1304,16 +1304,15 @@ static void Wayland_move_window(SDL_Window *window, SDL_DisplayData *driverdata)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wayland_RemoveOutputFromWindow(SDL_WindowData *window, struct wl_output *output)
|
void Wayland_RemoveOutputFromWindow(SDL_WindowData *window, SDL_DisplayData *display_data)
|
||||||
{
|
{
|
||||||
int i, send_move_event = 0;
|
SDL_bool send_move_event = SDL_FALSE;
|
||||||
SDL_DisplayData *driverdata = wl_output_get_user_data(output);
|
|
||||||
|
|
||||||
for (i = 0; i < window->num_outputs; i++) {
|
for (int i = 0; i < window->num_outputs; i++) {
|
||||||
if (window->outputs[i] == driverdata) { /* remove this one */
|
if (window->outputs[i] == display_data) { /* remove this one */
|
||||||
if (i == (window->num_outputs - 1)) {
|
if (i == (window->num_outputs - 1)) {
|
||||||
window->outputs[i] = NULL;
|
window->outputs[i] = NULL;
|
||||||
send_move_event = 1;
|
send_move_event = SDL_TRUE;
|
||||||
} else {
|
} else {
|
||||||
SDL_memmove(&window->outputs[i],
|
SDL_memmove(&window->outputs[i],
|
||||||
&window->outputs[i + 1],
|
&window->outputs[i + 1],
|
||||||
@@ -1335,8 +1334,7 @@ void Wayland_RemoveOutputFromWindow(SDL_WindowData *window, struct wl_output *ou
|
|||||||
Wayland_MaybeUpdateScaleFactor(window);
|
Wayland_MaybeUpdateScaleFactor(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_surface_enter(void *data, struct wl_surface *surface,
|
static void handle_surface_enter(void *data, struct wl_surface *surface, struct wl_output *output)
|
||||||
struct wl_output *output)
|
|
||||||
{
|
{
|
||||||
SDL_WindowData *window = data;
|
SDL_WindowData *window = data;
|
||||||
SDL_DisplayData *driverdata = wl_output_get_user_data(output);
|
SDL_DisplayData *driverdata = wl_output_get_user_data(output);
|
||||||
@@ -1359,16 +1357,15 @@ static void handle_surface_enter(void *data, struct wl_surface *surface,
|
|||||||
Wayland_MaybeUpdateScaleFactor(window);
|
Wayland_MaybeUpdateScaleFactor(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_surface_leave(void *data, struct wl_surface *surface,
|
static void handle_surface_leave(void *data, struct wl_surface *surface, struct wl_output *output)
|
||||||
struct wl_output *output)
|
|
||||||
{
|
{
|
||||||
SDL_WindowData *window = data;
|
SDL_WindowData *window = (SDL_WindowData *)data;
|
||||||
|
|
||||||
if (!SDL_WAYLAND_own_output(output) || !SDL_WAYLAND_own_surface(surface)) {
|
if (!SDL_WAYLAND_own_output(output) || !SDL_WAYLAND_own_surface(surface)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Wayland_RemoveOutputFromWindow(window, output);
|
Wayland_RemoveOutputFromWindow(window, (SDL_DisplayData *)wl_output_get_user_data(output));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_preferred_buffer_scale(void *data, struct wl_surface *wl_surface, int32_t factor)
|
static void handle_preferred_buffer_scale(void *data, struct wl_surface *wl_surface, int32_t factor)
|
||||||
|
|||||||
@@ -206,6 +206,6 @@ extern int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled);
|
|||||||
extern int Wayland_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation);
|
extern int Wayland_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation);
|
||||||
extern int Wayland_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
extern int Wayland_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window);
|
||||||
|
|
||||||
extern void Wayland_RemoveOutputFromWindow(SDL_WindowData *window, struct wl_output *output);
|
extern void Wayland_RemoveOutputFromWindow(SDL_WindowData *window, SDL_DisplayData *display_data);
|
||||||
|
|
||||||
#endif /* SDL_waylandwindow_h_ */
|
#endif /* SDL_waylandwindow_h_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user