1#include <stdio.h> 2#include <X11/Xlib.h> 3#include <X11/Xlibint.h> 4#include <X11/Xproto.h> 5#include <X11/extensions/panoramiXproto.h> 6#include <string.h> 7#include <stdlib.h> 8 9#include "libvmwarectrl.h" 10 11int 12main (int argc, char **argv) 13{ 14 Display *dpy; 15 char *displayName = NULL; 16 int screen; 17 int major, minor; 18 19 dpy = XOpenDisplay(displayName); 20 if (!dpy) { 21 printf("Could not open default X Display\n"); 22 exit(EXIT_FAILURE); 23 } 24 screen = DefaultScreen(dpy); 25 26 if (VMwareCtrl_QueryVersion(dpy, &major, &minor)) { 27 printf("Got Extension version %d.%d\n", major, minor); 28 } else { 29 printf("VMWARE_CTRL Extension not found.\n"); 30 exit(EXIT_FAILURE); 31 } 32 33 if (argc >= 2) { 34 if (strcmp(argv[1], "setres") == 0) { 35 int x, y; 36 if (argc < 4) { 37 printf("Setres needs x and y too\n"); 38 exit(EXIT_FAILURE); 39 } 40 41 x = atoi(argv[2]); 42 y = atoi(argv[3]); 43 44 if (VMwareCtrl_SetRes(dpy, screen, x, y)) { 45 printf("Set Res was successful\n"); 46 } else { 47 printf("Set Res failed\n"); 48 } 49 } else if (strcmp(argv[1], "settopology") == 0) { 50 xXineramaScreenInfo extents[2]; 51 52 if (major == 0 && minor < 2) { 53 printf("VMWARE_CTRL version >= 0.2 is required\n"); 54 exit(EXIT_FAILURE); 55 } 56 57 printf("Requesting hard-coded topology\n"); 58 59 extents[0].x_org = 0; 60 extents[0].y_org = 0; 61 extents[0].width = 800; 62 extents[0].height = 600; 63 extents[1].x_org = 800; 64 extents[1].y_org = 0; 65 extents[1].width = 800; 66 extents[1].height = 600; 67 if (VMwareCtrl_SetTopology(dpy, screen, extents, 2)) { 68 printf("SetTopology was successful\n"); 69 } else { 70 printf("SetTopology failed\n"); 71 } 72 } 73 } 74 75 return EXIT_SUCCESS; 76} 77