forked from AuroraMiddleware/gtk
broadway: Add a setter for display scale
This is useful when using Broadway as a headless display server. Fixes: #3934
This commit is contained in:
parent
374225ae6a
commit
7745f67583
@ -48,6 +48,10 @@ void gdk_broadway_display_show_keyboard (GdkBroadwayDis
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_broadway_display_hide_keyboard (GdkBroadwayDisplay *display);
|
||||
|
||||
GDK_AVAILABLE_IN_4_4
|
||||
void gdk_broadway_display_set_surface_scale (GdkDisplay *display,
|
||||
int scale);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_BROADWAY_DISPLAY_H__ */
|
||||
|
@ -94,10 +94,12 @@ _gdk_broadway_display_size_changed (GdkDisplay *display,
|
||||
|
||||
if (msg->width == current_size.width &&
|
||||
msg->height == current_size.height &&
|
||||
msg->scale == broadway_display->scale_factor)
|
||||
(msg->scale == broadway_display->scale_factor ||
|
||||
broadway_display->fixed_scale))
|
||||
return;
|
||||
|
||||
broadway_display->scale_factor = msg->scale;
|
||||
if (!broadway_display->fixed_scale)
|
||||
broadway_display->scale_factor = msg->scale;
|
||||
|
||||
gdk_monitor_set_geometry (monitor, &(GdkRectangle) { 0, 0, msg->width, msg->height });
|
||||
gdk_monitor_set_scale_factor (monitor, msg->scale);
|
||||
@ -328,6 +330,37 @@ gdk_broadway_display_hide_keyboard (GdkBroadwayDisplay *display)
|
||||
_gdk_broadway_server_set_show_keyboard (display->server, FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_broadway_display_set_surface_scale:
|
||||
* @display: (type GdkBroadwayDisplay): the display
|
||||
* @scale: The new scale value, as an integer >= 1
|
||||
*
|
||||
* Forces a specific window scale for all windows on this display,
|
||||
* instead of using the default or user configured scale. This
|
||||
* is can be used to disable scaling support by setting @scale to
|
||||
* 1, or to programmatically set the window scale.
|
||||
*
|
||||
* Once the scale is set by this call it will not change in
|
||||
* response to later user configuration changes.
|
||||
*
|
||||
* Since: 4.4
|
||||
*/
|
||||
void
|
||||
gdk_broadway_display_set_surface_scale (GdkDisplay *display,
|
||||
int scale)
|
||||
{
|
||||
GdkBroadwayDisplay *self;
|
||||
|
||||
g_return_if_fail (GDK_IS_BROADWAY_DISPLAY (display));
|
||||
g_return_if_fail (scale > 0);
|
||||
|
||||
self = GDK_BROADWAY_DISPLAY (display);
|
||||
|
||||
self->scale_factor = scale;
|
||||
self->fixed_scale = TRUE;
|
||||
gdk_monitor_set_scale_factor (self->monitor, scale);
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
gdk_broadway_display_get_monitors (GdkDisplay *display)
|
||||
{
|
||||
|
@ -57,6 +57,7 @@ struct _GdkBroadwayDisplay
|
||||
GListStore *monitors;
|
||||
GdkMonitor *monitor;
|
||||
int scale_factor;
|
||||
gboolean fixed_scale;
|
||||
|
||||
GHashTable *texture_cache;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user