Merge lp:~sylvain-pineau/checkbox/gsd-res-change into lp:checkbox

Proposed by Sylvain Pineau
Status: Work in progress
Proposed branch: lp:~sylvain-pineau/checkbox/gsd-res-change
Merge into: lp:checkbox
Diff against target: 117 lines (+83/-2)
4 files modified
providers/plainbox-provider-checkbox/requirements/deb-base.txt (+3/-0)
providers/plainbox-provider-checkbox/src/EXECUTABLES (+1/-0)
providers/plainbox-provider-checkbox/src/Makefile (+4/-2)
providers/plainbox-provider-checkbox/src/screen_resolution.c (+75/-0)
To merge this branch: bzr merge lp:~sylvain-pineau/checkbox/gsd-res-change
Reviewer Review Type Date Requested Status
Checkbox Developers Pending
Review via email: mp+276461@code.launchpad.net

Description of the change

-- WIP --

A new program to replace all calls to xrandr to perform screen resolution changes (on I+N systems).

New build dep for the checkbox provider are (so far):

 - libgtk-3-dev
 - unity-settings-daemon-dev
 - pkg-config

To post a comment you must log in.
4070. By Sylvain Pineau

providers:checkbox: Added a nex executable to perform screen resolution changes

The xrandr command does not always work with Intel+Nvidia systems.
This new program uses the same backend as System Settings
(unity-settings-daemon) to change the screen resolution.

Unmerged revisions

4070. By Sylvain Pineau

providers:checkbox: Added a nex executable to perform screen resolution changes

The xrandr command does not always work with Intel+Nvidia systems.
This new program uses the same backend as System Settings
(unity-settings-daemon) to change the screen resolution.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'providers/plainbox-provider-checkbox/requirements/deb-base.txt'
2--- providers/plainbox-provider-checkbox/requirements/deb-base.txt 1970-01-01 00:00:00 +0000
3+++ providers/plainbox-provider-checkbox/requirements/deb-base.txt 2015-11-02 23:14:35 +0000
4@@ -0,0 +1,3 @@
5+libgtk-3-dev
6+unity-settings-daemon-dev
7+pkg-config
8
9=== modified file 'providers/plainbox-provider-checkbox/src/EXECUTABLES'
10--- providers/plainbox-provider-checkbox/src/EXECUTABLES 2014-04-07 16:29:32 +0000
11+++ providers/plainbox-provider-checkbox/src/EXECUTABLES 2015-11-02 23:14:35 +0000
12@@ -1,2 +1,3 @@
13 clocktest
14 threaded_memtest
15+screen_resolution
16
17=== modified file 'providers/plainbox-provider-checkbox/src/Makefile'
18--- providers/plainbox-provider-checkbox/src/Makefile 2014-04-16 15:22:37 +0000
19+++ providers/plainbox-provider-checkbox/src/Makefile 2015-11-02 23:14:35 +0000
20@@ -1,13 +1,15 @@
21 .PHONY:
22-all: clocktest threaded_memtest
23+all: clocktest threaded_memtest screen_resolution
24
25 .PHONY: clean
26 clean:
27- rm -f clocktest threaded_memtest
28+ rm -f clocktest threaded_memtest screen_resolution
29
30 threaded_memtest: CFLAGS += -pthread
31 threaded_memtest: CFLAGS += -Wno-unused-but-set-variable
32 clocktest: CFLAGS += -D_POSIX_C_SOURCE=199309L
33 clocktest: LDLIBS += -lrt
34+screen_resolution: CFLAGS += $(shell pkg-config --cflags --libs gtk+-3.0 unity-settings-daemon)
35+screen_resolution: LDLIBS += $(shell pkg-config --libs gtk+-3.0) -lunity-settings-daemon
36
37 CFLAGS += -Wall
38
39=== added file 'providers/plainbox-provider-checkbox/src/screen_resolution.c'
40--- providers/plainbox-provider-checkbox/src/screen_resolution.c 1970-01-01 00:00:00 +0000
41+++ providers/plainbox-provider-checkbox/src/screen_resolution.c 2015-11-02 23:14:35 +0000
42@@ -0,0 +1,75 @@
43+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
44+ *
45+ * This file is part of Checkbox.
46+ *
47+ * Copyright 2015 Canonical Ltd.
48+ * Written by:
49+ * Sylvain Pineau <sylvain.pineau@canonical.com>
50+ *
51+ * Checkbox is free software: you can redistribute it and/or modify
52+ * it under the terms of the GNU General Public License version 3,
53+ * as published by the Free Software Foundation.
54+ *
55+ * Checkbox is distributed in the hope that it will be useful,
56+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
57+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58+ * GNU General Public License for more details.
59+ *
60+ * You should have received a copy of the GNU General Public License
61+ * along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
62+ */
63+
64+#include <gdk/gdkx.h>
65+#include <glib.h>
66+#include <gtk/gtk.h>
67+#include <libunity-settings-daemon/gsd-rr.h>
68+#include <libunity-settings-daemon/gsd-rr-config.h>
69+
70+static gint height = 0;
71+static gint width = 0;
72+static gint screen = 0;
73+static gint x = 0;
74+static gint y = 0;
75+
76+static GOptionEntry entries[] =
77+{
78+ { "height", 'h', 0, G_OPTION_ARG_INT, &height, "Set screen width to H", "H" },
79+ { "width", 'w', 0, G_OPTION_ARG_INT, &width, "Set screen width to W", "W" },
80+ { "x_position", 'x', 0, G_OPTION_ARG_INT, &x, "Set x position to X", "X" },
81+ { "y_position", 'y', 0, G_OPTION_ARG_INT, &y, "Set y position to Y", "Y" },
82+ { "screen", 's', 0, G_OPTION_ARG_INT, &screen, "Apply resolution to screen #N", "N" },
83+ { NULL }
84+};
85+
86+int main (int argc, char *argv[])
87+{
88+ GsdRROutputInfo **outputs;
89+ GsdRRScreen *rr_screen;
90+ GsdRRConfig *rr_config;
91+ GError *error = NULL;
92+ GOptionContext *context;
93+
94+ context = g_option_context_new ("- Change screen resolution");
95+ g_option_context_add_main_entries (context, entries, NULL);
96+ g_option_context_add_group (context, gtk_get_option_group (TRUE));
97+ if (!g_option_context_parse (context, &argc, &argv, &error))
98+ {
99+ g_print ("option parsing failed: %s\n", error->message);
100+ return 1;
101+ }
102+ gtk_init (&argc, &argv);
103+ rr_screen = gsd_rr_screen_new (gdk_screen_get_default (), NULL);
104+ if (!rr_screen)
105+ return 1;
106+ rr_config = gsd_rr_config_new_current (rr_screen, NULL);
107+ gsd_rr_config_ensure_primary (rr_config);
108+ outputs = gsd_rr_config_get_outputs (rr_config);
109+ gsd_rr_output_info_set_geometry (outputs[screen], x, y, height, width);
110+ if (!gsd_rr_config_apply_with_time(rr_config, rr_screen, 0, &error)) {
111+ g_warning ("failed to apply resolution %dx%d to %s: %s", height, width, gsd_rr_output_info_get_display_name(outputs[screen]), error->message);
112+ return 1;
113+ }
114+ g_object_unref (rr_config);
115+ g_object_unref (rr_screen);
116+ return 0;
117+}

Subscribers

People subscribed via source and target branches