Last active
August 29, 2015 14:06
-
-
Save saitoha/5623535ade7bd27521ea to your computer and use it in GitHub Desktop.
Rebase xserver-xsdl to current xserver master HEAD(3a51418b)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/build-xsdl.sh b/build-xsdl.sh | |
new file mode 100755 | |
index 0000000..61c2077 | |
--- /dev/null | |
+++ b/build-xsdl.sh | |
@@ -0,0 +1,46 @@ | |
+#!/bin/sh | |
+ | |
+x11prefix=/opt/X11 | |
+ | |
+env SDL=yes CFLAGS="-O3 -Ofast" \ | |
+./autogen.sh \ | |
+ --prefix=${x11prefix} \ | |
+ --with-xkb-path=${x11prefix}/share/X11/xkb \ | |
+ --with-xkb-bin-directory=${x11prefix}/bin \ | |
+ --enable-debug \ | |
+ --disable-xorg \ | |
+ --disable-dmx \ | |
+ --disable-xvfb \ | |
+ --disable-xnest \ | |
+ --disable-xquartz \ | |
+ --disable-xwin \ | |
+ --disable-xephyr \ | |
+ --disable-xfake \ | |
+ --disable-xfbdev \ | |
+ --disable-unit-tests \ | |
+ --enable-mitshm \ | |
+ --disable-dri \ | |
+ --disable-dri2 \ | |
+ --disable-dri3 \ | |
+ --disable-present \ | |
+ --disable-glx \ | |
+ --disable-xf86vidmode \ | |
+ --disable-xquartz \ | |
+ --disable-composite \ | |
+ --disable-xv \ | |
+ --disable-dga \ | |
+ --disable-screensaver \ | |
+ --disable-xdmcp \ | |
+ --disable-xdm-auth-1 \ | |
+ --disable-xinerama \ | |
+ --disable-docs \ | |
+ --enable-xsdl \ | |
+ --enable-kdrive \ | |
+ --disable-kdrive-kbd \ | |
+ --disable-kdrive-mouse \ | |
+ --disable-kdrive-evdev \ | |
+ | |
+nice -n19 make -j8 | |
+ | |
+# run: | |
+# hw/kdrive/sdl/Xsdl :1 2>/dev/null | |
diff --git a/configure.ac b/configure.ac | |
index cba7d24..176ad2b 100644 | |
--- a/configure.ac | |
+++ b/configure.ac | |
@@ -642,6 +642,7 @@ AC_ARG_ENABLE(glamor, AS_HELP_STRING([--enable-glamor], [Build glamor di | |
dnl kdrive and its subsystems | |
AC_ARG_ENABLE(kdrive, AS_HELP_STRING([--enable-kdrive], [Build kdrive servers (default: no)]), [KDRIVE=$enableval], [KDRIVE=no]) | |
AC_ARG_ENABLE(xephyr, AS_HELP_STRING([--enable-xephyr], [Build the kdrive Xephyr server (default: auto)]), [XEPHYR=$enableval], [XEPHYR=auto]) | |
+AC_ARG_ENABLE(xsdl, AS_HELP_STRING([--enable-xsdl], [Build the kdrive Xsdl server (default: auto)]), [XSDL=$enableval], [XSDL=auto]) | |
AC_ARG_ENABLE(xfake, AS_HELP_STRING([--enable-xfake], [Build the kdrive 'fake' server (default: auto)]), [XFAKE=$enableval], [XFAKE=auto]) | |
AC_ARG_ENABLE(xfbdev, AS_HELP_STRING([--enable-xfbdev], [Build the kdrive framebuffer device server (default: auto)]), [XFBDEV=$enableval], [XFBDEV=auto]) | |
dnl kdrive options | |
@@ -2316,6 +2317,9 @@ dnl kdrive DDX | |
XEPHYR_LIBS= | |
XEPHYR_INCS= | |
+XSDL_LIBS= | |
+XSDL_INCS= | |
+XSDL_DIRS= | |
AM_CONDITIONAL(KDRIVE, [test x$KDRIVE = xyes]) | |
@@ -2364,6 +2368,18 @@ if test "$KDRIVE" = yes; then | |
AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver]) | |
fi | |
+ AC_CHECK_HEADERS([SDL/SDL.h]) | |
+ if test x"$ac_cv_header_SDL_SDL_h" = xyes && test "x$XSDL" = xauto; then | |
+ XSDL=yes | |
+ fi | |
+ | |
+ if test x"$XSDL" = xyes; then | |
+ # PKG_CHECK_MODULES(XSDL_EXTRA, Xfont xau $XDMCP_MODULES) | |
+ AC_DEFINE(XSDLSERVER,1,[Build Xsdl server]) | |
+ XSDL_LIBS="`sdl-config --libs`" | |
+ XSDL_INCS="`sdl-config --cflags` $XSERVER_CFLAGS" | |
+ fi | |
+ | |
XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr" | |
if test "x$XV" = xyes; then | |
XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS xcb-xv" | |
@@ -2428,6 +2444,8 @@ if test "$KDRIVE" = yes; then | |
AC_SUBST([XEPHYR_LIBS]) | |
AC_SUBST([XEPHYR_INCS]) | |
+ AC_SUBST([XSDL_LIBS]) | |
+ AC_SUBST([XSDL_INCS]) | |
fi | |
AC_SUBST([KDRIVE_INCS]) | |
AC_SUBST([KDRIVE_PURE_INCS]) | |
@@ -2441,6 +2459,7 @@ AM_CONDITIONAL(KDRIVE_KBD, [test "x$KDRIVE_KBD" = xyes]) | |
AM_CONDITIONAL(KDRIVE_MOUSE, [test "x$KDRIVE_MOUSE" = xyes]) | |
AM_CONDITIONAL(TSLIB, [test "x$HAVE_TSLIB" = xyes]) | |
AM_CONDITIONAL(KDRIVEFBDEV, [test "x$XFBDEV" = xyes]) | |
+AM_CONDITIONAL(XSDLSERVER, [test "x$XSDL" = xyes]) | |
AM_CONDITIONAL(XEPHYR, [test "x$KDRIVE" = xyes && test "x$XEPHYR" = xyes]) | |
AM_CONDITIONAL(BUILD_KDRIVEFBDEVLIB, [test "x$KDRIVE" = xyes && test "x$KDRIVEFBDEVLIB" = xyes]) | |
AM_CONDITIONAL(XFAKESERVER, [test "x$KDRIVE" = xyes && test "x$XFAKE" = xyes]) | |
@@ -2609,6 +2628,7 @@ hw/xquartz/xpr/Makefile | |
hw/kdrive/Makefile | |
hw/kdrive/ephyr/Makefile | |
hw/kdrive/ephyr/man/Makefile | |
+hw/kdrive/sdl/Makefile | |
hw/kdrive/fake/Makefile | |
hw/kdrive/fbdev/Makefile | |
hw/kdrive/linux/Makefile | |
diff --git a/dix/Makefile.am b/dix/Makefile.am | |
index e7ca236..6c9e1cb 100644 | |
--- a/dix/Makefile.am | |
+++ b/dix/Makefile.am | |
@@ -47,7 +47,6 @@ EXTRA_DIST = buildatoms BuiltInAtoms Xserver.d Xserver-dtrace.h.in | |
# Install list of protocol names | |
miscconfigdir = $(SERVER_MISC_CONFIG_PATH) | |
-dist_miscconfig_DATA = protocol.txt | |
if XSERVER_DTRACE | |
# Generate dtrace header file for C sources to include | |
diff --git a/hw/kdrive/Makefile.am b/hw/kdrive/Makefile.am | |
index 471ca89..377127e 100644 | |
--- a/hw/kdrive/Makefile.am | |
+++ b/hw/kdrive/Makefile.am | |
@@ -6,6 +6,10 @@ if XFAKESERVER | |
XFAKE_SUBDIRS = fake | |
endif | |
+if XSDLSERVER | |
+XSDL_SUBDIRS = sdl | |
+endif | |
+ | |
if XEPHYR | |
XEPHYR_SUBDIRS = ephyr | |
endif | |
@@ -15,6 +19,7 @@ LINUX_SUBDIRS = linux | |
endif | |
SERVER_SUBDIRS = \ | |
+ $(XSDL_SUBDIRS) \ | |
$(FBDEV_SUBDIRS) \ | |
$(XEPHYR_SUBDIRS) \ | |
$(XFAKE_SUBDIRS) | |
@@ -24,7 +29,7 @@ SUBDIRS = \ | |
$(LINUX_SUBDIRS) \ | |
$(SERVER_SUBDIRS) | |
-DIST_SUBDIRS = fbdev ephyr src linux fake | |
+DIST_SUBDIRS = fbdev sdl ephyr src linux fake | |
relink: | |
$(AM_V_at)for i in $(SERVER_SUBDIRS) ; do $(MAKE) -C $$i relink || exit 1 ; done | |
diff --git a/hw/kdrive/sdl/Makefile.am b/hw/kdrive/sdl/Makefile.am | |
new file mode 100644 | |
index 0000000..b08acaf | |
--- /dev/null | |
+++ b/hw/kdrive/sdl/Makefile.am | |
@@ -0,0 +1,19 @@ | |
+INCLUDES = \ | |
+ @KDRIVE_PURE_INCS@ \ | |
+ @KDRIVE_CFLAGS@ \ | |
+ @XSDL_INCS@ | |
+ | |
+bin_PROGRAMS = Xsdl | |
+ | |
+Xsdl_SOURCES = sdl.c | |
+ | |
+Xsdl_LDADD = \ | |
+ @KDRIVE_LIBS@ \ | |
+ @XSDL_LIBS@ | |
+ | |
+Xsdl_DEPENDENCIES = @KDRIVE_LOCAL_LIBS@ | |
+ | |
+Xsdl_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG) | |
+ | |
+relink: | |
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS) | |
diff --git a/hw/kdrive/sdl/sdl.c b/hw/kdrive/sdl/sdl.c | |
new file mode 100644 | |
index 0000000..a6d262d | |
--- /dev/null | |
+++ b/hw/kdrive/sdl/sdl.c | |
@@ -0,0 +1,697 @@ | |
+/* | |
+ * Copyright © 2004 PillowElephantBadgerBankPond | |
+ * Copyright © 2014 Sergii Pylypenko | |
+ * | |
+ * Permission to use, copy, modify, distribute, and sell this software and its | |
+ * documentation for any purpose is hereby granted without fee, provided that | |
+ * the above copyright notice appear in all copies and that both that | |
+ * copyright notice and this permission notice appear in supporting | |
+ * documentation, and that the name of PillowElephantBadgerBankPond not be used in | |
+ * advertising or publicity pertaining to distribution of the software without | |
+ * specific, written prior permission. PillowElephantBadgerBankPond makes no | |
+ * representations about the suitability of this software for any purpose. It | |
+ * is provided "as is" without express or implied warranty. | |
+ * | |
+ * PillowElephantBadgerBankPond DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | |
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO | |
+ * EVENT SHALL PillowElephantBadgerBankPond BE LIABLE FOR ANY SPECIAL, INDIRECT OR | |
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, | |
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | |
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | |
+ * PERFORMANCE OF THIS SOFTWARE. | |
+ * | |
+ * It's really not my fault - see it was the elephants!! | |
+ * - jaymz | |
+ * | |
+ */ | |
+#ifdef HAVE_CONFIG_H | |
+#include "kdrive-config.h" | |
+#endif | |
+#include "kdrive.h" | |
+#include <SDL/SDL.h> | |
+#include <X11/keysym.h> | |
+#include <sys/wait.h> | |
+#include <pthread.h> | |
+ | |
+ | |
+static void xsdlFini(void); | |
+static Bool sdlScreenInit(KdScreenInfo *screen); | |
+static Bool sdlFinishInitScreen(ScreenPtr pScreen); | |
+static Bool sdlCreateRes(ScreenPtr pScreen); | |
+static Bool sdlMapFramebuffer (KdScreenInfo *screen); | |
+ | |
+static void sdlKeyboardFini(KdKeyboardInfo *ki); | |
+static Status sdlKeyboardInit(KdKeyboardInfo *ki); | |
+static Status sdlKeyboardEnable (KdKeyboardInfo *ki); | |
+static void sdlKeyboardDisable (KdKeyboardInfo *ki); | |
+static void sdlKeyboardLeds (KdKeyboardInfo *ki, int leds); | |
+static void sdlKeyboardBell (KdKeyboardInfo *ki, int volume, int frequency, int duration); | |
+ | |
+static Bool sdlMouseInit(KdPointerInfo *pi); | |
+static void sdlMouseFini(KdPointerInfo *pi); | |
+static Status sdlMouseEnable (KdPointerInfo *pi); | |
+static void sdlMouseDisable (KdPointerInfo *pi); | |
+ | |
+KdKeyboardInfo *sdlKeyboard = NULL; | |
+KdPointerInfo *sdlPointer = NULL; | |
+ | |
+//#define DEBUG 1 | |
+ | |
+#if DEBUG | |
+#define TRACE(s) printf(s) | |
+#define TRACE1(s, arg1) printf(s, arg1) | |
+#define TRACE2(s, arg1, arg2) printf(s, arg1, arg2) | |
+#define TRACE3(s, arg1, arg2, arg3) printf(s, arg1, arg2, arg3) | |
+#define TRACE4(s, arg1, arg2, arg3, arg4) printf(s, arg1, arg2, arg3, arg4) | |
+#define TRACE5(s, arg1, arg2, arg3, arg4, arg5) printf(s, arg1, arg2, arg3, arg4, arg5) | |
+#else | |
+#define TRACE(s) | |
+#define TRACE1(s, arg1) | |
+#define TRACE2(s, arg1, arg2) | |
+#define TRACE3(s, arg1, arg2, arg3) | |
+#define TRACE4(s, arg1, arg2, arg3, arg4) | |
+#define TRACE5(s, arg1, arg2, arg3, arg4, arg5) | |
+#endif | |
+ | |
+KdKeyboardDriver sdlKeyboardDriver = { | |
+ .name = "keyboard", | |
+ .Init = sdlKeyboardInit, | |
+ .Fini = sdlKeyboardFini, | |
+ .Enable = sdlKeyboardEnable, | |
+ .Disable = sdlKeyboardDisable, | |
+ .Leds = sdlKeyboardLeds, | |
+ .Bell = sdlKeyboardBell, | |
+}; | |
+ | |
+KdPointerDriver sdlMouseDriver = { | |
+ .name = "mouse", | |
+ .Init = sdlMouseInit, | |
+ .Fini = sdlMouseFini, | |
+ .Enable = sdlMouseEnable, | |
+ .Disable = sdlMouseDisable, | |
+}; | |
+ | |
+ | |
+KdCardFuncs sdlFuncs = { | |
+ .scrinit = sdlScreenInit, /* scrinit */ | |
+ .finishInitScreen = sdlFinishInitScreen, /* finishInitScreen */ | |
+ .createRes = sdlCreateRes, /* createRes */ | |
+}; | |
+ | |
+int mouseState = 0; | |
+ | |
+enum { NUMRECTS = 32, FULLSCREEN_REFRESH_TIME = 1000 }; | |
+//Uint32 nextFullScreenRefresh = 0; | |
+ | |
+typedef struct | |
+{ | |
+ SDL_Surface *screen; | |
+ Rotation randr; | |
+ Bool shadow; | |
+} SdlDriver; | |
+ | |
+//#undef RANDR | |
+ | |
+Bool | |
+sdlMapFramebuffer (KdScreenInfo *screen) | |
+{ | |
+ SdlDriver *driver = screen->driver; | |
+ KdPointerMatrix m; | |
+ | |
+ if (driver->randr != RR_Rotate_0) | |
+ driver->shadow = TRUE; | |
+ else | |
+ driver->shadow = FALSE; | |
+ | |
+ KdComputePointerMatrix (&m, driver->randr, screen->width, screen->height); | |
+ | |
+ KdSetPointerMatrix (&m); | |
+ | |
+ screen->width = driver->screen->w; | |
+ screen->height = driver->screen->h; | |
+ | |
+ TRACE2("%s: shadow %d\n", __func__, driver->shadow); | |
+ | |
+ if (driver->shadow) | |
+ { | |
+ if (!KdShadowFbAlloc (screen, | |
+ driver->randr & (RR_Rotate_90|RR_Rotate_270))) | |
+ return FALSE; | |
+ } | |
+ else | |
+ { | |
+ screen->fb.byteStride = driver->screen->pitch; | |
+ screen->fb.pixelStride = driver->screen->w; | |
+ screen->fb.frameBuffer = (CARD8 *) (driver->screen->pixels); | |
+ } | |
+ | |
+ return TRUE; | |
+} | |
+ | |
+static void | |
+sdlSetScreenSizes (ScreenPtr pScreen) | |
+{ | |
+ KdScreenPriv(pScreen); | |
+ KdScreenInfo *screen = pScreenPriv->screen; | |
+ SdlDriver *driver = screen->driver; | |
+ | |
+ if (driver->randr & (RR_Rotate_0|RR_Rotate_180)) | |
+ { | |
+ pScreen->width = driver->screen->w; | |
+ pScreen->height = driver->screen->h; | |
+ pScreen->mmWidth = screen->width_mm; | |
+ pScreen->mmHeight = screen->height_mm; | |
+ } | |
+ else | |
+ { | |
+ pScreen->width = driver->screen->h; | |
+ pScreen->height = driver->screen->w; | |
+ pScreen->mmWidth = screen->height_mm; | |
+ pScreen->mmHeight = screen->width_mm; | |
+ } | |
+} | |
+ | |
+static Bool | |
+sdlUnmapFramebuffer (KdScreenInfo *screen) | |
+{ | |
+ KdShadowFbFree (screen); | |
+ return TRUE; | |
+} | |
+ | |
+static Bool sdlScreenInit(KdScreenInfo *screen) | |
+{ | |
+ SdlDriver *driver=calloc(1, sizeof(SdlDriver)); | |
+ | |
+ TRACE1("%s\n", __func__); | |
+ | |
+ if (!screen->width || !screen->height) | |
+ { | |
+ screen->width = 640; | |
+ screen->height = 480; | |
+ } | |
+ if (!screen->fb.depth) | |
+ screen->fb.depth = 16; | |
+ | |
+ TRACE3("Attempting for %dx%d/%dbpp mode\n", screen->width, screen->height, screen->fb.depth); | |
+ | |
+ driver->screen = SDL_SetVideoMode(screen->width, screen->height, screen->fb.depth, 0); | |
+ if(driver->screen == NULL) | |
+ return FALSE; | |
+ driver->randr = screen->randr; | |
+ screen->driver = driver; | |
+ | |
+ TRACE3("Set %dx%d/%dbpp mode\n", driver->screen->w, driver->screen->h, driver->screen->format->BitsPerPixel); | |
+ | |
+ screen->width = driver->screen->w; | |
+ screen->height = driver->screen->h; | |
+ screen->fb.depth = driver->screen->format->BitsPerPixel; | |
+ screen->fb.visuals = (1<<TrueColor); | |
+ screen->fb.redMask = driver->screen->format->Rmask; | |
+ screen->fb.greenMask = driver->screen->format->Gmask; | |
+ screen->fb.blueMask = driver->screen->format->Bmask; | |
+ screen->fb.bitsPerPixel = driver->screen->format->BitsPerPixel; | |
+ //screen->fb.shadow = FALSE; | |
+ screen->rate = 8; // 60 is too intense for CPU | |
+ | |
+ SDL_WM_SetCaption("Freedesktop.org X server (SDL)", NULL); | |
+ | |
+ SDL_EnableUNICODE(1); | |
+ | |
+ return sdlMapFramebuffer (screen); | |
+} | |
+ | |
+static void sdlShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf) | |
+{ | |
+ KdScreenPriv(pScreen); | |
+ KdScreenInfo *screen = pScreenPriv->screen; | |
+ SdlDriver *driver = screen->driver; | |
+ pixman_box16_t * rects; | |
+ int amount, i; | |
+ int updateRectsPixelCount = 0; | |
+ | |
+ if (driver->shadow) | |
+ { | |
+ shadowUpdatePacked(pScreen, pBuf); | |
+ } | |
+ | |
+ rects = pixman_region_rectangles(&pBuf->pDamage->damage, &amount); | |
+ for ( i = 0; i < amount; i++ ) | |
+ { | |
+ updateRectsPixelCount += (pBuf->pDamage->damage.extents.x2 - pBuf->pDamage->damage.extents.x1) * | |
+ (pBuf->pDamage->damage.extents.y2 - pBuf->pDamage->damage.extents.y1); | |
+ } | |
+ // Each subrect is copied into temp buffer before uploading to OpenGL texture, | |
+ // so if total area of pixels copied is more than 1/3 of the whole screen area, | |
+ // there will be performance hit instead of optimization. | |
+ | |
+ if ( amount > NUMRECTS || updateRectsPixelCount * 3 > driver->screen->w * driver->screen->h ) | |
+ { | |
+ SDL_Flip(driver->screen); | |
+ //nextFullScreenRefresh = 0; | |
+ } | |
+ else | |
+ { | |
+ SDL_Rect updateRects[NUMRECTS]; | |
+ //if ( ! nextFullScreenRefresh ) | |
+ // nextFullScreenRefresh = SDL_GetTicks() + FULLSCREEN_REFRESH_TIME; | |
+ for ( i = 0; i < amount; i++ ) | |
+ { | |
+ updateRects[i].x = rects[i].x1; | |
+ updateRects[i].y = rects[i].y1; | |
+ updateRects[i].w = rects[i].x2 - rects[i].x1; | |
+ updateRects[i].h = rects[i].y2 - rects[i].y1; | |
+ } | |
+ SDL_UpdateRects(driver->screen, amount, updateRects); | |
+ } | |
+} | |
+ | |
+static void *sdlShadowWindow (ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, CARD32 *size, void *closure) | |
+{ | |
+ KdScreenPriv(pScreen); | |
+ KdScreenInfo *screen = pScreenPriv->screen; | |
+ SdlDriver *driver = screen->driver; | |
+ | |
+// if (!pScreenPriv->enabled) | |
+// return NULL; | |
+ | |
+ *size = driver->screen->pitch; | |
+ | |
+ TRACE1("%s\n", __func__); | |
+ | |
+ return (void *)((CARD8 *)driver->screen->pixels + row * (*size) + offset); | |
+} | |
+ | |
+ | |
+static Bool sdlCreateRes(ScreenPtr pScreen) | |
+{ | |
+ KdScreenPriv(pScreen); | |
+ KdScreenInfo *screen = pScreenPriv->screen; | |
+ SdlDriver *driver = screen->driver; | |
+ Bool oldShadow = screen->fb.shadow; | |
+ | |
+ TRACE1("%s\n", __func__); | |
+ | |
+ // Hack: Kdrive assumes we have dumb videobuffer, which updates automatically, | |
+ // and does not call update callback if shadow flag is not set. | |
+ screen->fb.shadow = TRUE; | |
+ KdShadowSet (pScreen, driver->randr, sdlShadowUpdate, sdlShadowWindow); | |
+ screen->fb.shadow = oldShadow; | |
+ | |
+ return TRUE; | |
+} | |
+ | |
+ | |
+#ifdef RANDR | |
+static Bool sdlRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) | |
+{ | |
+ KdScreenPriv(pScreen); | |
+ KdScreenInfo *screen = pScreenPriv->screen; | |
+ SdlDriver *driver = screen->driver; | |
+ RRScreenSizePtr pSize; | |
+ Rotation randr; | |
+ int n; | |
+ | |
+ TRACE1("%s", __func__); | |
+ | |
+ *rotations = RR_Rotate_All|RR_Reflect_All; | |
+ | |
+ for (n = 0; n < pScreen->numDepths; n++) | |
+ if (pScreen->allowedDepths[n].numVids) | |
+ break; | |
+ if (n == pScreen->numDepths) | |
+ return FALSE; | |
+ | |
+ pSize = RRRegisterSize (pScreen, | |
+ screen->width, | |
+ screen->height, | |
+ screen->width_mm, | |
+ screen->height_mm); | |
+ | |
+ randr = KdSubRotation (driver->randr, screen->randr); | |
+ | |
+ RRSetCurrentConfig (pScreen, randr, 0, pSize); | |
+ | |
+ return TRUE; | |
+} | |
+ | |
+static Bool sdlRandRSetConfig (ScreenPtr pScreen, | |
+ Rotation randr, | |
+ int rate, | |
+ RRScreenSizePtr pSize) | |
+{ | |
+ KdScreenPriv(pScreen); | |
+ KdScreenInfo *screen = pScreenPriv->screen; | |
+ SdlDriver *driver = screen->driver; | |
+ Bool wasEnabled = pScreenPriv->enabled; | |
+ SdlDriver oldDriver; | |
+ int oldwidth; | |
+ int oldheight; | |
+ int oldmmwidth; | |
+ int oldmmheight; | |
+ | |
+ if (wasEnabled) | |
+ KdDisableScreen (pScreen); | |
+ | |
+ oldDriver = *driver; | |
+ | |
+ oldwidth = screen->width; | |
+ oldheight = screen->height; | |
+ oldmmwidth = pScreen->mmWidth; | |
+ oldmmheight = pScreen->mmHeight; | |
+ | |
+ /* | |
+ * Set new configuration | |
+ */ | |
+ | |
+ driver->randr = KdAddRotation (screen->randr, randr); | |
+ | |
+ TRACE2("%s driver->randr %d", __func__, driver->randr); | |
+ | |
+ sdlUnmapFramebuffer (screen); | |
+ | |
+ if (!sdlMapFramebuffer (screen)) | |
+ goto bail4; | |
+ | |
+ KdShadowUnset (screen->pScreen); | |
+ | |
+ if (!sdlCreateRes (screen->pScreen)) | |
+ goto bail4; | |
+ | |
+ sdlSetScreenSizes (screen->pScreen); | |
+ | |
+ /* | |
+ * Set frame buffer mapping | |
+ */ | |
+ (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen), | |
+ pScreen->width, | |
+ pScreen->height, | |
+ screen->fb.depth, | |
+ screen->fb.bitsPerPixel, | |
+ screen->fb.byteStride, | |
+ screen->fb.frameBuffer); | |
+ | |
+ /* set the subpixel order */ | |
+ | |
+ KdSetSubpixelOrder (pScreen, driver->randr); | |
+ if (wasEnabled) | |
+ KdEnableScreen (pScreen); | |
+ | |
+ return TRUE; | |
+ | |
+bail4: | |
+ sdlUnmapFramebuffer (screen); | |
+ *driver = oldDriver; | |
+ (void) sdlMapFramebuffer (screen); | |
+ pScreen->width = oldwidth; | |
+ pScreen->height = oldheight; | |
+ pScreen->mmWidth = oldmmwidth; | |
+ pScreen->mmHeight = oldmmheight; | |
+ | |
+ if (wasEnabled) | |
+ KdEnableScreen (pScreen); | |
+ return FALSE; | |
+} | |
+ | |
+static Bool sdlRandRInit (ScreenPtr pScreen) | |
+{ | |
+ rrScrPrivPtr pScrPriv; | |
+ | |
+ TRACE1("%s", __func__); | |
+ | |
+ if (!RRScreenInit (pScreen)) | |
+ return FALSE; | |
+ | |
+ pScrPriv = rrGetScrPriv(pScreen); | |
+ pScrPriv->rrGetInfo = sdlRandRGetInfo; | |
+ pScrPriv->rrSetConfig = sdlRandRSetConfig; | |
+ return TRUE; | |
+} | |
+#endif | |
+ | |
+ | |
+static Bool sdlFinishInitScreen(ScreenPtr pScreen) | |
+{ | |
+ if (!shadowSetup (pScreen)) | |
+ return FALSE; | |
+ | |
+#ifdef RANDR | |
+ if (!sdlRandRInit (pScreen)) | |
+ return FALSE; | |
+#endif | |
+ return TRUE; | |
+} | |
+ | |
+static void sdlKeyboardFini(KdKeyboardInfo *ki) | |
+{ | |
+ TRACE1("sdlKeyboardFini() %p\n", ki); | |
+ sdlKeyboard = NULL; | |
+} | |
+ | |
+static Status sdlKeyboardInit(KdKeyboardInfo *ki) | |
+{ | |
+ ki->minScanCode = 8; | |
+ ki->maxScanCode = 255; | |
+ ki->name = strdup("mlterm keyboard"); | |
+ | |
+ sdlKeyboard = ki; | |
+ TRACE1("sdlKeyboardInit() %p\n", ki); | |
+ return Success; | |
+} | |
+ | |
+static Status sdlKeyboardEnable (KdKeyboardInfo *ki) | |
+{ | |
+ return Success; | |
+} | |
+ | |
+static void sdlKeyboardDisable (KdKeyboardInfo *ki) | |
+{ | |
+} | |
+ | |
+static void sdlKeyboardLeds (KdKeyboardInfo *ki, int leds) | |
+{ | |
+} | |
+ | |
+static void sdlKeyboardBell (KdKeyboardInfo *ki, int volume, int frequency, int duration) | |
+{ | |
+} | |
+ | |
+static Status sdlMouseInit (KdPointerInfo *pi) | |
+{ | |
+ pi->nButtons = 7; | |
+ pi->name = strdup("Android touchscreen and stylus"); | |
+ sdlPointer = pi; | |
+ TRACE1("sdlMouseInit() %p\n", pi); | |
+ return Success; | |
+} | |
+ | |
+static void sdlMouseFini(KdPointerInfo *pi) | |
+{ | |
+ TRACE1("sdlMouseFini() %p\n", pi); | |
+ sdlPointer = NULL; | |
+} | |
+ | |
+static Status sdlMouseEnable (KdPointerInfo *pi) | |
+{ | |
+ /* TODO */ | |
+ return Success; | |
+} | |
+ | |
+static void sdlMouseDisable (KdPointerInfo *pi) | |
+{ | |
+ /* TODO */ | |
+ return; | |
+} | |
+ | |
+ | |
+void InitCard(char *name) | |
+{ | |
+ KdCardInfoAdd (&sdlFuncs, 0); | |
+ TRACE1("InitCard: %s\n", name); | |
+} | |
+ | |
+void InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) | |
+{ | |
+ KdInitOutput(pScreenInfo, argc, argv); | |
+ TRACE("InitOutput()\n"); | |
+} | |
+ | |
+void InitInput(int argc, char **argv) | |
+{ | |
+ KdPointerInfo *pi; | |
+ KdKeyboardInfo *ki; | |
+ | |
+ KdAddKeyboardDriver(&sdlKeyboardDriver); | |
+ KdAddPointerDriver(&sdlMouseDriver); | |
+ | |
+ ki = KdParseKeyboard("keyboard"); | |
+ KdAddKeyboard(ki); | |
+ pi = KdParsePointer("mouse"); | |
+ KdAddPointer(pi); | |
+ | |
+ KdInitInput(); | |
+} | |
+ | |
+#ifdef DDXBEFORERESET | |
+void ddxBeforeReset(void) | |
+{ | |
+} | |
+#endif | |
+ | |
+void ddxUseMsg(void) | |
+{ | |
+ KdUseMsg(); | |
+} | |
+ | |
+int ddxProcessArgument(int argc, char **argv, int i) | |
+{ | |
+ return KdProcessArgument(argc, argv, i); | |
+} | |
+ | |
+static void sdlPollInput(void) | |
+{ | |
+ static int buttonState=0; | |
+ static int pressure = 0; | |
+ SDL_Event event; | |
+ | |
+ while ( SDL_PollEvent(&event) ) { | |
+ switch (event.type) { | |
+ case SDL_MOUSEMOTION: | |
+ KdEnqueuePointerEvent(sdlPointer, mouseState, event.motion.x, event.motion.y, pressure); | |
+ break; | |
+ case SDL_MOUSEBUTTONDOWN: | |
+ switch(event.button.button) | |
+ { | |
+ case SDL_BUTTON_LEFT: | |
+ buttonState = KD_BUTTON_1; | |
+ break; | |
+ case SDL_BUTTON_MIDDLE: | |
+ buttonState = KD_BUTTON_2; | |
+ break; | |
+ case SDL_BUTTON_RIGHT: | |
+ buttonState = KD_BUTTON_3; | |
+ break; | |
+ case SDL_BUTTON_WHEELUP: | |
+ buttonState = KD_BUTTON_4; | |
+ break; | |
+ case SDL_BUTTON_WHEELDOWN: | |
+ buttonState = KD_BUTTON_5; | |
+ break; | |
+ /* | |
+ case SDL_BUTTON_X1: | |
+ buttonState = KD_BUTTON_6; | |
+ break; | |
+ case SDL_BUTTON_X2: | |
+ buttonState = KD_BUTTON_7; | |
+ break; | |
+ */ | |
+ default: | |
+ buttonState = 1 << (event.button.button - 1); | |
+ break; | |
+ } | |
+ mouseState |= buttonState; | |
+ KdEnqueuePointerEvent(sdlPointer, mouseState|KD_MOUSE_DELTA, 0, 0, pressure); | |
+ break; | |
+ case SDL_MOUSEBUTTONUP: | |
+ switch(event.button.button) | |
+ { | |
+ case SDL_BUTTON_LEFT: | |
+ buttonState = KD_BUTTON_1; | |
+ pressure = 0; | |
+ break; | |
+ case SDL_BUTTON_MIDDLE: | |
+ buttonState = KD_BUTTON_2; | |
+ break; | |
+ case SDL_BUTTON_RIGHT: | |
+ buttonState = KD_BUTTON_3; | |
+ break; | |
+ case SDL_BUTTON_WHEELUP: | |
+ buttonState = KD_BUTTON_4; | |
+ break; | |
+ case SDL_BUTTON_WHEELDOWN: | |
+ buttonState = KD_BUTTON_5; | |
+ break; | |
+ /* | |
+ case SDL_BUTTON_X1: | |
+ buttonState = KD_BUTTON_6; | |
+ break; | |
+ case SDL_BUTTON_X2: | |
+ buttonState = KD_BUTTON_7; | |
+ break; | |
+ */ | |
+ default: | |
+ buttonState = 1 << (event.button.button - 1); | |
+ break; | |
+ } | |
+ mouseState &= ~buttonState; | |
+ KdEnqueuePointerEvent(sdlPointer, mouseState|KD_MOUSE_DELTA, 0, 0, pressure); | |
+ break; | |
+ case SDL_KEYDOWN: | |
+ case SDL_KEYUP: | |
+ TRACE3("\033[100;1HKey sym %d scancode %d unicode %d", event.key.keysym.sym, event.key.keysym.scancode, event.key.keysym.unicode); | |
+ KdEnqueueKeyboardEvent (sdlKeyboard, event.key.keysym.scancode, event.type==SDL_KEYUP); | |
+ // Force SDL screen update, so SDL virtual on-screen buttons will change their images | |
+ //{ | |
+ // SDL_Rect r = {0, 0, 1, 1}; | |
+ // SDL_UpdateRects(SDL_GetVideoSurface(), 1, &r); | |
+ //} | |
+ break; | |
+ case SDL_JOYAXISMOTION: | |
+ if (event.jaxis.which == 0 && event.jaxis.axis == 4 && pressure != event.jaxis.value) | |
+ { | |
+ pressure = event.jaxis.value; | |
+ if (mouseState & KD_BUTTON_1) | |
+ KdEnqueuePointerEvent(sdlPointer, mouseState|KD_MOUSE_DELTA, 0, 0, pressure); | |
+ } | |
+ break; | |
+ case SDL_ACTIVEEVENT: | |
+ // We need this to re-init OpenGL and redraw screen | |
+ // And we need to also call this when OpenGL context was destroyed | |
+ // Oherwise SDL will stuck and we will get a permanent black screen | |
+ SDL_Flip(SDL_GetVideoSurface()); | |
+ break; | |
+ case SDL_QUIT: | |
+ /* this should never happen */ | |
+ SDL_Quit(); | |
+ } | |
+ } | |
+ /* | |
+ if ( nextFullScreenRefresh && nextFullScreenRefresh < SDL_GetTicks() ) | |
+ { | |
+ //printf("SDL_Flip from sdlPollInput"); | |
+ SDL_Flip(SDL_GetVideoSurface()); | |
+ nextFullScreenRefresh = 0; | |
+ } | |
+ */ | |
+} | |
+ | |
+static int xsdlInit(void) | |
+{ | |
+ TRACE("Calling SDL_Init()\n"); | |
+ SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK); | |
+ SDL_JoystickOpen(0); // Receive pressure events | |
+ return 0; | |
+} | |
+ | |
+ | |
+static void xsdlFini(void) | |
+{ | |
+ SDL_Quit(); // SDL_Quit() on Android is buggy | |
+} | |
+ | |
+void | |
+CloseInput (void) | |
+{ | |
+ KdCloseInput (); | |
+} | |
+ | |
+KdOsFuncs sdlOsFuncs={ | |
+ .Init = xsdlInit, | |
+ .Fini = xsdlFini, | |
+ .pollEvents = sdlPollInput, | |
+}; | |
+ | |
+void OsVendorInit (void) | |
+{ | |
+ KdOsInit (&sdlOsFuncs); | |
+} | |
+ | |
diff --git a/man/Makefile.am b/man/Makefile.am | |
index 71d7049..25c85e2 100644 | |
--- a/man/Makefile.am | |
+++ b/man/Makefile.am | |
@@ -3,4 +3,3 @@ | |
# the DDX-level options processing) | |
include $(top_srcdir)/manpages.am | |
-appman_PRE = Xserver.man | |
diff --git a/os/osinit.c b/os/osinit.c | |
index 4d48ea9..351b607 100644 | |
--- a/os/osinit.c | |
+++ b/os/osinit.c | |
@@ -214,6 +214,7 @@ OsInit(void) | |
#endif | |
#if !defined(XQUARTZ) /* STDIN is already /dev/null and STDOUT/STDERR is managed by console_redirect.c */ | |
+#if 0 /* for SIXEL */ | |
# if defined(__APPLE__) | |
int devnullfd = open(devnull, O_RDWR, 0); | |
assert(devnullfd > 2); | |
@@ -225,6 +226,7 @@ OsInit(void) | |
fclose(stdin); | |
fclose(stdout); | |
# endif | |
+#endif | |
/* | |
* If a write of zero bytes to stderr returns non-zero, i.e. -1, | |
* then writing to stderr failed, and we'll write somewhere else | |
diff --git a/xkb/Makefile.am b/xkb/Makefile.am | |
index e386ce5..2a79762 100644 | |
--- a/xkb/Makefile.am | |
+++ b/xkb/Makefile.am | |
@@ -37,6 +37,3 @@ libxkb_la_SOURCES = $(DDX_SRCS) $(DIX_SRCS) $(XKBFILE_SRCS) $(X11_SRCS) | |
libxkbstubs_la_SOURCES = ddxVT.c ddxPrivate.c ddxKillSrv.c | |
EXTRA_DIST = xkbDflts.h xkbgeom.h xkb.h | |
- | |
-xkbcompileddir = $(XKB_COMPILED_DIR) | |
-dist_xkbcompiled_DATA = README.compiled |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment