src/video/wayland/SDL_waylandwindow.c
changeset 12889 32d98e72ed94
parent 12844 d92b5fbb5ac0
equal deleted inserted replaced
12888:3dd2f2634e46 12889:32d98e72ed94
   343 #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
   343 #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */
   344 
   344 
   345 static void
   345 static void
   346 update_scale_factor(SDL_WindowData *window) {
   346 update_scale_factor(SDL_WindowData *window) {
   347    float old_factor = window->scale_factor, new_factor = 0.0;
   347    float old_factor = window->scale_factor, new_factor = 0.0;
       
   348    int i;
   348 
   349 
   349    if (!(window->sdlwindow->flags & SDL_WINDOW_ALLOW_HIGHDPI)) {
   350    if (!(window->sdlwindow->flags & SDL_WINDOW_ALLOW_HIGHDPI)) {
   350        return;
   351        return;
   351    }
   352    }
   352 
   353 
   356 
   357 
   357    if (FULLSCREEN_VISIBLE(window->sdlwindow) && window->sdlwindow->fullscreen_mode.driverdata) {
   358    if (FULLSCREEN_VISIBLE(window->sdlwindow) && window->sdlwindow->fullscreen_mode.driverdata) {
   358        new_factor = ((SDL_WaylandOutputData*)(wl_output_get_user_data(window->sdlwindow->fullscreen_mode.driverdata)))->scale_factor;
   359        new_factor = ((SDL_WaylandOutputData*)(wl_output_get_user_data(window->sdlwindow->fullscreen_mode.driverdata)))->scale_factor;
   359    }
   360    }
   360 
   361 
   361    for (int i = 0; i < window->num_outputs; i++) {
   362    for (i = 0; i < window->num_outputs; i++) {
   362        float factor = ((SDL_WaylandOutputData*)(wl_output_get_user_data(window->outputs[i])))->scale_factor;
   363        float factor = ((SDL_WaylandOutputData*)(wl_output_get_user_data(window->outputs[i])))->scale_factor;
   363        if (factor > new_factor) {
   364        if (factor > new_factor) {
   364            new_factor = factor;
   365            new_factor = factor;
   365        }
   366        }
   366    }
   367    }
   386 
   387 
   387 static void
   388 static void
   388 handle_surface_leave(void *data, struct wl_surface *surface,
   389 handle_surface_leave(void *data, struct wl_surface *surface,
   389         struct wl_output *output) {
   390         struct wl_output *output) {
   390     SDL_WindowData *window = data;
   391     SDL_WindowData *window = data;
       
   392     int i;
   391 
   393 
   392     if (window->num_outputs > 1) {
   394     if (window->num_outputs > 1) {
   393        struct wl_output **new_outputs = SDL_malloc((window->num_outputs - 1) * sizeof *window->outputs), **iter = new_outputs;
   395        struct wl_output **new_outputs = SDL_malloc((window->num_outputs - 1) * sizeof *window->outputs), **iter = new_outputs;
   394        for (int i=0; i < window->num_outputs; i++) {
   396        for (i=0; i < window->num_outputs; i++) {
   395            if (window->outputs[i] != output) {
   397            if (window->outputs[i] != output) {
   396                *iter = window->outputs[i];
   398                *iter = window->outputs[i];
   397                iter++;
   399                iter++;
   398            }
   400            }
   399        }
   401        }
   638     data->sdlwindow = window;
   640     data->sdlwindow = window;
   639 
   641 
   640     data->scale_factor = 1.0;
   642     data->scale_factor = 1.0;
   641 
   643 
   642     if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
   644     if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
   643         for (int i=0; i < SDL_GetVideoDevice()->num_displays; i++) {
   645         int i;
       
   646         for (i=0; i < SDL_GetVideoDevice()->num_displays; i++) {
   644             float scale = ((SDL_WaylandOutputData*)SDL_GetVideoDevice()->displays[i].driverdata)->scale_factor;
   647             float scale = ((SDL_WaylandOutputData*)SDL_GetVideoDevice()->displays[i].driverdata)->scale_factor;
   645             if (scale > data->scale_factor) {
   648             if (scale > data->scale_factor) {
   646                 data->scale_factor = scale;
   649                 data->scale_factor = scale;
   647             }
   650             }
   648         }
   651         }