Commit ac6d1034 authored by Guido Gunther's avatar Guido Gunther

Merge branch 'use-current-mode' into 'master'

Use current mode

See merge request Librem5/phosh!95
parents 4e539f70 77e7dd67
......@@ -406,10 +406,10 @@ phosh_monitor_manager_handle_get_current_state (
G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&mode_properties_builder, "{sv}",
"is-current",
g_variant_new_boolean (TRUE));
g_variant_new_boolean (k == monitor->current_mode));
g_variant_builder_add (&mode_properties_builder, "{sv}",
"is-preferred",
g_variant_new_boolean (i == 0));
g_variant_new_boolean (k == monitor->preferred_mode));
mode_name = g_strdup_printf ("%dx%d@%.0f", mode->width, mode->height,
mode->refresh / 1000.0);
......
......@@ -100,8 +100,11 @@ output_handle_mode (void *data,
if (height > self->height)
self->height = height;
if ((flags & WL_OUTPUT_MODE_CURRENT) == 0)
if ((flags & WL_OUTPUT_MODE_CURRENT) == 1)
self->current_mode = self->modes->len - 1;
if ((flags & WL_OUTPUT_MODE_PREFERRED) == 1)
self->preferred_mode = self->modes->len - 1;
}
......@@ -211,3 +214,11 @@ phosh_monitor_new_from_wl_output (gpointer wl_output)
{
return g_object_new (PHOSH_TYPE_MONITOR, "wl-output", wl_output, NULL);
}
PhoshMonitorMode *
phosh_monitor_get_current_mode (PhoshMonitor *self)
{
g_return_val_if_fail (PHOSH_IS_MONITOR (self), NULL);
return &g_array_index (self->modes, PhoshMonitorMode, self->current_mode);
}
......@@ -34,10 +34,12 @@ struct _PhoshMonitor {
GArray *modes;
guint current_mode;
guint preferred_mode;
gboolean done;
};
G_DECLARE_FINAL_TYPE (PhoshMonitor, phosh_monitor, PHOSH, MONITOR, GObject)
PhoshMonitor * phosh_monitor_new_from_wl_output (gpointer wl_output);
PhoshMonitor * phosh_monitor_new_from_wl_output (gpointer wl_output);
PhoshMonitorMode * phosh_monitor_get_current_mode (PhoshMonitor *monitor);
......@@ -600,7 +600,8 @@ phosh_shell_get_monitor_manager (PhoshShell *self)
void
phosh_shell_get_usable_area (PhoshShell *self, gint *x, gint *y, gint *width, gint *height)
{
PhoshMonitor *monitor = NULL;
PhoshMonitor *monitor;
PhoshMonitorMode *mode;
PhoshShellPrivate *priv;
gint w, h;
gint scale;
......@@ -610,14 +611,15 @@ phosh_shell_get_usable_area (PhoshShell *self, gint *x, gint *y, gint *width, gi
monitor = phosh_shell_get_primary_monitor (self);
g_return_if_fail(monitor);
mode = phosh_monitor_get_current_mode (monitor);
scale = monitor->scale ? monitor->scale : 1;
if (priv->rotation) {
w = monitor->height / scale;
h = monitor->width / scale - PHOSH_PANEL_HEIGHT - PHOSH_HOME_HEIGHT;
w = mode->height / scale;
h = mode->width / scale - PHOSH_PANEL_HEIGHT - PHOSH_HOME_HEIGHT;
} else {
w = monitor->width / scale;
h = monitor->height / scale - PHOSH_PANEL_HEIGHT - PHOSH_HOME_HEIGHT;
w = mode->width / scale;
h = mode->height / scale - PHOSH_PANEL_HEIGHT - PHOSH_HOME_HEIGHT;
}
if (x)
......
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