summaryrefslogtreecommitdiff
path: root/hw/kdrive
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2008-03-04 18:11:10 +1030
committerPeter Hutterer <peter@cs.unisa.edu.au>2008-03-04 18:11:10 +1030
commit4f2cd0ed96d3b10c78774c721c2ffbfb0556dddd (patch)
tree9f477ddd4af2162152057bded1426102b475e67c /hw/kdrive
parent23ae68a4c74a2ec90b4130c37b0d0aec3f4082ce (diff)
parent453661a9e193a511cf5e54e6d330454163817316 (diff)
Merge branch 'master' into mpx
This merge reverts Magnus' device coorindate scaling changes. MPX core event generation is very different, so we can't scale in GetPointerEvents. Conflicts: Xi/opendev.c dix/devices.c dix/dixfonts.c dix/getevents.c dix/resource.c dix/window.c hw/xfree86/common/xf86Xinput.c mi/mipointer.c xkb/ddxBeep.c xkb/ddxCtrls.c xkb/ddxKeyClick.c xkb/ddxList.c xkb/ddxLoad.c xkb/xkb.c xkb/xkbAccessX.c xkb/xkbEvents.c xkb/xkbInit.c xkb/xkbPrKeyEv.c xkb/xkbUtils.c
Diffstat (limited to 'hw/kdrive')
-rw-r--r--hw/kdrive/ephyr/XF86dri.c6
-rw-r--r--hw/kdrive/ephyr/ephyr.c55
-rw-r--r--hw/kdrive/ephyr/ephyrdriext.c24
-rw-r--r--hw/kdrive/ephyr/ephyrdriext.h10
-rw-r--r--hw/kdrive/ephyr/ephyrglxext.c14
-rw-r--r--hw/kdrive/ephyr/ephyrhostglx.c9
-rw-r--r--hw/kdrive/ephyr/hostx.c54
-rw-r--r--hw/kdrive/ephyr/hostx.h7
-rw-r--r--hw/kdrive/linux/linux.c2
-rw-r--r--hw/kdrive/src/kaa.c12
-rw-r--r--hw/kdrive/src/kmap.c8
-rw-r--r--hw/kdrive/vesa/vm86.c2
12 files changed, 162 insertions, 41 deletions
diff --git a/hw/kdrive/ephyr/XF86dri.c b/hw/kdrive/ephyr/XF86dri.c
index c11da0634..506d7bed8 100644
--- a/hw/kdrive/ephyr/XF86dri.c
+++ b/hw/kdrive/ephyr/XF86dri.c
@@ -385,7 +385,7 @@ Bool XF86DRICreateContext(dpy, screen, visual, context, hHWContext)
context, hHWContext );
}
-Bool XF86DRIDestroyContext( __DRInativeDisplay * ndpy, int screen, __DRIid context)
+GLboolean XF86DRIDestroyContext( __DRInativeDisplay * ndpy, int screen, __DRIid context)
{
Display * const dpy = (Display *) ndpy;
XExtDisplayInfo *info = find_display (dpy);
@@ -406,7 +406,7 @@ Bool XF86DRIDestroyContext( __DRInativeDisplay * ndpy, int screen, __DRIid conte
return True;
}
-Bool
+GLboolean
XF86DRICreateDrawable (__DRInativeDisplay * ndpy, int screen,
__DRIid drawable, drm_drawable_t * hHWDrawable)
{
@@ -437,7 +437,7 @@ XF86DRICreateDrawable (__DRInativeDisplay * ndpy, int screen,
return True;
}
-Bool XF86DRIDestroyDrawable( __DRInativeDisplay * ndpy, int screen,
+GLboolean XF86DRIDestroyDrawable( __DRInativeDisplay * ndpy, int screen,
__DRIid drawable )
{
Display * const dpy = (Display *) ndpy;
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 90aadf0f2..e892a9b0f 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -841,6 +841,39 @@ miPointerScreenFuncRec ephyrPointerScreenFuncs =
ephyrWarpCursor
};
+#ifdef XEPHYR_DRI
+/**
+ * find if the remote window denoted by a_remote
+ * is paired with an internal Window within the Xephyr server.
+ * If the remove window is paired with an internal window, send an
+ * expose event to the client insterested in the internal window expose event.
+ *
+ * Pairing happens when a drawable inside Xephyr is associated with
+ * a GL surface in a DRI environment.
+ * Look at the function ProcXF86DRICreateDrawable in ephyrdriext.c to
+ * know a paired window is created.
+ *
+ * This is useful to make GL drawables (only windows for now) handle
+ * expose events and send those events to clients.
+ */
+static void
+ephyrExposePairedWindow (int a_remote)
+{
+ EphyrWindowPair *pair = NULL;
+ RegionRec reg;
+ ScreenPtr screen;
+
+ if (!findWindowPairFromRemote (a_remote, &pair)) {
+ EPHYR_LOG ("did not find a pair for this window\n");
+ return;
+ }
+ screen = pair->local->drawable.pScreen;
+ REGION_NULL (screen, &reg);
+ REGION_COPY (screen, &reg, &pair->local->clipList);
+ screen->WindowExposures (pair->local, &reg, NullRegion);
+ REGION_UNINIT (screen, &reg);
+}
+#endif /*XEPHYR_DRI*/
void
ephyrPoll(void)
@@ -861,9 +894,13 @@ ephyrPoll(void)
if (ephyrCurScreen != ev.data.mouse_motion.screen)
{
EPHYR_LOG ("warping mouse cursor:%d\n", ephyrCurScreen) ;
- ephyrWarpCursor(screenInfo.screens[ev.data.mouse_motion.screen],
- ev.data.mouse_motion.x,
- ev.data.mouse_motion.y );
+ if (ev.data.mouse_motion.screen >= 0)
+ {
+ ephyrWarpCursor
+ (screenInfo.screens[ev.data.mouse_motion.screen],
+ ev.data.mouse_motion.x,
+ ev.data.mouse_motion.y );
+ }
}
else
{
@@ -913,6 +950,18 @@ ephyrPoll(void)
KdEnqueueKeyboardEvent (ephyrKbd, ev.data.key_up.scancode, TRUE);
break;
+#ifdef XEPHYR_DRI
+ case EPHYR_EV_EXPOSE:
+ /*
+ * We only receive expose events when the expose event have
+ * be generated for a drawable that is a host X window managed
+ * by Xephyr. Host X windows managed by Xephyr exists for instance
+ * when Xephyr is asked to create a GL drawable in a DRI environment.
+ */
+ ephyrExposePairedWindow (ev.data.expose.window);
+ break;
+#endif /*XEPHYR_DRI*/
+
default:
break;
}
diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c
index 1b9dce5c8..fafe56d1f 100644
--- a/hw/kdrive/ephyr/ephyrdriext.c
+++ b/hw/kdrive/ephyr/ephyrdriext.c
@@ -59,10 +59,6 @@
#define _HAVE_XALLOC_DECLS
#include "ephyrlog.h"
-typedef struct {
- WindowPtr local ;
- int remote ;
-} EphyrWindowPair;
typedef struct {
int foo;
@@ -950,6 +946,26 @@ findWindowPairFromLocal (WindowPtr a_local,
return FALSE ;
}
+Bool
+findWindowPairFromRemote (int a_remote,
+ EphyrWindowPair **a_pair)
+{
+ int i=0 ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_pair, FALSE) ;
+
+ for (i=0; i < NUM_WINDOW_PAIRS; i++) {
+ if (window_pairs[i].remote == a_remote) {
+ *a_pair = &window_pairs[i] ;
+ EPHYR_LOG ("found (%p, %d)\n",
+ (*a_pair)->local,
+ (*a_pair)->remote) ;
+ return TRUE ;
+ }
+ }
+ return FALSE ;
+}
+
static Bool
createHostPeerWindow (const WindowPtr a_win,
int *a_peer_win)
diff --git a/hw/kdrive/ephyr/ephyrdriext.h b/hw/kdrive/ephyr/ephyrdriext.h
index 66af833b9..01c9421fb 100644
--- a/hw/kdrive/ephyr/ephyrdriext.h
+++ b/hw/kdrive/ephyr/ephyrdriext.h
@@ -27,6 +27,16 @@
*/
#ifndef __EPHYRDRIEXT_H__
#define __EPHYRDRIEXT_H__
+
+typedef struct {
+ WindowPtr local ;
+ int remote ;
+} EphyrWindowPair;
+
Bool ephyrDRIExtensionInit (ScreenPtr a_screen) ;
+
+Bool findWindowPairFromRemote (int a_remote,
+ EphyrWindowPair **a_pair);
+
#endif /*__EPHYRDRIEXT_H__*/
diff --git a/hw/kdrive/ephyr/ephyrglxext.c b/hw/kdrive/ephyr/ephyrglxext.c
index 381c9d7ed..43a634d24 100644
--- a/hw/kdrive/ephyr/ephyrglxext.c
+++ b/hw/kdrive/ephyr/ephyrglxext.c
@@ -362,7 +362,7 @@ ephyrGLXQueryServerString(__GLXclientState *a_cl, GLbyte *a_pc)
ClientPtr client = a_cl->client;
xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) a_pc;
xGLXQueryServerStringReply reply;
- char *server_string=NULL ;
+ char *server_string=NULL, *buf=NULL;
int length=0 ;
EPHYR_LOG ("enter\n") ;
@@ -379,9 +379,15 @@ ephyrGLXQueryServerString(__GLXclientState *a_cl, GLbyte *a_pc)
reply.sequenceNumber = client->sequence ;
reply.length = __GLX_PAD (length) >> 2 ;
reply.n = length ;
+ buf = xcalloc (reply.length << 2, 1);
+ if (!buf) {
+ EPHYR_LOG_ERROR ("failed to allocate string\n;");
+ return BadAlloc;
+ }
+ memcpy (buf, server_string, length);
WriteToClient(client, sz_xGLXQueryServerStringReply, (char*)&reply);
- WriteToClient(client, (int)length, server_string);
+ WriteToClient(client, (int)(reply.length << 2), server_string);
res = Success ;
@@ -391,6 +397,10 @@ out:
xfree (server_string) ;
server_string = NULL;
}
+ if (buf) {
+ xfree (buf);
+ buf = NULL;
+ }
return res ;
}
diff --git a/hw/kdrive/ephyr/ephyrhostglx.c b/hw/kdrive/ephyr/ephyrhostglx.c
index 5d9a482e8..f5db5be16 100644
--- a/hw/kdrive/ephyr/ephyrhostglx.c
+++ b/hw/kdrive/ephyr/ephyrhostglx.c
@@ -151,6 +151,7 @@ ephyrHostGLXGetStringFromServer (int a_screen_number,
{
Bool is_ok=FALSE ;
Display *dpy = hostx_get_display () ;
+ int default_screen = DefaultScreen (dpy);
xGLXGenericGetStringReq *req=NULL;
xGLXSingleReply reply;
int length=0, numbytes=0, major_opcode=0, get_string_op=0;
@@ -188,13 +189,17 @@ ephyrHostGLXGetStringFromServer (int a_screen_number,
GetReq (GLXGenericGetString, req);
req->reqType = major_opcode;
req->glxCode = get_string_op;
- req->for_whom = DefaultScreen (dpy);
+ req->for_whom = default_screen;
req->name = a_string_name;
_XReply (dpy, (xReply *)&reply, 0, False);
length = reply.length * 4;
- numbytes = reply.size;
+ if (!length) {
+ numbytes = 0;
+ } else {
+ numbytes = reply.size;
+ }
EPHYR_LOG ("going to get a string of size:%d\n", numbytes) ;
*a_string = (char *) Xmalloc (numbytes +1);
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index a5413b876..ae1bb4bf9 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -839,16 +839,38 @@ hostx_load_keymap(void)
static struct EphyrHostScreen *
host_screen_from_window (Window w)
{
- int index;
+ int index = 0;
+ struct EphyrHostScreen *result = NULL;
+#if 0
+ unsigned int num_children = 0;
+ Window root = None, parent = None, *children = NULL;
+#endif
for (index = 0 ; index < HostX.n_screens ; index++)
{
if (HostX.screens[index].win == w)
{
- return &HostX.screens[index];
+ result = &HostX.screens[index];
+ goto out;
}
}
- return NULL;
+#if 0
+ XQueryTree (hostx_get_display (), w, &root, &parent,
+ &children, &num_children);
+ if (parent == root || parent == None)
+ goto out;
+ result = host_screen_from_window (parent);
+#endif
+
+out:
+#if 0
+ if (children)
+ {
+ XFree (children);
+ children = NULL;
+ }
+#endif
+ return result;
}
int
@@ -870,9 +892,19 @@ hostx_get_event(EphyrHostXEvent *ev)
{
struct EphyrHostScreen *host_screen =
host_screen_from_window (xev.xexpose.window);
- hostx_paint_rect (host_screen->info, 0, 0, 0, 0,
- host_screen->win_width,
- host_screen->win_height);
+ if (host_screen)
+ {
+ hostx_paint_rect (host_screen->info, 0, 0, 0, 0,
+ host_screen->win_width,
+ host_screen->win_height);
+ }
+ else
+ {
+ EPHYR_LOG_ERROR ("failed to get host screen\n");
+ ev->type = EPHYR_EV_EXPOSE;
+ ev->data.expose.window = xev.xexpose.window;
+ return 1;
+ }
}
return 0;
@@ -1113,12 +1145,18 @@ hostx_create_window (int a_screen_number,
visual_info->screen),
visual_info->visual,
AllocNone) ;
- winmask = CWColormap;
+ attrs.event_mask = ButtonPressMask
+ |ButtonReleaseMask
+ |PointerMotionMask
+ |KeyPressMask
+ |KeyReleaseMask
+ |ExposureMask;
+ winmask = CWColormap|CWEventMask;
win = XCreateWindow (dpy, hostx_get_window (a_screen_number),
a_geometry->x, a_geometry->y,
a_geometry->width, a_geometry->height, 0,
- visual_info->depth, InputOutput,
+ visual_info->depth, CopyFromParent,
visual_info->visual, winmask, &attrs) ;
if (win == None) {
EPHYR_LOG_ERROR ("failed to create peer window\n") ;
diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h
index 3caa466a7..f72cfe700 100644
--- a/hw/kdrive/ephyr/hostx.h
+++ b/hw/kdrive/ephyr/hostx.h
@@ -47,7 +47,8 @@ typedef enum EphyrHostXEventType
EPHYR_EV_MOUSE_PRESS,
EPHYR_EV_MOUSE_RELEASE,
EPHYR_EV_KEY_PRESS,
- EPHYR_EV_KEY_RELEASE
+ EPHYR_EV_KEY_RELEASE,
+ EPHYR_EV_EXPOSE
}
EphyrHostXEventType;
@@ -87,6 +88,10 @@ struct EphyrHostXEvent
int scancode;
} key_down;
+ struct expose {
+ int window;
+ } expose;
+
} data;
int key_state;
diff --git a/hw/kdrive/linux/linux.c b/hw/kdrive/linux/linux.c
index 23cd8f59f..258dc7b81 100644
--- a/hw/kdrive/linux/linux.c
+++ b/hw/kdrive/linux/linux.c
@@ -441,7 +441,7 @@ LinuxFini (void)
memset (&vts, '\0', sizeof (vts)); /* valgrind */
ioctl (fd, VT_GETSTATE, &vts);
if (ioctl (fd, VT_DISALLOCATE, vtno) < 0)
- fprintf (stderr, "Can't deallocate console %d errno %d\n", vtno, errno);
+ fprintf (stderr, "Can't deallocate console %d %s\n", vtno, strerror(errno));
close (fd);
}
return;
diff --git a/hw/kdrive/src/kaa.c b/hw/kdrive/src/kaa.c
index e75b08399..db09e9dba 100644
--- a/hw/kdrive/src/kaa.c
+++ b/hw/kdrive/src/kaa.c
@@ -996,18 +996,6 @@ kaaFillRegionSolid (DrawablePtr pDrawable,
kaaDrawableDirty (pDrawable);
}
-#if 0
-static void
-kaaFillRegionTiled (DrawablePtr pDrawable,
- RegionPtr pRegion,
- Pixmap pTile)
-{
- else
- {
- kaaWaitSync
-}
-#endif
-
Bool
kaaDrawInit (ScreenPtr pScreen,
KaaScreenInfoPtr pScreenInfo)
diff --git a/hw/kdrive/src/kmap.c b/hw/kdrive/src/kmap.c
index b92c1a84f..ce1e28ae4 100644
--- a/hw/kdrive/src/kmap.c
+++ b/hw/kdrive/src/kmap.c
@@ -132,8 +132,8 @@ KdSetMappedMode (CARD32 addr, CARD32 size, int mode)
sentry.type = type;
if (ioctl (mtrr, MTRRIOC_ADD_ENTRY, &sentry) < 0)
- ErrorF ("MTRRIOC_ADD_ENTRY failed 0x%x 0x%x %d (errno %d)\n",
- base, bound - base, type, errno);
+ ErrorF ("MTRRIOC_ADD_ENTRY failed 0x%x 0x%x %d (%s)\n",
+ base, bound - base, type, strerror(errno));
}
#endif
}
@@ -171,8 +171,8 @@ KdResetMappedMode (CARD32 addr, CARD32 size, int mode)
sentry.type = type;
if (ioctl (mtrr, MTRRIOC_DEL_ENTRY, &sentry) < 0)
- ErrorF ("MTRRIOC_DEL_ENTRY failed 0x%x 0x%x %d (errno %d)\n",
- base, bound - base, type, errno);
+ ErrorF ("MTRRIOC_DEL_ENTRY failed 0x%x 0x%x %d (%s)\n",
+ base, bound - base, type, strerror(errno));
}
#endif
}
diff --git a/hw/kdrive/vesa/vm86.c b/hw/kdrive/vesa/vm86.c
index 78fc593a7..0f7bb2262 100644
--- a/hw/kdrive/vesa/vm86.c
+++ b/hw/kdrive/vesa/vm86.c
@@ -567,7 +567,7 @@ vm86_loop(Vm86InfoPtr vi)
if(errno == ENOSYS) {
ErrorF("No vm86 support. Are you running on AMD64?\n");
} else {
- ErrorF("vm86 failed (errno = %d).\n", errno);
+ ErrorF("vm86 failed (%s).\n", strerror(errno));
Vm86Debug(vi);
}
} else {