summaryrefslogtreecommitdiff
path: root/xserver/hw/kdrive/ephyr
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2015-09-16 19:10:27 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2015-09-16 19:10:27 +0000
commit4f2941d7bdfb60a6b2ca49d7e2ee50dd5eb11ddd (patch)
tree5f7f0cf3d5aeb655a950fae516224a3d61a820cf /xserver/hw/kdrive/ephyr
parentc84734bf28ef1ec0ce3cc7d1c45dfb920484e68e (diff)
Update to xserver 1.17.2. tested by dcoppa@, jsg@, jasper@ & naddy@
Diffstat (limited to 'xserver/hw/kdrive/ephyr')
-rw-r--r--xserver/hw/kdrive/ephyr/Makefile.am6
-rw-r--r--xserver/hw/kdrive/ephyr/Makefile.in22
-rw-r--r--xserver/hw/kdrive/ephyr/ephyr.c56
-rw-r--r--xserver/hw/kdrive/ephyr/ephyr.h23
-rw-r--r--xserver/hw/kdrive/ephyr/ephyr_glamor_glx.c24
-rw-r--r--xserver/hw/kdrive/ephyr/ephyr_glamor_xv.c161
-rw-r--r--xserver/hw/kdrive/ephyr/ephyrcursor.c262
-rw-r--r--xserver/hw/kdrive/ephyr/ephyrdri.c4
-rw-r--r--xserver/hw/kdrive/ephyr/ephyrdri.h4
-rw-r--r--xserver/hw/kdrive/ephyr/ephyrdriext.c4
-rw-r--r--xserver/hw/kdrive/ephyr/ephyrdriext.h4
-rw-r--r--xserver/hw/kdrive/ephyr/ephyrglxext.c4
-rw-r--r--xserver/hw/kdrive/ephyr/ephyrglxext.h4
-rw-r--r--xserver/hw/kdrive/ephyr/ephyrhostglx.c4
-rw-r--r--xserver/hw/kdrive/ephyr/ephyrhostglx.h4
-rw-r--r--xserver/hw/kdrive/ephyr/ephyrinit.c133
-rw-r--r--xserver/hw/kdrive/ephyr/ephyrlog.h4
-rw-r--r--xserver/hw/kdrive/ephyr/ephyrvideo.c38
-rw-r--r--xserver/hw/kdrive/ephyr/hostx.c275
-rw-r--r--xserver/hw/kdrive/ephyr/hostx.h20
-rw-r--r--xserver/hw/kdrive/ephyr/man/Makefile.in1
-rw-r--r--xserver/hw/kdrive/ephyr/man/Xephyr.man3
-rw-r--r--xserver/hw/kdrive/ephyr/os.c4
23 files changed, 862 insertions, 202 deletions
diff --git a/xserver/hw/kdrive/ephyr/Makefile.am b/xserver/hw/kdrive/ephyr/Makefile.am
index 00a53d0df..155e11eb3 100644
--- a/xserver/hw/kdrive/ephyr/Makefile.am
+++ b/xserver/hw/kdrive/ephyr/Makefile.am
@@ -35,9 +35,14 @@ XV_SRCS = ephyrvideo.c
endif
if GLAMOR
+if XV
+GLAMOR_XV_SRCS = ephyr_glamor_xv.c
+endif
+
GLAMOR_SRCS = \
ephyr_glamor_glx.c \
ephyr_glamor_glx.h \
+ $(GLAMOR_XV_SRCS) \
$()
endif
@@ -63,6 +68,7 @@ Xephyr_SOURCES = \
ephyr_draw.c \
os.c \
ephyrinit.c \
+ ephyrcursor.c \
hostx.c \
hostx.h \
$(XV_SRCS) \
diff --git a/xserver/hw/kdrive/ephyr/Makefile.in b/xserver/hw/kdrive/ephyr/Makefile.in
index 1cf0570e5..a299e9739 100644
--- a/xserver/hw/kdrive/ephyr/Makefile.in
+++ b/xserver/hw/kdrive/ephyr/Makefile.in
@@ -98,17 +98,19 @@ CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am__Xephyr_SOURCES_DIST = ephyr.c ephyr.h ephyrlog.h ephyr_draw.c os.c \
- ephyrinit.c hostx.c hostx.h ephyrvideo.c ephyrdriext.c \
- ephyrdriext.h ephyrdri.c ephyrdri.h ephyrglxext.c \
- ephyrglxext.h ephyrhostglx.c ephyrhostglx.h ephyr_glamor_glx.c \
- ephyr_glamor_glx.h
+ ephyrinit.c ephyrcursor.c hostx.c hostx.h ephyrvideo.c \
+ ephyrdriext.c ephyrdriext.h ephyrdri.c ephyrdri.h \
+ ephyrglxext.c ephyrglxext.h ephyrhostglx.c ephyrhostglx.h \
+ ephyr_glamor_glx.c ephyr_glamor_glx.h ephyr_glamor_xv.c
@XV_TRUE@am__objects_1 = ephyrvideo.$(OBJEXT)
@DRI_TRUE@am__objects_2 = ephyrdriext.$(OBJEXT) ephyrdri.$(OBJEXT) \
@DRI_TRUE@ ephyrglxext.$(OBJEXT) ephyrhostglx.$(OBJEXT)
-@GLAMOR_TRUE@am__objects_3 = ephyr_glamor_glx.$(OBJEXT)
+@GLAMOR_TRUE@@XV_TRUE@am__objects_3 = ephyr_glamor_xv.$(OBJEXT)
+@GLAMOR_TRUE@am__objects_4 = ephyr_glamor_glx.$(OBJEXT) \
+@GLAMOR_TRUE@ $(am__objects_3)
am_Xephyr_OBJECTS = ephyr.$(OBJEXT) ephyr_draw.$(OBJEXT) os.$(OBJEXT) \
- ephyrinit.$(OBJEXT) hostx.$(OBJEXT) $(am__objects_1) \
- $(am__objects_2) $(am__objects_3)
+ ephyrinit.$(OBJEXT) ephyrcursor.$(OBJEXT) hostx.$(OBJEXT) \
+ $(am__objects_1) $(am__objects_2) $(am__objects_4)
Xephyr_OBJECTS = $(am_Xephyr_OBJECTS)
@GLAMOR_TRUE@am__DEPENDENCIES_1 = $(top_builddir)/glamor/libglamor.la \
@GLAMOR_TRUE@ $(top_builddir)/glamor/libglamor_egl_stubs.la
@@ -309,6 +311,7 @@ KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
KDRIVE_INCS = @KDRIVE_INCS@
KDRIVE_LIBS = @KDRIVE_LIBS@
KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_MAIN_LIB = @KDRIVE_MAIN_LIB@
KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
KHRONOS_OPENGL_REGISTRY_CFLAGS = @KHRONOS_OPENGL_REGISTRY_CFLAGS@
@@ -551,9 +554,11 @@ AM_CPPFLAGS = @KDRIVE_INCS@ @KDRIVE_CFLAGS@ @XEPHYR_INCS@ \
@XEPHYR_CFLAGS@ -I$(top_srcdir) -I$(top_srcdir)/glamor \
-I$(top_srcdir)/exa $(am__append_1)
@XV_TRUE@XV_SRCS = ephyrvideo.c
+@GLAMOR_TRUE@@XV_TRUE@GLAMOR_XV_SRCS = ephyr_glamor_xv.c
@GLAMOR_TRUE@GLAMOR_SRCS = \
@GLAMOR_TRUE@ ephyr_glamor_glx.c \
@GLAMOR_TRUE@ ephyr_glamor_glx.h \
+@GLAMOR_TRUE@ $(GLAMOR_XV_SRCS) \
@GLAMOR_TRUE@ $()
@DRI_TRUE@DRI_SRCS = \
@@ -574,6 +579,7 @@ Xephyr_SOURCES = \
ephyr_draw.c \
os.c \
ephyrinit.c \
+ ephyrcursor.c \
hostx.c \
hostx.h \
$(XV_SRCS) \
@@ -687,6 +693,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ephyr.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ephyr_draw.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ephyr_glamor_glx.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ephyr_glamor_xv.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ephyrcursor.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ephyrdri.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ephyrdriext.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ephyrglxext.Po@am__quote@
diff --git a/xserver/hw/kdrive/ephyr/ephyr.c b/xserver/hw/kdrive/ephyr/ephyr.c
index def50d8d8..164ebdcba 100644
--- a/xserver/hw/kdrive/ephyr/ephyr.c
+++ b/xserver/hw/kdrive/ephyr/ephyr.c
@@ -1,8 +1,8 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2004 Nokia
+ *
+ * Copyright © 2004 Nokia
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -68,6 +68,7 @@ typedef struct _EphyrInputPrivate {
Bool EphyrWantGrayScale = 0;
Bool EphyrWantResize = 0;
+Bool EphyrWantNoHostGrab = 0;
Bool
host_has_extension(xcb_extension_t *extension)
@@ -111,13 +112,16 @@ Bool
ephyrScreenInitialize(KdScreenInfo *screen)
{
EphyrScrPriv *scrpriv = screen->driver;
+ int x = 0, y = 0;
int width = 640, height = 480;
CARD32 redMask, greenMask, blueMask;
- if (hostx_want_screen_size(screen, &width, &height)
+ if (hostx_want_screen_geometry(screen, &width, &height, &x, &y)
|| !screen->width || !screen->height) {
screen->width = width;
screen->height = height;
+ screen->x = x;
+ screen->y = y;
}
if (EphyrWantGrayScale)
@@ -242,7 +246,8 @@ ephyrMapFramebuffer(KdScreenInfo * screen)
buffer_height = ephyrBufferHeight(screen);
priv->base =
- hostx_screen_init(screen, screen->width, screen->height, buffer_height,
+ hostx_screen_init(screen, screen->x, screen->y,
+ screen->width, screen->height, buffer_height,
&priv->bytes_per_line, &screen->fb.bitsPerPixel);
if ((scrpriv->randr & RR_Rotate_0) && !(scrpriv->randr & RR_Reflect_All)) {
@@ -308,8 +313,8 @@ ephyrShadowUpdate(ScreenPtr pScreen, shadowBufPtr pBuf)
EPHYR_LOG("slow paint");
/* FIXME: Slow Rotated/Reflected updates could be much
- * much faster efficiently updating via tranforming
- * pBuf->pDamage regions
+ * much faster efficiently updating via tranforming
+ * pBuf->pDamage regions
*/
shadowUpdateRotatePacked(pScreen, pBuf);
hostx_paint_rect(screen, 0, 0, 0, 0, screen->width, screen->height);
@@ -530,7 +535,7 @@ ephyrRandRSetConfig(ScreenPtr pScreen,
goto bail4;
}
else {
- /* Without shadow fb ( non rotated ) we need
+ /* Without shadow fb ( non rotated ) we need
* to use damage to efficiently update display
* via signal regions what to copy from 'fb'.
*/
@@ -645,12 +650,18 @@ ephyrInitScreen(ScreenPtr pScreen)
EPHYR_LOG("pScreen->myNum:%d\n", pScreen->myNum);
hostx_set_screen_number(screen, pScreen->myNum);
- hostx_set_win_title(screen, "(ctrl+shift grabs mouse and keyboard)");
+ if (EphyrWantNoHostGrab) {
+ hostx_set_win_title(screen, "xephyr");
+ } else {
+ hostx_set_win_title(screen, "(ctrl+shift grabs mouse and keyboard)");
+ }
pScreen->CreateColormap = ephyrCreateColormap;
#ifdef XV
if (!ephyrNoXV) {
- if (!ephyrInitVideo(pScreen)) {
+ if (ephyr_glamor)
+ ephyr_glamor_xv_init(pScreen);
+ else if (!ephyrInitVideo(pScreen)) {
EPHYR_LOG_ERROR("failed to initialize xvideo\n");
}
else {
@@ -676,7 +687,7 @@ ephyrInitScreen(ScreenPtr pScreen)
Bool
ephyrFinishInitScreen(ScreenPtr pScreen)
{
- /* FIXME: Calling this even if not using shadow.
+ /* FIXME: Calling this even if not using shadow.
* Seems harmless enough. But may be safer elsewhere.
*/
if (!shadowSetup(pScreen))
@@ -756,7 +767,13 @@ ephyrScreenFini(KdScreenInfo * screen)
}
}
-/*
+void
+ephyrCloseScreen(ScreenPtr pScreen)
+{
+ ephyrUnsetInternalDamage(pScreen);
+}
+
+/*
* Port of Mark McLoughlin's Xnest fix for focus in + modifier bug.
* See https://bugs.freedesktop.org/show_bug.cgi?id=3030
*/
@@ -789,7 +806,11 @@ ephyrUpdateModifierState(unsigned int state)
for (key = 0; key < MAP_LENGTH; key++)
if (keyc->xkbInfo->desc->map->modmap[key] & mask) {
- if (key_is_down(pDev, key, KEY_PROCESSED))
+ if (mask == XCB_MOD_MASK_LOCK) {
+ KdEnqueueKeyboardEvent(ephyrKbd, key, FALSE);
+ KdEnqueueKeyboardEvent(ephyrKbd, key, TRUE);
+ }
+ else if (key_is_down(pDev, key, KEY_PROCESSED))
KdEnqueueKeyboardEvent(ephyrKbd, key, TRUE);
if (--count == 0)
@@ -803,6 +824,8 @@ ephyrUpdateModifierState(unsigned int state)
for (key = 0; key < MAP_LENGTH; key++)
if (keyc->xkbInfo->desc->map->modmap[key] & mask) {
KdEnqueueKeyboardEvent(ephyrKbd, key, FALSE);
+ if (mask == XCB_MOD_MASK_LOCK)
+ KdEnqueueKeyboardEvent(ephyrKbd, key, TRUE);
break;
}
}
@@ -866,7 +889,7 @@ ephyrExposePairedWindow(int a_remote)
screen = pair->local->drawable.pScreen;
RegionNull(&reg);
RegionCopy(&reg, &pair->local->clipList);
- screen->WindowExposures(pair->local, &reg, NullRegion);
+ screen->WindowExposures(pair->local, &reg);
RegionUninit(&reg);
}
#endif /* XF86DRI */
@@ -1080,12 +1103,13 @@ ephyrProcessKeyRelease(xcb_generic_event_t *xev)
if (!keysyms)
keysyms = xcb_key_symbols_alloc(conn);
- if (((xcb_key_symbols_get_keysym(keysyms, key->detail, 0) == XK_Shift_L
+ if (!EphyrWantNoHostGrab &&
+ (((xcb_key_symbols_get_keysym(keysyms, key->detail, 0) == XK_Shift_L
|| xcb_key_symbols_get_keysym(keysyms, key->detail, 0) == XK_Shift_R)
&& (key->state & XCB_MOD_MASK_CONTROL)) ||
((xcb_key_symbols_get_keysym(keysyms, key->detail, 0) == XK_Control_L
|| xcb_key_symbols_get_keysym(keysyms, key->detail, 0) == XK_Control_R)
- && (key->state & XCB_MOD_MASK_SHIFT))) {
+ && (key->state & XCB_MOD_MASK_SHIFT)))) {
KdScreenInfo *screen = screen_from_window(key->event);
EphyrScrPriv *scrpriv = screen->driver;
@@ -1274,7 +1298,7 @@ ephyrPutColors(ScreenPtr pScreen, int n, xColorItem * pdefs)
if (p > max)
max = p;
- hostx_set_cmap_entry(p,
+ hostx_set_cmap_entry(pScreen, p,
pdefs->red >> 8,
pdefs->green >> 8, pdefs->blue >> 8);
pdefs++;
diff --git a/xserver/hw/kdrive/ephyr/ephyr.h b/xserver/hw/kdrive/ephyr/ephyr.h
index 34ce4601b..18bfe11ff 100644
--- a/xserver/hw/kdrive/ephyr/ephyr.h
+++ b/xserver/hw/kdrive/ephyr/ephyr.h
@@ -1,8 +1,8 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@o-hand.com>
- *
- * Copyright © 2004 Nokia
+ *
+ * Copyright © 2004 Nokia
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -73,13 +73,17 @@ typedef struct _ephyrScrPriv {
xcb_window_t win_pre_existing; /* Set via -parent option like xnest */
xcb_window_t peer_win; /* Used for GL; should be at most one */
xcb_image_t *ximg;
+ Bool win_explicit_position;
+ int win_x, win_y;
int win_width, win_height;
int server_depth;
+ const char *output; /* Set via -output option */
unsigned char *fb_data; /* only used when host bpp != server bpp */
xcb_shm_segment_info_t shminfo;
KdScreenInfo *screen;
int mynum; /* Screen number */
+ unsigned long cmap[256];
/**
* Per-screen Xlib-using state for glamor (private to
@@ -131,6 +135,9 @@ void
ephyrScreenFini(KdScreenInfo * screen);
void
+ephyrCloseScreen(ScreenPtr pScreen);
+
+void
ephyrCardFini(KdCardInfo * card);
void
@@ -191,8 +198,6 @@ extern KdOsFuncs EphyrOsFuncs;
extern Bool ephyrCursorInit(ScreenPtr pScreen);
-extern void ephyrCursorEnable(ScreenPtr pScreen);
-
extern int ephyrBufferHeight(KdScreenInfo * screen);
/* ephyr_draw.c */
@@ -221,4 +226,14 @@ void ephyr_glamor_host_paint_rect(ScreenPtr pScreen);
Bool ephyrInitVideo(ScreenPtr pScreen);
+/* ephyr_glamor_xv.c */
+#ifdef GLAMOR
+void ephyr_glamor_xv_init(ScreenPtr screen);
+#else /* !GLAMOR */
+static inline void
+ephyr_glamor_xv_init(ScreenPtr screen)
+{
+}
+#endif /* !GLAMOR */
+
#endif
diff --git a/xserver/hw/kdrive/ephyr/ephyr_glamor_glx.c b/xserver/hw/kdrive/ephyr/ephyr_glamor_glx.c
index eaf565496..8fe751693 100644
--- a/xserver/hw/kdrive/ephyr/ephyr_glamor_glx.c
+++ b/xserver/hw/kdrive/ephyr/ephyr_glamor_glx.c
@@ -52,6 +52,7 @@
static Display *dpy;
static XVisualInfo *visual_info;
static GLXFBConfig fb_config;
+Bool ephyr_glamor_gles2;
/** @} */
/**
@@ -145,6 +146,10 @@ ephyr_glamor_setup_texturing_shader(struct ephyr_glamor *glamor)
"}\n";
const char *fs_source =
+ "#ifdef GL_ES\n"
+ "precision mediump float;\n"
+ "#endif\n"
+ "\n"
"varying vec2 t;\n"
"uniform sampler2D s; /* initially 0 */\n"
"\n"
@@ -276,7 +281,24 @@ ephyr_glamor_glx_screen_init(xcb_window_t win)
glx_win = glXCreateWindow(dpy, fb_config, win, NULL);
- ctx = glXCreateContext(dpy, visual_info, NULL, True);
+ if (ephyr_glamor_gles2) {
+ static const int context_attribs[] = {
+ GLX_CONTEXT_MAJOR_VERSION_ARB, 2,
+ GLX_CONTEXT_MINOR_VERSION_ARB, 0,
+ GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_ES_PROFILE_BIT_EXT,
+ 0,
+ };
+ if (epoxy_has_glx_extension(dpy, DefaultScreen(dpy),
+ "GLX_EXT_create_context_es2_profile")) {
+ ctx = glXCreateContextAttribsARB(dpy, fb_config, NULL, True,
+ context_attribs);
+ } else {
+ FatalError("Xephyr -glamor_gles2 rquires "
+ "GLX_EXT_create_context_es2_profile\n");
+ }
+ } else {
+ ctx = glXCreateContext(dpy, visual_info, NULL, True);
+ }
if (ctx == NULL)
FatalError("glXCreateContext failed\n");
diff --git a/xserver/hw/kdrive/ephyr/ephyr_glamor_xv.c b/xserver/hw/kdrive/ephyr/ephyr_glamor_xv.c
new file mode 100644
index 000000000..b9c3464d8
--- /dev/null
+++ b/xserver/hw/kdrive/ephyr/ephyr_glamor_xv.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+
+#include "kdrive.h"
+#include "kxv.h"
+#include "ephyr.h"
+#include "glamor_priv.h"
+
+#include <X11/extensions/Xv.h>
+#include "fourcc.h"
+
+#define NUM_FORMATS 3
+
+static KdVideoFormatRec Formats[NUM_FORMATS] = {
+ {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
+};
+
+static void
+ephyr_glamor_xv_stop_video(KdScreenInfo *screen, void *data, Bool cleanup)
+{
+ if (!cleanup)
+ return;
+
+ glamor_xv_stop_video(data);
+}
+
+static int
+ephyr_glamor_xv_set_port_attribute(KdScreenInfo *screen,
+ Atom attribute, INT32 value, void *data)
+{
+ return glamor_xv_set_port_attribute(data, attribute, value);
+}
+
+static int
+ephyr_glamor_xv_get_port_attribute(KdScreenInfo *screen,
+ Atom attribute, INT32 *value, void *data)
+{
+ return glamor_xv_get_port_attribute(data, attribute, value);
+}
+
+static void
+ephyr_glamor_xv_query_best_size(KdScreenInfo *screen,
+ Bool motion,
+ short vid_w, short vid_h,
+ short drw_w, short drw_h,
+ unsigned int *p_w, unsigned int *p_h,
+ void *data)
+{
+ *p_w = drw_w;
+ *p_h = drw_h;
+}
+
+static int
+ephyr_glamor_xv_query_image_attributes(KdScreenInfo *screen,
+ int id,
+ unsigned short *w, unsigned short *h,
+ int *pitches, int *offsets)
+{
+ return glamor_xv_query_image_attributes(id, w, h, pitches, offsets);
+}
+
+static int
+ephyr_glamor_xv_put_image(KdScreenInfo *screen,
+ DrawablePtr pDrawable,
+ short src_x, short src_y,
+ short drw_x, short drw_y,
+ short src_w, short src_h,
+ short drw_w, short drw_h,
+ int id,
+ unsigned char *buf,
+ short width,
+ short height,
+ Bool sync,
+ RegionPtr clipBoxes, void *data)
+{
+ return glamor_xv_put_image(data, pDrawable,
+ src_x, src_y,
+ drw_x, drw_y,
+ src_w, src_h,
+ drw_w, drw_h,
+ id, buf, width, height, sync, clipBoxes);
+}
+
+void
+ephyr_glamor_xv_init(ScreenPtr screen)
+{
+ KdVideoAdaptorRec *adaptor;
+ glamor_port_private *port_privates;
+ KdVideoEncodingRec encoding = {
+ 0,
+ "XV_IMAGE",
+ /* These sizes should probably be GL_MAX_TEXTURE_SIZE instead
+ * of 2048, but our context isn't set up yet.
+ */
+ 2048, 2048,
+ {1, 1}
+ };
+ int i;
+
+ glamor_xv_core_init(screen);
+
+ adaptor = xnfcalloc(1, sizeof(*adaptor));
+
+ adaptor->name = "glamor textured video";
+ adaptor->type = XvWindowMask | XvInputMask | XvImageMask;
+ adaptor->flags = 0;
+ adaptor->nEncodings = 1;
+ adaptor->pEncodings = &encoding;
+
+ adaptor->pFormats = Formats;
+ adaptor->nFormats = NUM_FORMATS;
+
+ adaptor->nPorts = 16; /* Some absurd number */
+ port_privates = xnfcalloc(adaptor->nPorts,
+ sizeof(glamor_port_private));
+ adaptor->pPortPrivates = xnfcalloc(adaptor->nPorts,
+ sizeof(glamor_port_private *));
+ for (i = 0; i < adaptor->nPorts; i++) {
+ adaptor->pPortPrivates[i].ptr = &port_privates[i];
+ glamor_xv_init_port(&port_privates[i]);
+ }
+
+ adaptor->pAttributes = glamor_xv_attributes;
+ adaptor->nAttributes = glamor_xv_num_attributes;
+
+ adaptor->pImages = glamor_xv_images;
+ adaptor->nImages = glamor_xv_num_images;
+
+ adaptor->StopVideo = ephyr_glamor_xv_stop_video;
+ adaptor->SetPortAttribute = ephyr_glamor_xv_set_port_attribute;
+ adaptor->GetPortAttribute = ephyr_glamor_xv_get_port_attribute;
+ adaptor->QueryBestSize = ephyr_glamor_xv_query_best_size;
+ adaptor->PutImage = ephyr_glamor_xv_put_image;
+ adaptor->QueryImageAttributes = ephyr_glamor_xv_query_image_attributes;
+
+ KdXVScreenInit(screen, adaptor, 1);
+}
diff --git a/xserver/hw/kdrive/ephyr/ephyrcursor.c b/xserver/hw/kdrive/ephyr/ephyrcursor.c
new file mode 100644
index 000000000..852be33e0
--- /dev/null
+++ b/xserver/hw/kdrive/ephyr/ephyrcursor.c
@@ -0,0 +1,262 @@
+/*
+ * Copyright © 2014 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author:
+ * Adam Jackson <ajax@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "ephyr.h"
+#include "ephyrlog.h"
+#include "hostx.h"
+#include "cursorstr.h"
+#include <xcb/render.h>
+#include <xcb/xcb_renderutil.h>
+
+static DevPrivateKeyRec ephyrCursorPrivateKey;
+
+typedef struct _ephyrCursor {
+ xcb_cursor_t cursor;
+} ephyrCursorRec, *ephyrCursorPtr;
+
+static ephyrCursorPtr
+ephyrGetCursor(CursorPtr cursor)
+{
+ return dixGetPrivateAddr(&cursor->devPrivates, &ephyrCursorPrivateKey);
+}
+
+static void
+ephyrRealizeCoreCursor(EphyrScrPriv *scr, CursorPtr cursor)
+{
+ ephyrCursorPtr hw = ephyrGetCursor(cursor);
+ xcb_connection_t *conn = hostx_get_xcbconn();
+ xcb_pixmap_t source, mask;
+ xcb_image_t *image;
+ xcb_gcontext_t gc;
+ int w = cursor->bits->width, h = cursor->bits->height;
+ uint32_t gcmask = XCB_GC_FUNCTION |
+ XCB_GC_PLANE_MASK |
+ XCB_GC_FOREGROUND |
+ XCB_GC_BACKGROUND |
+ XCB_GC_CLIP_MASK;
+ uint32_t val[] = {
+ XCB_GX_COPY, /* function */
+ ~0, /* planemask */
+ 1L, /* foreground */
+ 0L, /* background */
+ None, /* clipmask */
+ };
+
+ source = xcb_generate_id(conn);
+ mask = xcb_generate_id(conn);
+ xcb_create_pixmap(conn, 1, source, scr->win, w, h);
+ xcb_create_pixmap(conn, 1, mask, scr->win, w, h);
+
+ gc = xcb_generate_id(conn);
+ xcb_create_gc(conn, gc, source, gcmask, val);
+
+ image = xcb_image_create_native(conn, w, h, XCB_IMAGE_FORMAT_XY_BITMAP,
+ 1, NULL, ~0, NULL);
+ image->data = cursor->bits->source;
+ xcb_image_put(conn, source, gc, image, 0, 0, 0);
+ xcb_image_destroy(image);
+
+ image = xcb_image_create_native(conn, w, h, XCB_IMAGE_FORMAT_XY_BITMAP,
+ 1, NULL, ~0, NULL);
+ image->data = cursor->bits->mask;
+ xcb_image_put(conn, mask, gc, image, 0, 0, 0);
+ xcb_image_destroy(image);
+
+ xcb_free_gc(conn, gc);
+
+ hw->cursor = xcb_generate_id(conn);
+ xcb_create_cursor(conn, hw->cursor, source, mask,
+ cursor->foreRed, cursor->foreGreen, cursor->foreBlue,
+ cursor->backRed, cursor->backGreen, cursor->backBlue,
+ cursor->bits->xhot, cursor->bits->yhot);
+
+ xcb_free_pixmap(conn, source);
+ xcb_free_pixmap(conn, mask);
+}
+
+#ifdef ARGB_CURSOR
+static xcb_render_pictformat_t
+get_argb_format(void)
+{
+ static xcb_render_pictformat_t format;
+ if (format == None) {
+ xcb_connection_t *conn = hostx_get_xcbconn();
+ xcb_render_query_pict_formats_cookie_t cookie;
+ xcb_render_query_pict_formats_reply_t *formats;
+
+ cookie = xcb_render_query_pict_formats(conn);
+ formats =
+ xcb_render_query_pict_formats_reply(conn, cookie, NULL);
+
+ format =
+ xcb_render_util_find_standard_format(formats,
+ XCB_PICT_STANDARD_ARGB_32)->id;
+
+ free(formats);
+ }
+
+ return format;
+}
+
+static void
+ephyrRealizeARGBCursor(EphyrScrPriv *scr, CursorPtr cursor)
+{
+ ephyrCursorPtr hw = ephyrGetCursor(cursor);
+ xcb_connection_t *conn = hostx_get_xcbconn();
+ xcb_gcontext_t gc;
+ xcb_pixmap_t source;
+ xcb_render_picture_t picture;
+ xcb_image_t *image;
+ int w = cursor->bits->width, h = cursor->bits->height;
+
+ /* dix' storage is PICT_a8r8g8b8 */
+ source = xcb_generate_id(conn);
+ xcb_create_pixmap(conn, 32, source, scr->win, w, h);
+
+ gc = xcb_generate_id(conn);
+ xcb_create_gc(conn, gc, source, 0, NULL);
+ image = xcb_image_create_native(conn, w, h, XCB_IMAGE_FORMAT_Z_PIXMAP,
+ 32, NULL, ~0, NULL);
+ image->data = (void *)cursor->bits->argb;
+ xcb_image_put(conn, source, gc, image, 0, 0, 0);
+ xcb_free_gc(conn, gc);
+ xcb_image_destroy(image);
+
+ picture = xcb_generate_id(conn);
+ xcb_render_create_picture(conn, picture, source, get_argb_format(),
+ 0, NULL);
+ xcb_free_pixmap(conn, source);
+
+ hw->cursor = xcb_generate_id(conn);
+ xcb_render_create_cursor(conn, hw->cursor, picture,
+ cursor->bits->xhot, cursor->bits->yhot);
+
+ xcb_render_free_picture(conn, picture);
+}
+
+static Bool
+can_argb_cursor(void)
+{
+ static const xcb_render_query_version_reply_t *v;
+
+ if (!v)
+ v = xcb_render_util_query_version(hostx_get_xcbconn());
+
+ return v->major_version == 0 && v->minor_version >= 5;
+}
+#endif
+
+static Bool
+ephyrRealizeCursor(DeviceIntPtr dev, ScreenPtr screen, CursorPtr cursor)
+{
+ KdScreenPriv(screen);
+ KdScreenInfo *kscr = pScreenPriv->screen;
+ EphyrScrPriv *scr = kscr->driver;
+
+#ifdef ARGB_CURSOR
+ if (cursor->bits->argb && can_argb_cursor())
+ ephyrRealizeARGBCursor(scr, cursor);
+ else
+#endif
+ {
+ ephyrRealizeCoreCursor(scr, cursor);
+ }
+ return TRUE;
+}
+
+static Bool
+ephyrUnrealizeCursor(DeviceIntPtr dev, ScreenPtr screen, CursorPtr cursor)
+{
+ ephyrCursorPtr hw = ephyrGetCursor(cursor);
+
+ if (hw->cursor) {
+ xcb_free_cursor(hostx_get_xcbconn(), hw->cursor);
+ hw->cursor = None;
+ }
+
+ return TRUE;
+}
+
+static void
+ephyrSetCursor(DeviceIntPtr dev, ScreenPtr screen, CursorPtr cursor, int x,
+ int y)
+{
+ KdScreenPriv(screen);
+ KdScreenInfo *kscr = pScreenPriv->screen;
+ EphyrScrPriv *scr = kscr->driver;
+ uint32_t attr = None;
+
+ if (cursor)
+ attr = ephyrGetCursor(cursor)->cursor;
+ else
+ attr = hostx_get_empty_cursor();
+
+ xcb_change_window_attributes(hostx_get_xcbconn(), scr->win,
+ XCB_CW_CURSOR, &attr);
+ xcb_flush(hostx_get_xcbconn());
+}
+
+static void
+ephyrMoveCursor(DeviceIntPtr dev, ScreenPtr screen, int x, int y)
+{
+}
+
+static Bool
+ephyrDeviceCursorInitialize(DeviceIntPtr dev, ScreenPtr screen)
+{
+ return TRUE;
+}
+
+static void
+ephyrDeviceCursorCleanup(DeviceIntPtr dev, ScreenPtr screen)
+{
+}
+
+miPointerSpriteFuncRec EphyrPointerSpriteFuncs = {
+ ephyrRealizeCursor,
+ ephyrUnrealizeCursor,
+ ephyrSetCursor,
+ ephyrMoveCursor,
+ ephyrDeviceCursorInitialize,
+ ephyrDeviceCursorCleanup
+};
+
+Bool
+ephyrCursorInit(ScreenPtr screen)
+{
+ if (!dixRegisterPrivateKey(&ephyrCursorPrivateKey, PRIVATE_CURSOR_BITS,
+ sizeof(ephyrCursorRec)))
+ return FALSE;
+
+ miPointerInitialize(screen,
+ &EphyrPointerSpriteFuncs,
+ &ephyrPointerScreenFuncs, FALSE);
+
+ return TRUE;
+}
diff --git a/xserver/hw/kdrive/ephyr/ephyrdri.c b/xserver/hw/kdrive/ephyr/ephyrdri.c
index 16678fc5b..1e34301e1 100644
--- a/xserver/hw/kdrive/ephyr/ephyrdri.c
+++ b/xserver/hw/kdrive/ephyr/ephyrdri.c
@@ -1,8 +1,8 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
+ *
+ * Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
diff --git a/xserver/hw/kdrive/ephyr/ephyrdri.h b/xserver/hw/kdrive/ephyr/ephyrdri.h
index 8f2d3026e..b312e62d9 100644
--- a/xserver/hw/kdrive/ephyr/ephyrdri.h
+++ b/xserver/hw/kdrive/ephyr/ephyrdri.h
@@ -1,8 +1,8 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
+ *
+ * Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
diff --git a/xserver/hw/kdrive/ephyr/ephyrdriext.c b/xserver/hw/kdrive/ephyr/ephyrdriext.c
index 8368d1233..3d5cf7721 100644
--- a/xserver/hw/kdrive/ephyr/ephyrdriext.c
+++ b/xserver/hw/kdrive/ephyr/ephyrdriext.c
@@ -1,8 +1,8 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
+ *
+ * Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
diff --git a/xserver/hw/kdrive/ephyr/ephyrdriext.h b/xserver/hw/kdrive/ephyr/ephyrdriext.h
index 5808576fe..975571582 100644
--- a/xserver/hw/kdrive/ephyr/ephyrdriext.h
+++ b/xserver/hw/kdrive/ephyr/ephyrdriext.h
@@ -1,8 +1,8 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
+ *
+ * Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
diff --git a/xserver/hw/kdrive/ephyr/ephyrglxext.c b/xserver/hw/kdrive/ephyr/ephyrglxext.c
index 632a9c474..248689e6f 100644
--- a/xserver/hw/kdrive/ephyr/ephyrglxext.c
+++ b/xserver/hw/kdrive/ephyr/ephyrglxext.c
@@ -1,8 +1,8 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
+ *
+ * Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
diff --git a/xserver/hw/kdrive/ephyr/ephyrglxext.h b/xserver/hw/kdrive/ephyr/ephyrglxext.h
index 053f8d303..8b4b3a248 100644
--- a/xserver/hw/kdrive/ephyr/ephyrglxext.h
+++ b/xserver/hw/kdrive/ephyr/ephyrglxext.h
@@ -1,8 +1,8 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
+ *
+ * Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
diff --git a/xserver/hw/kdrive/ephyr/ephyrhostglx.c b/xserver/hw/kdrive/ephyr/ephyrhostglx.c
index 007524d04..0b98cce71 100644
--- a/xserver/hw/kdrive/ephyr/ephyrhostglx.c
+++ b/xserver/hw/kdrive/ephyr/ephyrhostglx.c
@@ -1,8 +1,8 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
+ *
+ * Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
diff --git a/xserver/hw/kdrive/ephyr/ephyrhostglx.h b/xserver/hw/kdrive/ephyr/ephyrhostglx.h
index 309d0f2f7..f1eec5f0b 100644
--- a/xserver/hw/kdrive/ephyr/ephyrhostglx.h
+++ b/xserver/hw/kdrive/ephyr/ephyrhostglx.h
@@ -1,8 +1,8 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
+ *
+ * Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
diff --git a/xserver/hw/kdrive/ephyr/ephyrinit.c b/xserver/hw/kdrive/ephyr/ephyrinit.c
index fac84cd13..8fbaf1d44 100644
--- a/xserver/hw/kdrive/ephyr/ephyrinit.c
+++ b/xserver/hw/kdrive/ephyr/ephyrinit.c
@@ -1,8 +1,8 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@o-hand.com>
- *
- * Copyright © 2004 Nokia
+ *
+ * Copyright © 2004 Nokia
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -33,9 +33,10 @@
extern Window EphyrPreExistingHostWin;
extern Bool EphyrWantGrayScale;
extern Bool EphyrWantResize;
+extern Bool EphyrWantNoHostGrab;
extern Bool kdHasPointer;
extern Bool kdHasKbd;
-extern Bool ephyr_glamor;
+extern Bool ephyr_glamor, ephyr_glamor_gles2;
#ifdef GLXEXT
extern Bool ephyrNoDRI;
@@ -47,8 +48,17 @@ extern KdPointerDriver LinuxEvdevMouseDriver;
extern KdKeyboardDriver LinuxEvdevKeyboardDriver;
#endif
+void processScreenOrOutputArg(const char *screen_size, const char *output, char *parent_id);
+void processOutputArg(const char *output, char *parent_id);
void processScreenArg(const char *screen_size, char *parent_id);
+int
+main(int argc, char *argv[], char *envp[])
+{
+ hostx_use_resname(basename(argv[0]), 0);
+ return dix_main(argc, argv, envp);
+}
+
void
InitCard(char *name)
{
@@ -134,10 +144,12 @@ ddxUseMsg(void)
ErrorF("-parent <XID> Use existing window as Xephyr root win\n");
ErrorF("-sw-cursor Render cursors in software in Xephyr\n");
ErrorF("-fullscreen Attempt to run Xephyr fullscreen\n");
+ ErrorF("-output <NAME> Attempt to run Xephyr fullscreen (restricted to given output geometry)\n");
ErrorF("-grayscale Simulate 8bit grayscale\n");
ErrorF("-resizeable Make Xephyr windows resizeable\n");
#ifdef GLAMOR
ErrorF("-glamor Enable 2D acceleration using glamor\n");
+ ErrorF("-glamor_gles2 Enable 2D acceleration using glamor (with GLES2 only)\n");
#endif
ErrorF
("-fakexa Simulate acceleration using software rendering\n");
@@ -149,11 +161,12 @@ ddxUseMsg(void)
ErrorF("-name [name] define the name in the WM_CLASS property\n");
ErrorF
("-title [title] set the window title in the WM_NAME property\n");
+ ErrorF("-no-host-grab Disable grabbing the keyboard and mouse.\n");
ErrorF("\n");
}
void
-processScreenArg(const char *screen_size, char *parent_id)
+processScreenOrOutputArg(const char *screen_size, const char *output, char *parent_id)
{
KdCardInfo *card;
@@ -163,6 +176,7 @@ processScreenArg(const char *screen_size, char *parent_id)
if (card) {
KdScreenInfo *screen;
unsigned long p_id = 0;
+ Bool use_geometry;
screen = KdScreenInfoAdd(card);
KdParseScreen(screen, screen_size);
@@ -173,14 +187,28 @@ processScreenArg(const char *screen_size, char *parent_id)
if (parent_id) {
p_id = strtol(parent_id, NULL, 0);
}
+
+ use_geometry = (strchr(screen_size, '+') != NULL);
EPHYR_DBG("screen number:%d\n", screen->mynum);
- hostx_add_screen(screen, p_id, screen->mynum);
+ hostx_add_screen(screen, p_id, screen->mynum, use_geometry, output);
}
else {
ErrorF("No matching card found!\n");
}
}
+void
+processScreenArg(const char *screen_size, char *parent_id)
+{
+ processScreenOrOutputArg(screen_size, NULL, parent_id);
+}
+
+void
+processOutputArg(const char *output, char *parent_id)
+{
+ processScreenOrOutputArg("100x100+0+0", output, parent_id);
+}
+
int
ddxProcessArgument(int argc, char **argv, int i)
{
@@ -188,10 +216,6 @@ 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) {
int j;
@@ -222,6 +246,15 @@ ddxProcessArgument(int argc, char **argv, int i)
UseMsg();
exit(1);
}
+ else if (!strcmp(argv[i], "-output")) {
+ if (i + 1 < argc) {
+ processOutputArg(argv[i + 1], NULL);
+ return 2;
+ }
+
+ UseMsg();
+ exit(1);
+ }
else if (!strcmp(argv[i], "-sw-cursor")) {
hostx_use_sw_cursor();
return 1;
@@ -251,6 +284,15 @@ ddxProcessArgument(int argc, char **argv, int i)
ephyrFuncs.finiAccel = ephyr_glamor_fini;
return 1;
}
+ else if (!strcmp (argv[i], "-glamor_gles2")) {
+ ephyr_glamor = TRUE;
+ ephyr_glamor_gles2 = TRUE;
+ ephyrFuncs.initAccel = ephyr_glamor_init;
+ ephyrFuncs.enableAccel = ephyr_glamor_enable;
+ ephyrFuncs.disableAccel = ephyr_glamor_disable;
+ ephyrFuncs.finiAccel = ephyr_glamor_fini;
+ return 1;
+ }
#endif
else if (!strcmp(argv[i], "-fakexa")) {
ephyrFuncs.initAccel = ephyrDrawInit;
@@ -323,6 +365,10 @@ ddxProcessArgument(int argc, char **argv, int i)
return 2;
}
/* end Xnest compat */
+ else if (!strcmp(argv[i], "-no-host-grab")) {
+ EphyrWantNoHostGrab = 1;
+ return 2;
+ }
return KdProcessArgument(argc, argv, i);
}
@@ -332,77 +378,12 @@ OsVendorInit(void)
{
EPHYR_DBG("mark");
- if (hostx_want_host_cursor()) {
+ if (hostx_want_host_cursor())
ephyrFuncs.initCursor = &ephyrCursorInit;
- ephyrFuncs.enableCursor = &ephyrCursorEnable;
- }
KdOsInit(&EphyrOsFuncs);
}
-/* 'Fake' cursor stuff, could be improved */
-
-static Bool
-ephyrRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
-{
- return TRUE;
-}
-
-static Bool
-ephyrUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
-{
- return TRUE;
-}
-
-static void
-ephyrSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x,
- int y)
-{
- ;
-}
-
-static void
-ephyrMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
-{
- ;
-}
-
-static Bool
-ephyrDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
-{
- return TRUE;
-}
-
-static void
-ephyrDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
-{
-}
-
-miPointerSpriteFuncRec EphyrPointerSpriteFuncs = {
- ephyrRealizeCursor,
- ephyrUnrealizeCursor,
- ephyrSetCursor,
- ephyrMoveCursor,
- ephyrDeviceCursorInitialize,
- ephyrDeviceCursorCleanup
-};
-
-Bool
-ephyrCursorInit(ScreenPtr pScreen)
-{
- miPointerInitialize(pScreen,
- &EphyrPointerSpriteFuncs,
- &ephyrPointerScreenFuncs, FALSE);
-
- return TRUE;
-}
-
-void
-ephyrCursorEnable(ScreenPtr pScreen)
-{
- ;
-}
-
KdCardFuncs ephyrFuncs = {
ephyrCardInit, /* cardinit */
ephyrScreenInitialize, /* scrinit */
@@ -430,4 +411,6 @@ KdCardFuncs ephyrFuncs = {
ephyrGetColors, /* getColors */
ephyrPutColors, /* putColors */
+
+ ephyrCloseScreen, /* closeScreen */
};
diff --git a/xserver/hw/kdrive/ephyr/ephyrlog.h b/xserver/hw/kdrive/ephyr/ephyrlog.h
index 0da0a2518..43679e181 100644
--- a/xserver/hw/kdrive/ephyr/ephyrlog.h
+++ b/xserver/hw/kdrive/ephyr/ephyrlog.h
@@ -1,8 +1,8 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
+ *
+ * Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
diff --git a/xserver/hw/kdrive/ephyr/ephyrvideo.c b/xserver/hw/kdrive/ephyr/ephyrvideo.c
index c6728351f..56a5ff1f8 100644
--- a/xserver/hw/kdrive/ephyr/ephyrvideo.c
+++ b/xserver/hw/kdrive/ephyr/ephyrvideo.c
@@ -1,8 +1,8 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@openedhand.com>
- *
- * Copyright © 2007 OpenedHand Ltd
+ *
+ * Copyright © 2007 OpenedHand Ltd
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -69,7 +69,7 @@ static Bool ephyrXVPrivSetAdaptorsHooks(EphyrXVPriv * a_this);
static Bool ephyrXVPrivRegisterAdaptors(EphyrXVPriv * a_this,
ScreenPtr a_screen);
-static Bool ephyrXVPrivIsAttrValueValid(KdAttributePtr a_attrs,
+static Bool ephyrXVPrivIsAttrValueValid(XvAttributePtr a_attrs,
int a_attrs_len,
const char *a_attr_name,
int a_attr_value, Bool *a_is_valid);
@@ -363,7 +363,7 @@ translate_xv_attributes(KdVideoAdaptorPtr adaptor,
it = xcb_xv_query_port_attributes_attributes_iterator(reply);
for (i = 0; i < reply->num_attributes; i++) {
- KdAttributePtr attribute = &adaptor->pAttributes[i];
+ XvAttributePtr attribute = &adaptor->pAttributes[i];
attribute->flags = it.data->flags;
attribute->min_value = it.data->min;
@@ -397,7 +397,7 @@ translate_xv_image_formats(KdVideoAdaptorPtr adaptor,
return FALSE;
adaptor->nImages = reply->num_formats;
- adaptor->pImages = calloc(reply->num_formats, sizeof(KdImageRec));
+ adaptor->pImages = calloc(reply->num_formats, sizeof(XvImageRec));
if (!adaptor->pImages) {
free(reply);
return FALSE;
@@ -405,7 +405,7 @@ translate_xv_image_formats(KdVideoAdaptorPtr adaptor,
formats = xcb_xv_list_image_formats_format(reply);
for (i = 0; i < reply->num_formats; i++) {
- KdImagePtr image = &adaptor->pImages[i];
+ XvImagePtr image = &adaptor->pImages[i];
image->id = formats[i].id;
image->type = formats[i].type;
@@ -612,11 +612,7 @@ ephyrXVPrivSetAdaptorsHooks(EphyrXVPriv * a_this)
static Bool
ephyrXVPrivRegisterAdaptors(EphyrXVPriv * a_this, ScreenPtr a_screen)
{
- KdScreenPriv(a_screen);
- KdScreenInfo *screen = pScreenPriv->screen;
Bool is_ok = FALSE;
- KdVideoAdaptorPtr *adaptors = NULL, *registered_adaptors = NULL;
- int num_registered_adaptors = 0, i = 0, num_adaptors = 0;
EPHYR_RETURN_VAL_IF_FAIL(a_this && a_screen, FALSE);
@@ -624,38 +620,22 @@ ephyrXVPrivRegisterAdaptors(EphyrXVPriv * a_this, ScreenPtr a_screen)
if (!a_this->num_adaptors)
goto out;
- num_registered_adaptors =
- KdXVListGenericAdaptors(screen, &registered_adaptors);
- num_adaptors = num_registered_adaptors + a_this->num_adaptors;
- adaptors = calloc(num_adaptors, sizeof(KdVideoAdaptorPtr));
- if (!adaptors) {
- EPHYR_LOG_ERROR("failed to allocate adaptors tab\n");
- goto out;
- }
- memmove(adaptors, registered_adaptors, num_registered_adaptors);
- for (i = 0; i < a_this->num_adaptors; i++) {
- *(adaptors + num_registered_adaptors + i) = &a_this->adaptors[i];
- }
- if (!KdXVScreenInit(a_screen, adaptors, num_adaptors)) {
+ if (!KdXVScreenInit(a_screen, a_this->adaptors, a_this->num_adaptors)) {
EPHYR_LOG_ERROR("failed to register adaptors\n");
goto out;
}
- EPHYR_LOG("there are %d registered adaptors\n", num_adaptors);
+ EPHYR_LOG("there are %d registered adaptors\n", a_this->num_adaptors);
is_ok = TRUE;
out:
- free(registered_adaptors);
- registered_adaptors = NULL;
- free(adaptors);
- adaptors = NULL;
EPHYR_LOG("leave\n");
return is_ok;
}
static Bool
-ephyrXVPrivIsAttrValueValid(KdAttributePtr a_attrs,
+ephyrXVPrivIsAttrValueValid(XvAttributePtr a_attrs,
int a_attrs_len,
const char *a_attr_name,
int a_attr_value, Bool *a_is_valid)
diff --git a/xserver/hw/kdrive/ephyr/hostx.c b/xserver/hw/kdrive/ephyr/hostx.c
index 435919e0a..71c1691c4 100644
--- a/xserver/hw/kdrive/ephyr/hostx.c
+++ b/xserver/hw/kdrive/ephyr/hostx.c
@@ -1,8 +1,8 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@o-hand.com>
- *
- * Copyright © 2004 Nokia
+ *
+ * Copyright © 2004 Nokia
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -51,6 +51,7 @@
#include <xcb/xcb_image.h>
#include <xcb/shape.h>
#include <xcb/xcb_keysyms.h>
+#include <xcb/randr.h>
#ifdef XF86DRI
#include <xcb/xf86dri.h>
#include <xcb/glx.h>
@@ -70,6 +71,8 @@ struct EphyrHostXVars {
xcb_visualtype_t *visual;
Window winroot;
xcb_gcontext_t gc;
+ xcb_render_pictformat_t argb_format;
+ xcb_cursor_t empty_cursor;
int depth;
Bool use_sw_cursor;
Bool use_fullscreen;
@@ -79,8 +82,6 @@ struct EphyrHostXVars {
KdScreenInfo **screens;
long damage_debug_msec;
-
- unsigned long cmap[256];
};
/* memset ( missing> ) instead of below */
@@ -104,12 +105,15 @@ static void
#define host_depth_matches_server(_vars) (HostX.depth == (_vars)->server_depth)
int
-hostx_want_screen_size(KdScreenInfo *screen, int *width, int *height)
+hostx_want_screen_geometry(KdScreenInfo *screen, int *width, int *height, int *x, int *y)
{
EphyrScrPriv *scrpriv = screen->driver;
if (scrpriv && (scrpriv->win_pre_existing != None ||
+ scrpriv->output != NULL ||
HostX.use_fullscreen == TRUE)) {
+ *x = scrpriv->win_x;
+ *y = scrpriv->win_y;
*width = scrpriv->win_width;
*height = scrpriv->win_height;
return 1;
@@ -119,7 +123,7 @@ hostx_want_screen_size(KdScreenInfo *screen, int *width, int *height)
}
void
-hostx_add_screen(KdScreenInfo *screen, unsigned long win_id, int screen_num)
+hostx_add_screen(KdScreenInfo *screen, unsigned long win_id, int screen_num, Bool use_geometry, const char *output)
{
EphyrScrPriv *scrpriv = screen->driver;
int index = HostX.n_screens;
@@ -131,6 +135,8 @@ hostx_add_screen(KdScreenInfo *screen, unsigned long win_id, int screen_num)
scrpriv->screen = screen;
scrpriv->win_pre_existing = win_id;
+ scrpriv->win_explicit_position = use_geometry;
+ scrpriv->output = output;
}
void
@@ -171,7 +177,7 @@ hostx_set_win_title(KdScreenInfo *screen, const char *extra_text)
memset(buf, 0, BUF_LEN + 1);
snprintf(buf, BUF_LEN, "Xephyr on %s.%d %s",
- HostX.server_dpy_name,
+ HostX.server_dpy_name ? HostX.server_dpy_name : ":0",
scrpriv->mynum, (extra_text != NULL) ? extra_text : "");
xcb_icccm_set_wm_name(HostX.conn,
@@ -196,6 +202,12 @@ hostx_use_sw_cursor(void)
HostX.use_sw_cursor = TRUE;
}
+xcb_cursor_t
+hostx_get_empty_cursor(void)
+{
+ return HostX.empty_cursor;
+}
+
int
hostx_want_preexisting_window(KdScreenInfo *screen)
{
@@ -210,6 +222,119 @@ hostx_want_preexisting_window(KdScreenInfo *screen)
}
void
+hostx_get_output_geometry(const char *output,
+ int *x, int *y,
+ int *width, int *height)
+{
+ int i, name_len = 0, output_found = FALSE;
+ char *name = NULL;
+ xcb_generic_error_t *error;
+ xcb_randr_query_version_cookie_t version_c;
+ xcb_randr_query_version_reply_t *version_r;
+ xcb_randr_get_screen_resources_cookie_t screen_resources_c;
+ xcb_randr_get_screen_resources_reply_t *screen_resources_r;
+ xcb_randr_output_t *randr_outputs;
+ xcb_randr_get_output_info_cookie_t output_info_c;
+ xcb_randr_get_output_info_reply_t *output_info_r;
+ xcb_randr_get_crtc_info_cookie_t crtc_info_c;
+ xcb_randr_get_crtc_info_reply_t *crtc_info_r;
+
+ /* First of all, check for extension */
+ if (!xcb_get_extension_data(HostX.conn, &xcb_randr_id)->present)
+ {
+ fprintf(stderr, "\nHost X server does not support RANDR extension (or it's disabled).\n");
+ exit(1);
+ }
+
+ /* Check RandR version */
+ version_c = xcb_randr_query_version(HostX.conn, 1, 2);
+ version_r = xcb_randr_query_version_reply(HostX.conn,
+ version_c,
+ &error);
+
+ if (error != NULL || version_r == NULL)
+ {
+ fprintf(stderr, "\nFailed to get RandR version supported by host X server.\n");
+ exit(1);
+ }
+ else if (version_r->major_version < 1 || version_r->minor_version < 2)
+ {
+ free(version_r);
+ fprintf(stderr, "\nHost X server doesn't support RandR 1.2, needed for -output usage.\n");
+ exit(1);
+ }
+
+ free(version_r);
+
+ /* Get list of outputs from screen resources */
+ screen_resources_c = xcb_randr_get_screen_resources(HostX.conn,
+ HostX.winroot);
+ screen_resources_r = xcb_randr_get_screen_resources_reply(HostX.conn,
+ screen_resources_c,
+ NULL);
+ randr_outputs = xcb_randr_get_screen_resources_outputs(screen_resources_r);
+
+ for (i = 0; !output_found && i < screen_resources_r->num_outputs; i++)
+ {
+ /* Get info on the output */
+ output_info_c = xcb_randr_get_output_info(HostX.conn,
+ randr_outputs[i],
+ XCB_CURRENT_TIME);
+ output_info_r = xcb_randr_get_output_info_reply(HostX.conn,
+ output_info_c,
+ NULL);
+
+ /* Get output name */
+ name_len = xcb_randr_get_output_info_name_length(output_info_r);
+ name = malloc(name_len + 1);
+ strncpy(name, (char*)xcb_randr_get_output_info_name(output_info_r), name_len);
+ name[name_len] = '\0';
+
+ if (!strcmp(name, output))
+ {
+ output_found = TRUE;
+
+ /* Check if output is connected */
+ if (output_info_r->crtc == XCB_NONE)
+ {
+ free(name);
+ free(output_info_r);
+ free(screen_resources_r);
+ fprintf(stderr, "\nOutput %s is currently disabled (or not connected).\n", output);
+ exit(1);
+ }
+
+ /* Get CRTC from output info */
+ crtc_info_c = xcb_randr_get_crtc_info(HostX.conn,
+ output_info_r->crtc,
+ XCB_CURRENT_TIME);
+ crtc_info_r = xcb_randr_get_crtc_info_reply(HostX.conn,
+ crtc_info_c,
+ NULL);
+
+ /* Get CRTC geometry */
+ *x = crtc_info_r->x;
+ *y = crtc_info_r->y;
+ *width = crtc_info_r->width;
+ *height = crtc_info_r->height;
+
+ free(crtc_info_r);
+ }
+
+ free(name);
+ free(output_info_r);
+ }
+
+ free(screen_resources_r);
+
+ if (!output_found)
+ {
+ fprintf(stderr, "\nOutput %s not available in host X server.\n", output);
+ exit(1);
+ }
+}
+
+void
hostx_use_fullscreen(void)
{
HostX.use_fullscreen = TRUE;
@@ -287,9 +412,10 @@ hostx_set_title(char *title)
int
hostx_init(void)
{
- uint32_t attr;
- xcb_cursor_t empty_cursor;
+ uint32_t attrs[2];
+ uint32_t attr_mask = 0;
xcb_pixmap_t cursor_pxm;
+ xcb_gcontext_t cursor_gc;
uint16_t red, green, blue;
uint32_t pixel;
int index;
@@ -298,8 +424,9 @@ hostx_init(void)
size_t class_len;
const xcb_query_extension_reply_t *shm_rep;
xcb_screen_t *xscreen;
+ xcb_rectangle_t rect = { 0, 0, 1, 1 };
- attr =
+ attrs[0] =
XCB_EVENT_MASK_BUTTON_PRESS
| XCB_EVENT_MASK_BUTTON_RELEASE
| XCB_EVENT_MASK_POINTER_MOTION
@@ -307,6 +434,7 @@ hostx_init(void)
| XCB_EVENT_MASK_KEY_RELEASE
| XCB_EVENT_MASK_EXPOSURE
| XCB_EVENT_MASK_STRUCTURE_NOTIFY;
+ attr_mask |= XCB_CW_EVENT_MASK;
EPHYR_DBG("mark");
#ifdef GLAMOR
@@ -315,7 +443,7 @@ hostx_init(void)
else
#endif
HostX.conn = xcb_connect(NULL, &HostX.screen);
- if (xcb_connection_has_error(HostX.conn)) {
+ if (!HostX.conn || xcb_connection_has_error(HostX.conn)) {
fprintf(stderr, "\nXephyr cannot open host display. Is DISPLAY set?\n");
exit(1);
}
@@ -325,9 +453,18 @@ hostx_init(void)
HostX.gc = xcb_generate_id(HostX.conn);
HostX.depth = xscreen->root_depth;
#ifdef GLAMOR
- if (ephyr_glamor)
+ if (ephyr_glamor) {
HostX.visual = ephyr_glamor_get_visual();
- else
+ if (HostX.visual->visual_id != xscreen->root_visual) {
+ attrs[1] = xcb_generate_id(HostX.conn);
+ attr_mask |= XCB_CW_COLORMAP;
+ xcb_create_colormap(HostX.conn,
+ XCB_COLORMAP_ALLOC_NONE,
+ attrs[1],
+ HostX.winroot,
+ HostX.visual->visual_id);
+ }
+ } else
#endif
HostX.visual = xcb_aux_find_visual_by_id(xscreen,xscreen->root_visual);
@@ -347,6 +484,8 @@ hostx_init(void)
scrpriv->win = xcb_generate_id(HostX.conn);
scrpriv->server_depth = HostX.depth;
scrpriv->ximg = NULL;
+ scrpriv->win_x = 0;
+ scrpriv->win_y = 0;
if (scrpriv->win_pre_existing != XCB_WINDOW_NONE) {
xcb_get_geometry_reply_t *prewin_geom;
@@ -379,9 +518,9 @@ hostx_init(void)
scrpriv->win_height,
0,
XCB_WINDOW_CLASS_COPY_FROM_PARENT,
- XCB_COPY_FROM_PARENT,
- XCB_CW_EVENT_MASK,
- &attr);
+ HostX.visual->visual_id,
+ attr_mask,
+ attrs);
}
else {
xcb_create_window(HostX.conn,
@@ -391,9 +530,9 @@ hostx_init(void)
0,0,100,100, /* will resize */
0,
XCB_WINDOW_CLASS_COPY_FROM_PARENT,
- XCB_COPY_FROM_PARENT,
- XCB_CW_EVENT_MASK,
- &attr);
+ HostX.visual->visual_id,
+ attr_mask,
+ attrs);
hostx_set_win_title(screen,
"(ctrl+shift grabs mouse and keyboard)");
@@ -404,6 +543,17 @@ hostx_init(void)
hostx_set_fullscreen_hint();
}
+ else if (scrpriv->output) {
+ hostx_get_output_geometry(scrpriv->output,
+ &scrpriv->win_x,
+ &scrpriv->win_y,
+ &scrpriv->win_width,
+ &scrpriv->win_height);
+
+ HostX.use_fullscreen = TRUE;
+ hostx_set_fullscreen_hint();
+ }
+
tmpstr = getenv("RESOURCE_NAME");
if (tmpstr && (!ephyrResNameFromCmd))
@@ -451,18 +601,25 @@ hostx_init(void)
xcb_change_gc(HostX.conn, HostX.gc, XCB_GC_FOREGROUND, &pixel);
+ cursor_pxm = xcb_generate_id(HostX.conn);
+ xcb_create_pixmap(HostX.conn, 1, cursor_pxm, HostX.winroot, 1, 1);
+ cursor_gc = xcb_generate_id(HostX.conn);
+ pixel = 0;
+ xcb_create_gc(HostX.conn, cursor_gc, cursor_pxm,
+ XCB_GC_FOREGROUND, &pixel);
+ xcb_poly_fill_rectangle(HostX.conn, cursor_pxm, cursor_gc, 1, &rect);
+ xcb_free_gc(HostX.conn, cursor_gc);
+ HostX.empty_cursor = xcb_generate_id(HostX.conn);
+ xcb_create_cursor(HostX.conn,
+ HostX.empty_cursor,
+ cursor_pxm, cursor_pxm,
+ 0,0,0,
+ 0,0,0,
+ 1,1);
+ xcb_free_pixmap(HostX.conn, cursor_pxm);
if (!hostx_want_host_cursor ()) {
CursorVisible = TRUE;
/* Ditch the cursor, we provide our 'own' */
- cursor_pxm = xcb_generate_id(HostX.conn);
- xcb_create_pixmap(HostX.conn, 1, cursor_pxm, HostX.winroot, 1, 1);
- empty_cursor = xcb_generate_id(HostX.conn);
- xcb_create_cursor(HostX.conn,
- empty_cursor,
- cursor_pxm, cursor_pxm,
- 0,0,0,
- 0,0,0,
- 1,1);
for (index = 0; index < HostX.n_screens; index++) {
KdScreenInfo *screen = HostX.screens[index];
EphyrScrPriv *scrpriv = screen->driver;
@@ -470,9 +627,8 @@ hostx_init(void)
xcb_change_window_attributes(HostX.conn,
scrpriv->win,
XCB_CW_CURSOR,
- &empty_cursor);
+ &HostX.empty_cursor);
}
- xcb_free_pixmap(HostX.conn, cursor_pxm);
}
/* Try to get share memory ximages for a little bit more speed */
@@ -593,9 +749,12 @@ hostx_calculate_color_shift(unsigned long mask)
}
void
-hostx_set_cmap_entry(unsigned char idx,
+hostx_set_cmap_entry(ScreenPtr pScreen, unsigned char idx,
unsigned char r, unsigned char g, unsigned char b)
{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
/* need to calculate the shifts for RGB because server could be BGR. */
/* XXX Not sure if this is correct for 8 on 16, but this works for 8 on 24.*/
static int rshift, bshift, gshift = 0;
@@ -607,7 +766,7 @@ hostx_set_cmap_entry(unsigned char idx,
gshift = hostx_calculate_color_shift(HostX.visual->green_mask);
bshift = hostx_calculate_color_shift(HostX.visual->blue_mask);
}
- HostX.cmap[idx] = ((r << rshift) & HostX.visual->red_mask) |
+ scrpriv->cmap[idx] = ((r << rshift) & HostX.visual->red_mask) |
((g << gshift) & HostX.visual->green_mask) |
((b << bshift) & HostX.visual->blue_mask);
}
@@ -626,6 +785,7 @@ hostx_set_cmap_entry(unsigned char idx,
*/
void *
hostx_screen_init(KdScreenInfo *screen,
+ int x, int y,
int width, int height, int buffer_height,
int *bytes_per_line, int *bits_per_pixel)
{
@@ -637,8 +797,8 @@ hostx_screen_init(KdScreenInfo *screen,
exit(1);
}
- EPHYR_DBG("host_screen=%p wxh=%dx%d, buffer_height=%d",
- host_screen, width, height, buffer_height);
+ EPHYR_DBG("host_screen=%p x=%d, y=%d, wxh=%dx%d, buffer_height=%d",
+ screen, x, y, width, height, buffer_height);
if (scrpriv->ximg != NULL) {
/* Free up the image data if previously used
@@ -706,6 +866,11 @@ hostx_screen_init(KdScreenInfo *screen,
~0,
NULL);
+ /* Match server byte order so that the image can be converted to
+ * the native byte order by xcb_image_put() before drawing */
+ if (host_depth_matches_server(scrpriv))
+ scrpriv->ximg->byte_order = IMAGE_BYTE_ORDER;
+
scrpriv->ximg->data =
malloc(scrpriv->ximg->stride * buffer_height);
}
@@ -729,10 +894,25 @@ hostx_screen_init(KdScreenInfo *screen,
xcb_map_window(HostX.conn, scrpriv->win);
+ /* Set explicit window position if it was informed in
+ * -screen option (WxH+X or WxH+X+Y). Otherwise, accept the
+ * position set by WM.
+ * The trick here is putting this code after xcb_map_window() call,
+ * so these values won't be overriden by WM. */
+ if (scrpriv->win_explicit_position)
+ {
+ uint32_t mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y;
+ uint32_t values[2] = {x, y};
+ xcb_configure_window(HostX.conn, scrpriv->win, mask, values);
+ }
+
+
xcb_aux_sync(HostX.conn);
scrpriv->win_width = width;
scrpriv->win_height = height;
+ scrpriv->win_x = x;
+ scrpriv->win_y = y;
#ifdef GLAMOR
if (ephyr_glamor) {
@@ -800,15 +980,15 @@ hostx_paint_rect(KdScreenInfo *screen,
hostx_paint_debug_rect(screen, dx, dy, width, height);
}
- /*
+ /*
* If the depth of the ephyr server is less than that of the host,
* the kdrive fb does not point to the ximage data but to a buffer
* ( fb_data ), we shift the various bits from this onto the XImage
* so they match the host.
*
- * Note, This code is pretty new ( and simple ) so may break on
- * endian issues, 32 bpp host etc.
- * Not sure if 8bpp case is right either.
+ * Note, This code is pretty new ( and simple ) so may break on
+ * endian issues, 32 bpp host etc.
+ * Not sure if 8bpp case is right either.
* ... and it will be slower than the matching depth case.
*/
@@ -843,7 +1023,7 @@ hostx_paint_rect(KdScreenInfo *screen,
unsigned char pixel =
*(unsigned char *) (scrpriv->fb_data + idx);
xcb_image_put_pixel(scrpriv->ximg, x, y,
- HostX.cmap[pixel]);
+ scrpriv->cmap[pixel]);
break;
}
default:
@@ -859,8 +1039,11 @@ hostx_paint_rect(KdScreenInfo *screen,
sx, sy, dx, dy, width, height, FALSE);
}
else {
- xcb_image_put(HostX.conn, scrpriv->win, HostX.gc, scrpriv->ximg,
- dx, dy, 0);
+ /* This is slow and could be done better */
+ xcb_image_t *img = xcb_image_native (HostX.conn, scrpriv->ximg, 1);
+ xcb_image_put(HostX.conn, scrpriv->win, HostX.gc, img, 0, 0, 0);
+ if (scrpriv->ximg != img)
+ xcb_image_destroy(img);
}
xcb_aux_sync(HostX.conn);
@@ -1232,10 +1415,12 @@ ephyr_glamor_init(ScreenPtr screen)
ephyr_glamor_set_window_size(scrpriv->glamor,
scrpriv->win_width, scrpriv->win_height);
- glamor_init(screen,
- GLAMOR_USE_SCREEN |
- GLAMOR_USE_PICTURE_SCREEN |
- GLAMOR_INVERTED_Y_AXIS);
+ if (!glamor_init(screen,
+ GLAMOR_USE_SCREEN |
+ GLAMOR_USE_PICTURE_SCREEN)) {
+ FatalError("Failed to initialize glamor\n");
+ return FALSE;
+ }
return TRUE;
}
diff --git a/xserver/hw/kdrive/ephyr/hostx.h b/xserver/hw/kdrive/ephyr/hostx.h
index e83323a0c..93aaa509c 100644
--- a/xserver/hw/kdrive/ephyr/hostx.h
+++ b/xserver/hw/kdrive/ephyr/hostx.h
@@ -1,8 +1,8 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@o-hand.com>
- *
- * Copyright © 2004 Nokia
+ *
+ * Copyright © 2004 Nokia
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -29,6 +29,7 @@
#include <X11/X.h>
#include <X11/Xmd.h>
#include <xcb/xcb.h>
+#include <xcb/render.h>
#include "ephyr.h"
#define EPHYR_WANT_DEBUG 0
@@ -74,7 +75,7 @@ typedef struct {
} EphyrRect;
int
-hostx_want_screen_size(KdScreenInfo *screen, int *width, int *height);
+hostx_want_screen_geometry(KdScreenInfo *screen, int *width, int *height, int *x, int *y);
int
hostx_want_host_cursor(void);
@@ -82,6 +83,14 @@ int
void
hostx_use_sw_cursor(void);
+xcb_cursor_t
+ hostx_get_empty_cursor(void);
+
+void
+ hostx_get_output_geometry(const char *output,
+ int *x, int *y,
+ int *width, int *height);
+
void
hostx_use_fullscreen(void);
@@ -107,7 +116,7 @@ int
hostx_init(void);
void
-hostx_add_screen(KdScreenInfo *screen, unsigned long win_id, int screen_num);
+hostx_add_screen(KdScreenInfo *screen, unsigned long win_id, int screen_num, Bool use_geometry, const char *output);
void
hostx_set_display_name(char *name);
@@ -132,10 +141,11 @@ hostx_get_visual_masks(KdScreenInfo *screen,
CARD32 *rmsk, CARD32 *gmsk, CARD32 *bmsk);
void
-hostx_set_cmap_entry(unsigned char idx,
+hostx_set_cmap_entry(ScreenPtr pScreen, unsigned char idx,
unsigned char r, unsigned char g, unsigned char b);
void *hostx_screen_init(KdScreenInfo *screen,
+ int x, int y,
int width, int height, int buffer_height,
int *bytes_per_line, int *bits_per_pixel);
diff --git a/xserver/hw/kdrive/ephyr/man/Makefile.in b/xserver/hw/kdrive/ephyr/man/Makefile.in
index 52091f5b0..9d49b9c7b 100644
--- a/xserver/hw/kdrive/ephyr/man/Makefile.in
+++ b/xserver/hw/kdrive/ephyr/man/Makefile.in
@@ -230,6 +230,7 @@ KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
KDRIVE_INCS = @KDRIVE_INCS@
KDRIVE_LIBS = @KDRIVE_LIBS@
KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_MAIN_LIB = @KDRIVE_MAIN_LIB@
KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
KHRONOS_OPENGL_REGISTRY_CFLAGS = @KHRONOS_OPENGL_REGISTRY_CFLAGS@
diff --git a/xserver/hw/kdrive/ephyr/man/Xephyr.man b/xserver/hw/kdrive/ephyr/man/Xephyr.man
index f14f6c864..c04379035 100644
--- a/xserver/hw/kdrive/ephyr/man/Xephyr.man
+++ b/xserver/hw/kdrive/ephyr/man/Xephyr.man
@@ -63,6 +63,9 @@ improvement is negligible.
.B -resizeable
Allow the Xephyr window to be resized, even if not embedded into a parent
window. By default, the Xephyr window has a fixed size.
+.TP 8
+.B -no-host-grab
+Disable grabbing the keyboard and mouse.
.SH "SIGNALS"
Send a SIGUSR1 to the server (e.g. pkill -USR1 Xephyr) to
toggle the debugging mode.
diff --git a/xserver/hw/kdrive/ephyr/os.c b/xserver/hw/kdrive/ephyr/os.c
index 56b52d143..0dbcbb883 100644
--- a/xserver/hw/kdrive/ephyr/os.c
+++ b/xserver/hw/kdrive/ephyr/os.c
@@ -1,8 +1,8 @@
/*
* Xephyr - A kdrive X server thats runs in a host X window.
* Authored by Matthew Allum <mallum@o-hand.com>
- *
- * Copyright © 2004 Nokia
+ *
+ * Copyright © 2004 Nokia
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that