diff options
author | Peter Hutterer <whot@potoroo.wearablelab.ml.unisa.edu.au> | 2008-04-07 07:56:41 +0930 |
---|---|---|
committer | Peter Hutterer <whot@potoroo.wearablelab.ml.unisa.edu.au> | 2008-04-07 07:56:41 +0930 |
commit | fd06e8f8c1d82a9d91931e8532bee0fd9c9ca9ab (patch) | |
tree | fda1a9d90f4a3e99af9da656939ff8c112cfeb33 /hw/kdrive | |
parent | b46a00918691cbd5ca80b6d3acae7614f93e073b (diff) | |
parent | 6c0cfe3d43b177c4cfaf7e228f32c655f9a98459 (diff) |
Merge branch 'master' into dcdc_rework
Conflicts:
Xext/xevie.c
dix/dispatch.c
Diffstat (limited to 'hw/kdrive')
-rw-r--r-- | hw/kdrive/ephyr/Makefile.am | 1 | ||||
-rw-r--r-- | hw/kdrive/ephyr/XF86dri.c | 37 | ||||
-rw-r--r-- | hw/kdrive/ephyr/ephyr.c | 34 | ||||
-rw-r--r-- | hw/kdrive/ephyr/ephyr.h | 1 | ||||
-rw-r--r-- | hw/kdrive/ephyr/ephyrinit.c | 19 | ||||
-rw-r--r-- | hw/kdrive/ephyr/hostx.c | 31 | ||||
-rw-r--r-- | hw/kdrive/ephyr/hostx.h | 4 |
7 files changed, 112 insertions, 15 deletions
diff --git a/hw/kdrive/ephyr/Makefile.am b/hw/kdrive/ephyr/Makefile.am index d025c201c..81d3d69ea 100644 --- a/hw/kdrive/ephyr/Makefile.am +++ b/hw/kdrive/ephyr/Makefile.am @@ -35,6 +35,7 @@ if XEPHYR_HAS_DRI libxephyr_hostdri_a_SOURCES= \ ephyrdriext.c \ +ephyrdriext.h \ ephyrdri.c \ ephyrdri.h \ XF86dri.c \ diff --git a/hw/kdrive/ephyr/XF86dri.c b/hw/kdrive/ephyr/XF86dri.c index 506d7bed8..e656ff5a0 100644 --- a/hw/kdrive/ephyr/XF86dri.c +++ b/hw/kdrive/ephyr/XF86dri.c @@ -385,9 +385,8 @@ Bool XF86DRICreateContext(dpy, screen, visual, context, hHWContext) context, hHWContext ); } -GLboolean XF86DRIDestroyContext( __DRInativeDisplay * ndpy, int screen, __DRIid context) +GLboolean XF86DRIDestroyContext( Display *dpy, int screen, XID context) { - Display * const dpy = (Display *) ndpy; XExtDisplayInfo *info = find_display (dpy); xXF86DRIDestroyContextReq *req; @@ -407,10 +406,9 @@ GLboolean XF86DRIDestroyContext( __DRInativeDisplay * ndpy, int screen, __DRIid } GLboolean -XF86DRICreateDrawable (__DRInativeDisplay * ndpy, int screen, - __DRIid drawable, drm_drawable_t * hHWDrawable) +XF86DRICreateDrawable (Display *dpy, int screen, + XID drawable, drm_drawable_t * hHWDrawable) { - Display * const dpy = (Display *) ndpy; XExtDisplayInfo *info = find_display (dpy); xXF86DRICreateDrawableReply rep; xXF86DRICreateDrawableReq *req; @@ -437,16 +435,36 @@ XF86DRICreateDrawable (__DRInativeDisplay * ndpy, int screen, return True; } -GLboolean XF86DRIDestroyDrawable( __DRInativeDisplay * ndpy, int screen, - __DRIid drawable ) +static int noopErrorHandler(Display *dpy, XErrorEvent *xerr) +{ + return 0; +} + +GLboolean XF86DRIDestroyDrawable( Display *dpy, int screen, + XID drawable ) { - Display * const dpy = (Display *) ndpy; XExtDisplayInfo *info = find_display (dpy); xXF86DRIDestroyDrawableReq *req; + int (*oldXErrorHandler)(Display *, XErrorEvent *); TRACE("DestroyDrawable..."); XF86DRICheckExtension (dpy, info, False); + /* This is called from the DRI driver, which used call it like this + * + * if (windowExists(drawable)) + * destroyDrawable(drawable); + * + * which is a textbook race condition - the window may disappear + * from the server between checking for its existance and + * destroying it. Instead we change the semantics of + * __DRIinterfaceMethodsRec::destroyDrawable() to succeed even if + * the windows is gone, by wrapping the destroy call in an error + * handler. */ + + XSync(dpy, GL_FALSE); + oldXErrorHandler = XSetErrorHandler(noopErrorHandler); + LockDisplay(dpy); GetReq(XF86DRIDestroyDrawable, req); req->reqType = info->codes->major_opcode; @@ -455,6 +473,9 @@ GLboolean XF86DRIDestroyDrawable( __DRInativeDisplay * ndpy, int screen, req->drawable = drawable; UnlockDisplay(dpy); SyncHandle(); + + XSetErrorHandler(oldXErrorHandler); + TRACE("DestroyDrawable... return True"); return True; } diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c index e892a9b0f..9f45fdb72 100644 --- a/hw/kdrive/ephyr/ephyr.c +++ b/hw/kdrive/ephyr/ephyr.c @@ -891,9 +891,12 @@ ephyrPoll(void) continue; } { - if (ephyrCurScreen != ev.data.mouse_motion.screen) + if (ev.data.mouse_motion.screen >=0 + && (ephyrCurScreen != ev.data.mouse_motion.screen)) { - EPHYR_LOG ("warping mouse cursor:%d\n", ephyrCurScreen) ; + EPHYR_LOG ("warping mouse cursor. " + "cur_screen%d, motion_screen:%d\n", + ephyrCurScreen, ev.data.mouse_motion.screen) ; if (ev.data.mouse_motion.screen >= 0) { ephyrWarpCursor @@ -904,11 +907,30 @@ ephyrPoll(void) } else { + int x=0, y=0; +#ifdef XEPHYR_DRI + EphyrWindowPair *pair = NULL; +#endif EPHYR_LOG ("enqueuing mouse motion:%d\n", ephyrCurScreen) ; - KdEnqueuePointerEvent(ephyrMouse, mouseState, - ev.data.mouse_motion.x, - ev.data.mouse_motion.y, - 0); + x = ev.data.mouse_motion.x; + y = ev.data.mouse_motion.y; + EPHYR_LOG ("initial (x,y):(%d,%d)\n", x, y) ; +#ifdef XEPHYR_DRI + EPHYR_LOG ("is this window peered by a gl drawable ?\n") ; + if (findWindowPairFromRemote (ev.data.mouse_motion.window, + &pair)) + { + EPHYR_LOG ("yes, it is peered\n") ; + x += pair->local->drawable.x; + y += pair->local->drawable.y; + } + else + { + EPHYR_LOG ("no, it is not peered\n") ; + } + EPHYR_LOG ("final (x,y):(%d,%d)\n", x, y) ; +#endif + KdEnqueuePointerEvent(ephyrMouse, mouseState, x, y, 0); } } break; diff --git a/hw/kdrive/ephyr/ephyr.h b/hw/kdrive/ephyr/ephyr.h index 8ed7e23dd..5d58a216c 100644 --- a/hw/kdrive/ephyr/ephyr.h +++ b/hw/kdrive/ephyr/ephyr.h @@ -28,6 +28,7 @@ #include <stdio.h> #include <unistd.h> #include <signal.h> +#include <libgen.h> #include "os.h" /* for OsSignal() */ #include "kdrive.h" diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c index 0d01fb425..d415fe75f 100644 --- a/hw/kdrive/ephyr/ephyrinit.c +++ b/hw/kdrive/ephyr/ephyrinit.c @@ -109,6 +109,7 @@ ddxUseMsg (void) ErrorF("-nodri do not use DRI\n"); #endif ErrorF("-noxv do not use XV\n"); + ErrorF("-name [name] define the name in the WM_CLASS property\n"); ErrorF("\n"); exit(1); @@ -148,6 +149,11 @@ ddxProcessArgument (int argc, char **argv, int i) { EPHYR_DBG("mark argv[%d]='%s'", i, argv[i] ); + if (i == 1) + { + hostx_use_resname(basename(argv[0]), 0); + } + if (!strcmp (argv[i], "-parent")) { if(i+1 < argc) @@ -223,6 +229,19 @@ ddxProcessArgument (int argc, char **argv, int i) EPHYR_LOG ("no XVideo enabled\n") ; return 1 ; } + else if (!strcmp (argv[i], "-name")) + { + if (i+1 < argc && argv[i+1][0] != '-') + { + hostx_use_resname(argv[i+1], 1); + return 2; + } + else + { + UseMsg(); + return 0; + } + } else if (argv[i][0] == ':') { hostx_set_display_name(argv[i]); diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c index ae1bb4bf9..1a71d0641 100644 --- a/hw/kdrive/ephyr/hostx.c +++ b/hw/kdrive/ephyr/hostx.c @@ -107,6 +107,9 @@ extern EphyrKeySyms ephyrKeySyms; extern int monitorResolution; +char *ephyrResName = NULL; +int ephyrResNameFromCmd = 0; + static void hostx_set_fullscreen_hint(void); @@ -296,6 +299,13 @@ hostx_handle_signal (int signum) HostXWantDamageDebug); } +void +hostx_use_resname (char *name, int fromcmd) +{ + ephyrResName = name; + ephyrResNameFromCmd = fromcmd; +} + int hostx_init (void) { @@ -304,6 +314,8 @@ hostx_init (void) Pixmap cursor_pxm; XColor col; int index; + char *tmpstr; + XClassHint *class_hint; attr.event_mask = ButtonPressMask @@ -327,6 +339,8 @@ hostx_init (void) HostX.depth = DefaultDepth(HostX.dpy, HostX.screen); HostX.visual = DefaultVisual(HostX.dpy, HostX.screen); + class_hint = XAllocClassHint(); + for (index = 0 ; index < HostX.n_screens ; index++) { struct EphyrHostScreen *host_screen = &HostX.screens[index]; @@ -389,9 +403,23 @@ hostx_init (void) hostx_set_fullscreen_hint(); } + + if (class_hint) + { + tmpstr = getenv("RESOURCE_NAME"); + if (tmpstr && (!ephyrResNameFromCmd)) + ephyrResName = tmpstr; + class_hint->res_name = ephyrResName; + class_hint->res_class = "Xephyr"; + XSetClassHint(hostx_get_display(), host_screen->win, class_hint); + + } + } } + if (class_hint) + XFree(class_hint); XParseColor (HostX.dpy, DefaultColormap (HostX.dpy,HostX.screen), "red", &col); @@ -914,8 +942,9 @@ hostx_get_event(EphyrHostXEvent *ev) host_screen_from_window (xev.xmotion.window); ev->type = EPHYR_EV_MOUSE_MOTION; - ev->data.mouse_motion.x = xev.xmotion.x; + ev->data.mouse_motion.x = xev.xmotion.x; ev->data.mouse_motion.y = xev.xmotion.y; + ev->data.mouse_motion.window = xev.xmotion.window; ev->data.mouse_motion.screen = (host_screen ? host_screen->mynum : -1); } return 1; diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h index f72cfe700..47ba61b5b 100644 --- a/hw/kdrive/ephyr/hostx.h +++ b/hw/kdrive/ephyr/hostx.h @@ -70,6 +70,7 @@ struct EphyrHostXEvent int x; int y; int screen; + int window; } mouse_motion; struct mouse_down { @@ -144,6 +145,9 @@ hostx_want_preexisting_window(EphyrScreenInfo screen); void hostx_use_preexisting_window(unsigned long win_id); +void +hostx_use_resname (char *name, int fromcmd); + void hostx_handle_signal(int signum); |