diff options
author | Daniel Narvaez <dwnarvaez@gmail.com> | 2012-11-19 15:54:24 (GMT) |
---|---|---|
committer | Daniel Narvaez <dwnarvaez@gmail.com> | 2012-11-19 15:54:24 (GMT) |
commit | a3de3e6ad1aae1f7bb2c718eebd1d635e6717916 (patch) | |
tree | 2d6ac03fb0ff7ea01b7a137387da8a2f52a746cd /commands | |
parent | a96a6091c87492f56fe3f1169bf7608c2fa3d05c (diff) |
Run xephyr in a custom window
Xephyr doesn't work very well with multiple outputs. This should
allow us to customize our behavior in that case.
Diffstat (limited to 'commands')
-rwxr-xr-x | commands/helpers/xephyr-window.c | 58 | ||||
-rwxr-xr-x | commands/run | 16 |
2 files changed, 68 insertions, 6 deletions
diff --git a/commands/helpers/xephyr-window.c b/commands/helpers/xephyr-window.c new file mode 100755 index 0000000..b711f99 --- /dev/null +++ b/commands/helpers/xephyr-window.c @@ -0,0 +1,58 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <X11/Xlib.h> +#include <X11/Xatom.h> + +int main(int argc, char **argv) +{ + Display *display = XOpenDisplay(NULL); + Window window, root_window; + Atom atom; + int width = 100, height = 100; + + if (argc > 1) { + char *geometry = strdup(argv[1]); + char *delimiter = strchr(geometry, 'x'); + + if (delimiter == NULL) { + fprintf(stderr, "Cannot parse geometry\n"); + free(geometry); + exit(1); + } + + *delimiter = '\0'; + width = atoi(geometry); + height = atoi(delimiter + 1); + + free(geometry); + } + + root_window = RootWindow(display, 0); + + window = XCreateSimpleWindow(display, root_window, 0, 0, + width, height, 0, 0, 0); + + printf("%d\n", window); + fflush(stdout); + + if (argc < 2) { + atom = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", True); + XChangeProperty(display, window, + XInternAtom(display, "_NET_WM_STATE", True), + XA_ATOM, 32, PropModeReplace, + (unsigned char *)&atom, 1); + } + + XMapWindow(display, window); + + XFlush(display); + + while(1) { + sleep(60); + } + + XCloseDisplay(display); + + return(0); +} diff --git a/commands/run b/commands/run index 70f9611..875d2a7 100755 --- a/commands/run +++ b/commands/run @@ -32,13 +32,17 @@ else screen_dpi=`$helpersdir/get-screen-dpi` xephyr_options="-dpi $screen_dpi" - if [ -z $RUN_IN_WINDOW ]; then - xephyr_options="$xephyr_options -fullscreen" - fi + xidfile=`mktemp -t sugar-xephyr-xid-XXXXXX` + $helpersdir/xephyr-window $RESOLUTION > $xidfile & + xephyrwindowpid=$! - if [ ! -z $RESOLUTION ]; then - xephyr_options="$xephyr_options -screen $RESOLUTION" - fi + while [ ! -s $xidfile ] + do + sleep 1 + done + xephyr_options="$xephyr_options -parent `cat $xidfile`" xinit $helpersdir/xinitrc -- /usr/bin/Xephyr $display $xephyr_options + + kill $xephyrwindowpid fi |