|
@@ -423,6 +423,7 @@ static SDL_VideoDevice *Wayland_CreateDevice(void)
|
|
|
data->display = display;
|
|
|
data->input = input;
|
|
|
data->display_externally_owned = display_is_external;
|
|
|
+ data->scale_to_display_enabled = SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_SCALE_TO_DISPLAY, SDL_FALSE);
|
|
|
WAYLAND_wl_list_init(&data->output_list);
|
|
|
WAYLAND_wl_list_init(&data->output_order);
|
|
|
WAYLAND_wl_list_init(&external_window_list);
|
|
@@ -488,6 +489,7 @@ static SDL_VideoDevice *Wayland_CreateDevice(void)
|
|
|
device->SetWindowModalFor = Wayland_SetWindowModalFor;
|
|
|
device->SetWindowTitle = Wayland_SetWindowTitle;
|
|
|
device->GetWindowSizeInPixels = Wayland_GetWindowSizeInPixels;
|
|
|
+ device->GetDisplayForWindow = Wayland_GetDisplayForWindow;
|
|
|
device->DestroyWindow = Wayland_DestroyWindow;
|
|
|
device->SetWindowHitTest = Wayland_SetWindowHitTest;
|
|
|
device->FlashWindow = Wayland_FlashWindow;
|
|
@@ -519,7 +521,8 @@ static SDL_VideoDevice *Wayland_CreateDevice(void)
|
|
|
|
|
|
device->device_caps = VIDEO_DEVICE_CAPS_MODE_SWITCHING_EMULATED |
|
|
|
VIDEO_DEVICE_CAPS_HAS_POPUP_WINDOW_SUPPORT |
|
|
|
- VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS;
|
|
|
+ VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS |
|
|
|
+ VIDEO_DEVICE_CAPS_SENDS_DISPLAY_CHANGES;
|
|
|
|
|
|
return device;
|
|
|
}
|
|
@@ -831,9 +834,16 @@ static void display_handle_done(void *data,
|
|
|
SDL_zero(desktop_mode);
|
|
|
desktop_mode.format = SDL_PIXELFORMAT_XRGB8888;
|
|
|
|
|
|
- desktop_mode.w = driverdata->screen_width;
|
|
|
- desktop_mode.h = driverdata->screen_height;
|
|
|
- desktop_mode.pixel_density = driverdata->scale_factor;
|
|
|
+ if (!video->scale_to_display_enabled) {
|
|
|
+ desktop_mode.w = driverdata->screen_width;
|
|
|
+ desktop_mode.h = driverdata->screen_height;
|
|
|
+ desktop_mode.pixel_density = driverdata->scale_factor;
|
|
|
+ } else {
|
|
|
+ desktop_mode.w = native_mode.w;
|
|
|
+ desktop_mode.h = native_mode.h;
|
|
|
+ desktop_mode.pixel_density = 1.0f;
|
|
|
+ }
|
|
|
+
|
|
|
desktop_mode.refresh_rate = ((100 * driverdata->refresh) / 1000) / 100.0f; /* mHz to Hz */
|
|
|
|
|
|
if (driverdata->display > 0) {
|
|
@@ -842,6 +852,10 @@ static void display_handle_done(void *data,
|
|
|
dpy = &driverdata->placeholder;
|
|
|
}
|
|
|
|
|
|
+ if (video->scale_to_display_enabled) {
|
|
|
+ SDL_SetDisplayContentScale(dpy, driverdata->scale_factor);
|
|
|
+ }
|
|
|
+
|
|
|
/* Set the desktop display mode. */
|
|
|
SDL_SetDesktopDisplayMode(dpy, &desktop_mode);
|
|
|
|
|
@@ -1176,6 +1190,12 @@ int Wayland_VideoInit(SDL_VideoDevice *_this)
|
|
|
// First roundtrip to receive all registry objects.
|
|
|
WAYLAND_wl_display_roundtrip(data->display);
|
|
|
|
|
|
+ // Require viewports for display scaling.
|
|
|
+ if (data->scale_to_display_enabled && !data->viewporter) {
|
|
|
+ SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "wayland: Display scaling requires the missing 'wp_viewporter' protocol: disabling");
|
|
|
+ data->scale_to_display_enabled = SDL_FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
/* Now that we have all the protocols, load libdecor if applicable */
|
|
|
Wayland_LoadLibdecor(data, SDL_FALSE);
|
|
|
|
|
@@ -1203,6 +1223,7 @@ int Wayland_VideoInit(SDL_VideoDevice *_this)
|
|
|
|
|
|
static int Wayland_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect)
|
|
|
{
|
|
|
+ SDL_VideoData *viddata = _this->driverdata;
|
|
|
SDL_DisplayData *driverdata = display->driverdata;
|
|
|
rect->x = driverdata->x;
|
|
|
rect->y = driverdata->y;
|
|
@@ -1216,15 +1237,7 @@ static int Wayland_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *di
|
|
|
rect->w = display->fullscreen_window->current_fullscreen_mode.w;
|
|
|
rect->h = display->fullscreen_window->current_fullscreen_mode.h;
|
|
|
} else {
|
|
|
- /* If the focused window is on the requested display and requires display scaling,
|
|
|
- * return the physical dimensions in pixels.
|
|
|
- */
|
|
|
- SDL_Window *kb = SDL_GetKeyboardFocus();
|
|
|
- SDL_Window *m = SDL_GetMouseFocus();
|
|
|
- SDL_bool scale_output = (kb && kb->driverdata->scale_to_display && (kb->last_displayID == display->id)) ||
|
|
|
- (m && m->driverdata->scale_to_display && (m->last_displayID == display->id));
|
|
|
-
|
|
|
- if (!scale_output) {
|
|
|
+ if (!viddata->scale_to_display_enabled) {
|
|
|
rect->w = display->current_mode->w;
|
|
|
rect->h = display->current_mode->h;
|
|
|
} else if (driverdata->transform & WL_OUTPUT_TRANSFORM_90) {
|