xfreerdp: add /monitor-list option
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Sun, 28 Apr 2013 21:10:43 +0000 (17:10 -0400)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Sun, 28 Apr 2013 21:10:43 +0000 (17:10 -0400)
client/X11/xf_interface.c
client/X11/xf_monitor.c
client/X11/xf_monitor.h
client/common/cmdline.c
include/freerdp/settings.h

index 728f3f7..516b4bf 100644 (file)
@@ -1560,6 +1560,11 @@ xfInfo* freerdp_client_new(int argc, char** argv)
        settings->OrderSupport[NEG_ELLIPSE_SC_INDEX] = FALSE;
        settings->OrderSupport[NEG_ELLIPSE_CB_INDEX] = FALSE;
 
+       if (settings->ListMonitors)
+       {
+               xf_list_monitors(xfi);
+       }
+
        return xfi;
 }
 
index 6ce66da..1d978bc 100644 (file)
 
 /* See MSDN Section on Multiple Display Monitors: http://msdn.microsoft.com/en-us/library/dd145071 */
 
+int xf_list_monitors(xfInfo* xfi)
+{
+#ifdef WITH_XINERAMA
+       Display* display;
+       int i, nmonitors = 0;
+       int ignored, ignored2;
+       XineramaScreenInfo* screen = NULL;
+
+       display = XOpenDisplay(NULL);
+
+       if (XineramaQueryExtension(display, &ignored, &ignored2))
+       {
+               if (XineramaIsActive(display))
+               {
+                       screen = XineramaQueryScreens(display, &nmonitors);
+
+                       for (i = 0; i < nmonitors; i++)
+                       {
+                               printf("      %s [%d] %dx%d\t+%d+%d\n",
+                                      (i == 0) ? "*" : " ", i,
+                                      screen[i].width, screen[i].height,
+                                      screen[i].x_org, screen[i].y_org);
+                       }
+
+                       XFree(screen);
+               }
+       }
+
+       XCloseDisplay(display);
+#else
+       Screen* screen;
+       Display* display;
+
+       display = XOpenDisplay(NULL);
+
+       screen = ScreenOfDisplay(display, DefaultScreen(display));
+       printf("      * [0] %dx%d\t+%d+%d\n", WidthOfScreen(screen), HeightOfScreen(screen), 0, 0);
+
+       XCloseDisplay(display);
+#endif
+
+       return 0;
+}
+
 BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings)
 {
        int i;
index e0fa018..4f3b1de 100644 (file)
@@ -43,6 +43,7 @@ typedef struct _VIRTUAL_SCREEN VIRTUAL_SCREEN;
 #include "xf_interface.h"
 #include "xfreerdp.h"
 
+int xf_list_monitors(xfInfo* xfi);
 BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings);
 
 #endif /* __XF_MONITOR_H */
index 5451d31..c4dd9df 100644 (file)
@@ -48,8 +48,9 @@ COMMAND_LINE_ARGUMENT_A args[] =
        { "kbd-subtype", COMMAND_LINE_VALUE_REQUIRED, "<subtype id>", NULL, NULL, -1, NULL, "Keyboard subtype" },
        { "kbd-fn-key", COMMAND_LINE_VALUE_REQUIRED, "<function key count>", NULL, NULL, -1, NULL, "Keyboard function key count" },
        { "admin", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, "console", "Admin (or console) session" },
-       { "multimon", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, NULL, "Multi-monitor" },
-       { "workarea", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "Work area" },
+       { "multimon", COMMAND_LINE_VALUE_OPTIONAL, NULL, NULL, NULL, -1, NULL, "Use multiple monitors" },
+       { "workarea", COMMAND_LINE_VALUE_FLAG, NULL, NULL, NULL, -1, NULL, "Use available work area" },
+       { "monitor-list", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT, NULL, NULL, NULL, -1, NULL, "List detected monitors" },
        { "t", COMMAND_LINE_VALUE_REQUIRED, "<title>", NULL, NULL, -1, "title", "Window title" },
        { "decorations", COMMAND_LINE_VALUE_BOOL, NULL, NULL, BoolValueTrue, -1, NULL, "Window decorations" },
        { "smart-sizing", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "Scale remote desktop to window size" },
@@ -985,6 +986,13 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin
                        printf("\n");
                }
 
+               arg = CommandLineFindArgumentA(args, "monitor-list");
+
+               if (arg->Flags & COMMAND_LINE_VALUE_PRESENT)
+               {
+                       settings->ListMonitors = TRUE;
+               }
+
                return COMMAND_LINE_STATUS_PRINT;
        }
 
@@ -1084,6 +1092,10 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin
                {
                        settings->Workarea = TRUE;
                }
+               CommandLineSwitchCase(arg, "monitor-list")
+               {
+                       settings->ListMonitors = TRUE;
+               }
                CommandLineSwitchCase(arg, "t")
                {
                        settings->WindowTitle = _strdup(arg->Value);
index 8b71045..cd31e59 100644 (file)
@@ -811,7 +811,8 @@ struct rdp_settings
        ALIGN64 BOOL ForceMultimon; /* 389 */
        ALIGN64 UINT32 DesktopPosX; /* 390 */
        ALIGN64 UINT32 DesktopPosY; /* 391 */
-       UINT64 padding0448[448 - 392]; /* 392 */
+       ALIGN64 BOOL ListMonitors; /* 392 */
+       UINT64 padding0448[448 - 393]; /* 393 */
 
        /* Client Message Channel Data */
        UINT64 padding0512[512 - 448]; /* 448 */