From 50cdff7ee2a1b448da24e85efae02237cff9b6b7 Mon Sep 17 00:00:00 2001 From: Matthew Allum Date: Tue, 9 Nov 2004 11:36:49 +0000 Subject: [PATCH] Xephyr improvements --- hw/kdrive/ephyr/ephyr.c | 1 - hw/kdrive/ephyr/ephyrinit.c | 4 +++ hw/kdrive/ephyr/hostx.c | 72 +++++++++++++++++++++++++++++++++---- hw/kdrive/ephyr/hostx.h | 6 ++++ 4 files changed, 75 insertions(+), 8 deletions(-) diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index e4f6e927a..5e87a2816 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -83,7 +83,6 @@ ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv) screen->height = height; } - if (screen->fb[0].depth && screen->fb[0].depth != hostx_get_depth()) { if (screen->fb[0].depth < hostx_get_depth() diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c index bf7b93ff9..45df309f0 100644 --- a/hw/kdrive/ephyr/ephyrinit.c +++ b/hw/kdrive/ephyr/ephyrinit.c @@ -87,6 +87,10 @@ ddxProcessArgument (int argc, char **argv, int i) hostx_use_host_cursor(); return 1; } + else if (argv[i][0] == ':') + { + hostx_set_display_name(argv[i]); + } return KdProcessArgument (argc, argv, i); } diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index 20eb74bc8..6ef7669a4 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -38,6 +38,7 @@ #include #include #include +#include #include /* @@ -48,6 +49,7 @@ struct EphyrHostXVars { + char *server_dpy_name; Display *dpy; int screen; Visual *visual; @@ -68,7 +70,8 @@ struct EphyrHostXVars XShmSegmentInfo shminfo; }; -static EphyrHostXVars HostX = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* memset? */ +/* memset ( missing> ) instead of below */ +static EphyrHostXVars HostX = { "?", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; static int HostXWantDamageDebug = 0; @@ -125,6 +128,24 @@ hostx_want_screen_size(int *width, int *height) return 0; } +void +hostx_set_display_name(char *name) +{ + HostX.server_dpy_name = strdup(name); +} + +void +hostx_set_win_title(char *extra_text) +{ + char buf[256]; + + snprintf(buf, 256, "Xephyr on %s %s", + HostX.server_dpy_name, + (extra_text != NULL) ? extra_text : ""); + + XStoreName(HostX.dpy, HostX.win, buf); +} + int hostx_want_host_cursor(void) { @@ -233,7 +254,7 @@ hostx_init(void) CWEventMask, &attr); - XStoreName(HostX.dpy, HostX.win, "Xephyr"); + hostx_set_win_title("( ctrl+shift grabs mouse and keyboard )"); } @@ -508,8 +529,8 @@ hostx_paint_rect(int sx, int sy, unsigned char r,g,b; unsigned long host_pixel; - for (x=sx; xtype = EPHYR_EV_KEY_RELEASE; - ev->data.key_up.scancode = xev.xkey.keycode; + if ((XKeycodeToKeysym(HostX.dpy,xev.xkey.keycode,0) == XK_Shift_L + || XKeycodeToKeysym(HostX.dpy,xev.xkey.keycode,0) == XK_Shift_R) + && (xev.xkey.state & ControlMask)) + { + if (grabbed) + { + XUngrabKeyboard (HostX.dpy, CurrentTime); + XUngrabPointer (HostX.dpy, CurrentTime); + grabbed = False; + hostx_set_win_title("( ctrl+shift grabs mouse and keyboard )"); + + } + else + { + if (XGrabKeyboard (HostX.dpy, HostX.win, True, + GrabModeAsync, + GrabModeAsync, + CurrentTime)) + break; + + if (XGrabPointer (HostX.dpy, HostX.win, True, + NoEventMask, + GrabModeAsync, + GrabModeAsync, + HostX.win, None, CurrentTime)) + break; + + grabbed = True; + hostx_set_win_title("( ctrl+shift releases mouse and keyboard )"); + + } + } + else + { + ev->type = EPHYR_EV_KEY_RELEASE; + ev->data.key_up.scancode = xev.xkey.keycode; + return 1; + } return 1; default: diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h index 2ef38c089..a27e4bea9 100644 --- a/hw/kdrive/ephyr/hostx.h +++ b/hw/kdrive/ephyr/hostx.h @@ -100,6 +100,12 @@ hostx_handle_signal(int signum); int hostx_init(void); +void +hostx_set_display_name(char *name); + +void +hostx_set_win_title(char *extra_text); + int hostx_get_depth (void);