Merge lp:~veger/lightdm/lp-1197999 into lp:lightdm

Proposed by Maarten Bezemer
Status: Merged
Approved by: Robert Ancell
Approved revision: 1867
Merged at revision: 1868
Proposed branch: lp:~veger/lightdm/lp-1197999
Merge into: lp:lightdm
Diff against target: 80 lines (+40/-9)
1 file modified
src/dm-tool.c (+40/-9)
To merge this branch: bzr merge lp:~veger/lightdm/lp-1197999
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Robert Ancell Approve
Review via email: mp+200481@code.launchpad.net

Description of the change

Hereby the modifications to add the --screen and --fullscreen options to the dm-tools command

To post a comment you must log in.
Revision history for this message
Robert Ancell (robert-ancell) wrote :

Hi Maarten,

Thanks for this patch.

Could you make some simple changes to it:

1. Instead of the if (n_options == 1), could you iterate over the remaining options so there's no code duplication? i.e.

for (i = 0; i < n_options; i++)
{
   if (strcmp (options[i], "--fullscreen") == 0)
       ...
   else if (strcmp (options[i], "--screen") == 0)
       ...
   else
       ... // show warning and exit
}

2. Could you use a string or enum to avoid the magic numbers for screen_mode

i.e. you could use:

if (dimensions == NULL)
   ... // Use Xephyr
else if (strcmp (dimensions, "fullscreen") == 0)
   ... // Use Xephyr -fullscreen
else
   ... // Use Xephyr -screen DIMENSIONS

review: Needs Fixing
lp:~veger/lightdm/lp-1197999 updated
1866. By Maarten Bezemer

As per review comments:
 * Remove code duplication when parsing the given options
 * Avoid magic numbers, use dimensions string to select the correct Xephyr command

------------- This line and the following will be ignored --------------

modified:
  src/dm-tool.c

Revision history for this message
Maarten Bezemer (veger) wrote :

Using a for loop to remove code duplications does not work (IMHO), as the amount of options needs to be checks (so garbage after the options is detected). But I think I managed to get it to a minimum this way.

Revision history for this message
Robert Ancell (robert-ancell) wrote :

Sorry, one last change - you don't need the debian/changelog entry - that will be added when it is released. Other than that, good to go, thanks!

lp:~veger/lightdm/lp-1197999 updated
1867. By Maarten Bezemer

Remove debian/changelog entry

Revision history for this message
Maarten Bezemer (veger) wrote :

I do not know whether you get alerted when a new commit is added. Hence this comment:

I removed the changes to debian/changelog

Revision history for this message
Robert Ancell (robert-ancell) wrote :

Great! Just waiting confirmation on contributor agreement before this can be merged.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/dm-tool.c'
2--- src/dm-tool.c 2013-11-07 07:54:55 +0000
3+++ src/dm-tool.c 2014-01-06 22:58:22 +0000
4@@ -132,14 +132,14 @@
5 " --session-bus Use session D-Bus\n"
6 "\n"
7 "Commands:\n"
8- " switch-to-greeter Switch to the greeter\n"
9- " switch-to-user USERNAME [SESSION] Switch to a user session\n"
10- " switch-to-guest [SESSION] Switch to a guest session\n"
11- " lock Lock the current seat\n"
12- " list-seats List the active seats\n"
13- " add-nested-seat Start a nested display\n"
14- " add-local-x-seat DISPLAY_NUMBER Add a local X seat\n"
15- " add-seat TYPE [NAME=VALUE...] Add a dynamic seat\n");
16+ " switch-to-greeter Switch to the greeter\n"
17+ " switch-to-user USERNAME [SESSION] Switch to a user session\n"
18+ " switch-to-guest [SESSION] Switch to a guest session\n"
19+ " lock Lock the current seat\n"
20+ " list-seats List the active seats\n"
21+ " add-nested-seat [--fullscreen|--screen DIMENSIONS] Start a nested display\n"
22+ " add-local-x-seat DISPLAY_NUMBER Add a local X seat\n"
23+ " add-seat TYPE [NAME=VALUE...] Add a dynamic seat\n");
24 return EXIT_SUCCESS;
25 }
26 else if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0)
27@@ -390,6 +390,7 @@
28 else if (strcmp (command, "add-nested-seat") == 0)
29 {
30 gchar *path, *xephyr_command, **xephyr_argv;
31+ gchar *dimensions = NULL;
32 GMainLoop *loop;
33
34 path = g_find_program_in_path ("Xephyr");
35@@ -399,6 +400,25 @@
36 return EXIT_FAILURE;
37 }
38
39+ if (n_options > 0)
40+ {
41+ /* Parse the given options */
42+ if (strcmp (options[0], "--fullscreen") == 0 && n_options == 1)
43+ {
44+ dimensions = "fullscreen";
45+ }
46+ else if (strcmp (options[0], "--screen") == 0 && n_options == 2)
47+ {
48+ dimensions = options[1];
49+ }
50+ else
51+ {
52+ g_printerr ("Usage add-nested-seat [--fullscreen|--screen DIMENSIONS]\n");
53+ usage ();
54+ return EXIT_FAILURE;
55+ }
56+ }
57+
58 /* Get a unique display number. It's racy, but the only reliable method to get one */
59 xephyr_display_number = 0;
60 while (TRUE)
61@@ -419,7 +439,18 @@
62 /* Wait for signal from Xephyr is ready */
63 signal (SIGUSR1, xephyr_signal_cb);
64
65- xephyr_command = g_strdup_printf ("Xephyr :%d", xephyr_display_number);
66+ if (dimensions == NULL)
67+ {
68+ xephyr_command = g_strdup_printf ("Xephyr :%d ", xephyr_display_number);
69+ }
70+ else if (strcmp (dimensions, "fullscreen") == 0)
71+ {
72+ xephyr_command = g_strdup_printf ("Xephyr :%d -fullscreen", xephyr_display_number);
73+ }
74+ else
75+ {
76+ xephyr_command = g_strdup_printf ("Xephyr :%d -screen %s", xephyr_display_number, dimensions);
77+ }
78 if (!g_shell_parse_argv (xephyr_command, NULL, &xephyr_argv, &error) ||
79 !g_spawn_async (NULL, xephyr_argv, NULL,
80 G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,

Subscribers

People subscribed via source and target branches