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
=== modified file 'src/dm-tool.c'
--- src/dm-tool.c 2013-11-07 07:54:55 +0000
+++ src/dm-tool.c 2014-01-06 22:58:22 +0000
@@ -132,14 +132,14 @@
132 " --session-bus Use session D-Bus\n"132 " --session-bus Use session D-Bus\n"
133 "\n"133 "\n"
134 "Commands:\n"134 "Commands:\n"
135 " switch-to-greeter Switch to the greeter\n"135 " switch-to-greeter Switch to the greeter\n"
136 " switch-to-user USERNAME [SESSION] Switch to a user session\n"136 " switch-to-user USERNAME [SESSION] Switch to a user session\n"
137 " switch-to-guest [SESSION] Switch to a guest session\n"137 " switch-to-guest [SESSION] Switch to a guest session\n"
138 " lock Lock the current seat\n"138 " lock Lock the current seat\n"
139 " list-seats List the active seats\n"139 " list-seats List the active seats\n"
140 " add-nested-seat Start a nested display\n"140 " add-nested-seat [--fullscreen|--screen DIMENSIONS] Start a nested display\n"
141 " add-local-x-seat DISPLAY_NUMBER Add a local X seat\n"141 " add-local-x-seat DISPLAY_NUMBER Add a local X seat\n"
142 " add-seat TYPE [NAME=VALUE...] Add a dynamic seat\n");142 " add-seat TYPE [NAME=VALUE...] Add a dynamic seat\n");
143 return EXIT_SUCCESS;143 return EXIT_SUCCESS;
144 }144 }
145 else if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0)145 else if (strcmp (arg, "-v") == 0 || strcmp (arg, "--version") == 0)
@@ -390,6 +390,7 @@
390 else if (strcmp (command, "add-nested-seat") == 0)390 else if (strcmp (command, "add-nested-seat") == 0)
391 {391 {
392 gchar *path, *xephyr_command, **xephyr_argv;392 gchar *path, *xephyr_command, **xephyr_argv;
393 gchar *dimensions = NULL;
393 GMainLoop *loop;394 GMainLoop *loop;
394395
395 path = g_find_program_in_path ("Xephyr");396 path = g_find_program_in_path ("Xephyr");
@@ -399,6 +400,25 @@
399 return EXIT_FAILURE;400 return EXIT_FAILURE;
400 }401 }
401402
403 if (n_options > 0)
404 {
405 /* Parse the given options */
406 if (strcmp (options[0], "--fullscreen") == 0 && n_options == 1)
407 {
408 dimensions = "fullscreen";
409 }
410 else if (strcmp (options[0], "--screen") == 0 && n_options == 2)
411 {
412 dimensions = options[1];
413 }
414 else
415 {
416 g_printerr ("Usage add-nested-seat [--fullscreen|--screen DIMENSIONS]\n");
417 usage ();
418 return EXIT_FAILURE;
419 }
420 }
421
402 /* Get a unique display number. It's racy, but the only reliable method to get one */422 /* Get a unique display number. It's racy, but the only reliable method to get one */
403 xephyr_display_number = 0;423 xephyr_display_number = 0;
404 while (TRUE)424 while (TRUE)
@@ -419,7 +439,18 @@
419 /* Wait for signal from Xephyr is ready */439 /* Wait for signal from Xephyr is ready */
420 signal (SIGUSR1, xephyr_signal_cb);440 signal (SIGUSR1, xephyr_signal_cb);
421441
422 xephyr_command = g_strdup_printf ("Xephyr :%d", xephyr_display_number);442 if (dimensions == NULL)
443 {
444 xephyr_command = g_strdup_printf ("Xephyr :%d ", xephyr_display_number);
445 }
446 else if (strcmp (dimensions, "fullscreen") == 0)
447 {
448 xephyr_command = g_strdup_printf ("Xephyr :%d -fullscreen", xephyr_display_number);
449 }
450 else
451 {
452 xephyr_command = g_strdup_printf ("Xephyr :%d -screen %s", xephyr_display_number, dimensions);
453 }
423 if (!g_shell_parse_argv (xephyr_command, NULL, &xephyr_argv, &error) ||454 if (!g_shell_parse_argv (xephyr_command, NULL, &xephyr_argv, &error) ||
424 !g_spawn_async (NULL, xephyr_argv, NULL,455 !g_spawn_async (NULL, xephyr_argv, NULL,
425 G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,456 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