Commit 6be28d83 authored by Guido Gunther's avatar Guido Gunther
Browse files

background: Scale by fractional output scale



Scale the background by logical scale instead of what we get
from xdg_output->scale. This allows the background to scale
with fractional scaling.

Closes: #338
Signed-off-by: Guido Gunther's avatarGuido Günther <guido.gunther@puri.sm>
parent ee2ff937
Pipeline #69479 passed with stages
in 48 minutes and 31 seconds
......@@ -44,7 +44,7 @@ create_background_for_monitor (PhoshBackgroundManager *self, PhoshMonitor *monit
background = g_object_ref_sink(PHOSH_BACKGROUND (phosh_background_new (
phosh_wayland_get_zwlr_layer_shell_v1(wl),
monitor->wl_output,
MAX(1, monitor->scale),
MAX(1.0, phosh_monitor_get_fractional_scale (monitor)),
monitor == self->primary_monitor)));
g_hash_table_insert (self->backgrounds,
g_object_ref (monitor),
......@@ -71,14 +71,16 @@ on_monitor_configured (PhoshBackgroundManager *self,
PhoshMonitor *monitor)
{
PhoshBackground *background;
float scale;
g_return_if_fail (PHOSH_IS_MONITOR (monitor));
g_debug ("Monitor %p (%s) configured", monitor, monitor->name);
scale = phosh_monitor_get_fractional_scale (monitor);
g_debug ("Monitor %p (%s) configured, scale %f", monitor, monitor->name, scale);
background = g_hash_table_lookup (self->backgrounds, monitor);
g_return_if_fail (background);
phosh_background_set_scale (background, monitor->scale);
phosh_background_set_scale (background, scale);
gtk_widget_show (GTK_WIDGET (background));
}
......
......@@ -69,7 +69,7 @@ struct _PhoshBackground
GdkRGBA color;
gboolean primary;
guint scale;
float scale;
GdkPixbuf *pixbuf;
GSettings *settings;
gboolean configured;
......@@ -96,7 +96,7 @@ phosh_background_set_property (GObject *object,
phosh_background_set_primary (self, g_value_get_boolean (value));
break;
case PROP_SCALE:
phosh_background_set_scale (self, g_value_get_uint (value));
phosh_background_set_scale (self, g_value_get_float (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -118,7 +118,7 @@ phosh_background_get_property (GObject *object,
g_value_set_boolean (value, self->primary);
break;
case PROP_SCALE:
g_value_set_uint (value, self->scale);
g_value_set_float (value, self->scale);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -271,7 +271,7 @@ background_update (PhoshBackground *self, GdkPixbuf *pixbuf, GDesktopBackgroundS
else
g_object_get (self, "configured-width", &width, "configured-height", &height, NULL);
g_debug ("Scaling %p to %dx%d, scale %d", self, width, height, self->scale);
g_debug ("Scaling %p to %dx%d, scale %f", self, width, height, self->scale);
self->pixbuf = image_background (pixbuf, width * self->scale, height * self->scale, style, &self->color);
/* force background redraw */
gtk_widget_queue_draw (GTK_WIDGET (self));
......@@ -585,16 +585,16 @@ phosh_background_class_init (PhoshBackgroundClass *klass)
G_PARAM_EXPLICIT_NOTIFY |
G_PARAM_CONSTRUCT);
props[PROP_SCALE] =
g_param_spec_uint ("scale",
"Scale",
"The output scale",
1,
G_MAXUINT,
1,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY |
G_PARAM_CONSTRUCT);
g_param_spec_float ("scale",
"Scale",
"The output scale",
1.0,
G_MAXFLOAT,
1.0,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY |
G_PARAM_CONSTRUCT);
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
}
......@@ -610,7 +610,7 @@ phosh_background_init (PhoshBackground *self)
GtkWidget *
phosh_background_new (gpointer layer_shell,
gpointer wl_output,
guint scale,
float scale,
gboolean primary)
{
return g_object_new (PHOSH_TYPE_BACKGROUND,
......@@ -644,9 +644,9 @@ phosh_background_set_primary (PhoshBackground *self, gboolean primary)
void
phosh_background_set_scale (PhoshBackground *self, guint scale)
phosh_background_set_scale (PhoshBackground *self, float scale)
{
if (self->scale == scale)
if ((int)(self->scale * 1000) == (int)(scale * 1000))
return;
self->scale = scale;
......
......@@ -18,7 +18,7 @@ G_DECLARE_FINAL_TYPE (PhoshBackground, phosh_background, PHOSH, BACKGROUND, Phos
GtkWidget *phosh_background_new (gpointer layer_shell,
gpointer wl_output,
guint scale,
float scale,
gboolean primary);
void phosh_background_set_primary (PhoshBackground *self, gboolean primary);
void phosh_background_set_scale (PhoshBackground *self, guint scale);
void phosh_background_set_scale (PhoshBackground *self, float scale);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment