aboutsummaryrefslogtreecommitdiffstats
path: root/distrib/sdl-1.2.15/src/video/x11
diff options
context:
space:
mode:
Diffstat (limited to 'distrib/sdl-1.2.15/src/video/x11')
-rw-r--r--distrib/sdl-1.2.15/src/video/x11/SDL_x11dyn.c1
-rw-r--r--distrib/sdl-1.2.15/src/video/x11/SDL_x11sym.h10
-rw-r--r--distrib/sdl-1.2.15/src/video/x11/SDL_x11video.c11
-rw-r--r--distrib/sdl-1.2.15/src/video/x11/SDL_x11video.h3
-rw-r--r--distrib/sdl-1.2.15/src/video/x11/SDL_x11wm.c186
-rw-r--r--distrib/sdl-1.2.15/src/video/x11/SDL_x11wm_c.h6
6 files changed, 215 insertions, 2 deletions
diff --git a/distrib/sdl-1.2.15/src/video/x11/SDL_x11dyn.c b/distrib/sdl-1.2.15/src/video/x11/SDL_x11dyn.c
index 7058add..7d4acbb 100644
--- a/distrib/sdl-1.2.15/src/video/x11/SDL_x11dyn.c
+++ b/distrib/sdl-1.2.15/src/video/x11/SDL_x11dyn.c
@@ -200,6 +200,7 @@ int SDL_X11_LoadSymbols(void)
if (SDL_X11_HAVE_BASEXLIB) { /* all required symbols loaded. */
SDL_ClearError();
+ XInitThreads();
} else {
SDL_X11_UnloadSymbols(); /* in case something got loaded... */
rc = 0;
diff --git a/distrib/sdl-1.2.15/src/video/x11/SDL_x11sym.h b/distrib/sdl-1.2.15/src/video/x11/SDL_x11sym.h
index 4875b98..f9c7df3 100644
--- a/distrib/sdl-1.2.15/src/video/x11/SDL_x11sym.h
+++ b/distrib/sdl-1.2.15/src/video/x11/SDL_x11sym.h
@@ -31,6 +31,7 @@ SDL_X11_SYM(int,XChangeWindowAttributes,(Display* a,Window b,unsigned long c,XSe
SDL_X11_SYM(Bool,XCheckTypedEvent,(Display* a,int b,XEvent* c),(a,b,c),return)
SDL_X11_SYM(int,XClearWindow,(Display* a,Window b),(a,b),return)
SDL_X11_SYM(int,XCloseDisplay,(Display* a),(a),return)
+SDL_X11_SYM(int,XConfigureWindow,(Display* a,Window b,unsigned int c,XWindowChanges* d),(a,b,c,d),return)
SDL_X11_SYM(Colormap,XCreateColormap,(Display* a,Window b,Visual* c,int d),(a,b,c,d),return)
SDL_X11_SYM(Cursor,XCreatePixmapCursor,(Display* a,Pixmap b,Pixmap c,XColor* d,XColor* e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return)
SDL_X11_SYM(GC,XCreateGC,(Display* a,Drawable b,unsigned long c,XGCValues* d),(a,b,c,d),return)
@@ -39,6 +40,11 @@ SDL_X11_SYM(Pixmap,XCreatePixmap,(Display* a,Drawable b,unsigned int c,unsigned
SDL_X11_SYM(Pixmap,XCreatePixmapFromBitmapData,(Display* a,Drawable b,char* c,unsigned int d,unsigned int e,unsigned long f,unsigned long g,unsigned int h),(a,b,c,d,e,f,g,h),return)
SDL_X11_SYM(Window,XCreateSimpleWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f,unsigned int g,unsigned long h,unsigned long i),(a,b,c,d,e,f,g,h,i),return)
SDL_X11_SYM(Window,XCreateWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f,unsigned int g,int h,unsigned int i,Visual* j,unsigned long k,XSetWindowAttributes* l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
+SDL_X11_SYM(int,XDefaultScreen,(Display* a),(a),return)
+SDL_X11_SYM(int,XDisplayWidth,(Display* a,int b),(a,b),return)
+SDL_X11_SYM(int,XDisplayWidthMM,(Display* a, int b),(a, b),return)
+SDL_X11_SYM(int,XDisplayHeight,(Display* a,int b),(a,b),return)
+SDL_X11_SYM(int,XDisplayHeightMM,(Display* a, int b),(a, b),return)
SDL_X11_SYM(int,XDefineCursor,(Display* a,Window b,Cursor c),(a,b,c),return)
SDL_X11_SYM(int,XDeleteProperty,(Display* a,Window b,Atom c),(a,b,c),return)
SDL_X11_SYM(int,XDestroyWindow,(Display* a,Window b),(a,b),return)
@@ -54,6 +60,7 @@ SDL_X11_SYM(int,XFreeGC,(Display* a,GC b),(a,b),return)
SDL_X11_SYM(int,XFreeModifiermap,(XModifierKeymap* a),(a),return)
SDL_X11_SYM(int,XFreePixmap,(Display* a,Pixmap b),(a,b),return)
SDL_X11_SYM(int,XGetErrorDatabaseText,(Display* a,_Xconst char* b,_Xconst char* c,_Xconst char* d,char* e,int f),(a,b,c,d,e,f),return)
+SDL_X11_SYM(int,XGetGeometry,(Display* a,Drawable b,Window* c,int* d,int* e,unsigned int* f,unsigned int* g,unsigned int* h,unsigned int* i),(a,b,c,d,e,f,g,h,i),return)
SDL_X11_SYM(XModifierKeymap*,XGetModifierMapping,(Display* a),(a),return)
SDL_X11_SYM(int,XGetPointerControl,(Display* a,int* b,int* c,int* d),(a,b,c,d),return)
SDL_X11_SYM(XVisualInfo*,XGetVisualInfo,(Display* a,long b,XVisualInfo* c,int* d),(a,b,c,d),return)
@@ -62,6 +69,7 @@ SDL_X11_SYM(Status,XGetWindowAttributes,(Display* a,Window b,XWindowAttributes*
SDL_X11_SYM(int,XGrabKeyboard,(Display* a,Window b,Bool c,int d,int e,Time f),(a,b,c,d,e,f),return)
SDL_X11_SYM(int,XGrabPointer,(Display* a,Window b,Bool c,unsigned int d,int e,int f,Window g,Cursor h,Time i),(a,b,c,d,e,f,g,h,i),return)
SDL_X11_SYM(Status,XIconifyWindow,(Display* a,Window b,int c),(a,b,c),return)
+SDL_X11_SYM(Status,XInitThreads,(void),(),return)
SDL_X11_SYM(int,XInstallColormap,(Display* a,Colormap b),(a,b),return)
SDL_X11_SYM(KeyCode,XKeysymToKeycode,(Display* a,KeySym b),(a,b),return)
SDL_X11_SYM(Atom,XInternAtom,(Display* a,_Xconst char* b,Bool c),(a,b,c),return)
@@ -82,6 +90,7 @@ SDL_X11_SYM(int,XPutImage,(Display* a,Drawable b,GC c,XImage* d,int e,int f,int
SDL_X11_SYM(int,XQueryColors,(Display* a,Colormap b,XColor* c,int d),(a,b,c,d),return)
SDL_X11_SYM(int,XQueryKeymap,(Display* a,char *b),(a,b),return)
SDL_X11_SYM(Bool,XQueryPointer,(Display* a,Window b,Window* c,Window* d,int* e,int* f,int* g,int* h,unsigned int* i),(a,b,c,d,e,f,g,h,i),return)
+SDL_X11_SYM(int,XQueryTree,(Display* a,Window b,Window* c,Window* d,Window** e,unsigned int* f),(a,b,c,d,e,f),return)
SDL_X11_SYM(int,XRaiseWindow,(Display* a,Window b),(a,b),return)
SDL_X11_SYM(int,XReparentWindow,(Display* a,Window b,Window c,int d,int e),(a,b,c,d,e),return)
SDL_X11_SYM(int,XResetScreenSaver,(Display* a),(a),return)
@@ -124,6 +133,7 @@ SDL_X11_SYM(void,_XSend,(Display* a,_Xconst char* b,long c),(a,b,c),)
SDL_X11_SYM(Status,_XReply,(Display* a,xReply* b,int c,Bool d),(a,b,c,d),return)
SDL_X11_SYM(unsigned long,_XSetLastRequestRead,(Display* a,xGenericReply* b),(a,b),return)
SDL_X11_SYM(SDL_X11_XSynchronizeRetType,XSynchronize,(Display* a,Bool b),(a,b),return)
+SDL_X11_SYM(int,XTranslateCoordinates,(Display* a,Window b,Window c,int d,int e,int* f,int* g,Window* h),(a,b,c,d,e,f,g,h),return)
SDL_X11_SYM(SDL_X11_XESetWireToEventRetType,XESetWireToEvent,(Display* a,int b,SDL_X11_XESetWireToEventRetType c),(a,b,c),return)
SDL_X11_SYM(SDL_X11_XESetEventToWireRetType,XESetEventToWire,(Display* a,int b,SDL_X11_XESetEventToWireRetType c),(a,b,c),return)
SDL_X11_SYM(XExtensionErrorHandler,XSetExtensionErrorHandler,(XExtensionErrorHandler a),(a),return)
diff --git a/distrib/sdl-1.2.15/src/video/x11/SDL_x11video.c b/distrib/sdl-1.2.15/src/video/x11/SDL_x11video.c
index f7d8073..6d24422 100644
--- a/distrib/sdl-1.2.15/src/video/x11/SDL_x11video.c
+++ b/distrib/sdl-1.2.15/src/video/x11/SDL_x11video.c
@@ -68,6 +68,8 @@ static int X11_SetColors(_THIS, int firstcolor, int ncolors,
static int X11_SetGammaRamp(_THIS, Uint16 *ramp);
static void X11_VideoQuit(_THIS);
+int X11_wmXAdjust;
+int X11_wmYAdjust;
/* X11 driver bootstrap functions */
@@ -164,6 +166,11 @@ static SDL_VideoDevice *X11_CreateDevice(int devindex)
device->SetIcon = X11_SetIcon;
device->IconifyWindow = X11_IconifyWindow;
device->GrabInput = X11_GrabInput;
+ device->GetWindowPos = X11_GetWindowPos;
+ device->SetWindowPos = X11_SetWindowPos;
+ device->IsWindowVisible = X11_IsWindowVisible;
+ device->GetMonitorDPI = X11_GetMonitorDPI;
+ device->GetMonitorRect = X11_GetMonitorRect;
device->GetWMInfo = X11_GetWMInfo;
device->FreeWMCursor = X11_FreeWMCursor;
device->CreateWMCursor = X11_CreateWMCursor;
@@ -350,7 +357,9 @@ static void create_aux_windows(_THIS)
xattr.colormap = SDL_XColorMap;
FSwindow = XCreateWindow(SDL_Display, SDL_Root,
- x, y, 32, 32, 0,
+ x + X11_wmXAdjust,
+ y + X11_wmYAdjust,
+ 32, 32, 0,
this->hidden->depth, InputOutput, SDL_Visual,
CWOverrideRedirect | CWBackPixel | CWBorderPixel
| CWColormap,
diff --git a/distrib/sdl-1.2.15/src/video/x11/SDL_x11video.h b/distrib/sdl-1.2.15/src/video/x11/SDL_x11video.h
index f347560..18cf497 100644
--- a/distrib/sdl-1.2.15/src/video/x11/SDL_x11video.h
+++ b/distrib/sdl-1.2.15/src/video/x11/SDL_x11video.h
@@ -156,6 +156,9 @@ struct SDL_PrivateVideoData {
int allow_screensaver;
};
+extern int X11_wmXAdjust;
+extern int X11_wmYAdjust;
+
/* Old variable names */
#define local_X11 (this->hidden->local_X11)
#define SDL_Display (this->hidden->X11_Display)
diff --git a/distrib/sdl-1.2.15/src/video/x11/SDL_x11wm.c b/distrib/sdl-1.2.15/src/video/x11/SDL_x11wm.c
index 14c816b..2fd59e9 100644
--- a/distrib/sdl-1.2.15/src/video/x11/SDL_x11wm.c
+++ b/distrib/sdl-1.2.15/src/video/x11/SDL_x11wm.c
@@ -325,6 +325,147 @@ int X11_IconifyWindow(_THIS)
return(result);
}
+#if 0
+#define D(...) printf(__VA_ARGS__)
+#define E(...) D(__VA_ARGS__)
+#else
+#define D(...) ((void)0)
+#define E(...) ((void)0)
+#endif
+
+static void set_window_pos_nolock(_THIS, int x, int y)
+{
+ int xNew, yNew;
+ Window child;
+ int xAdjust = X11_wmXAdjust;
+ int yAdjust = X11_wmYAdjust;
+
+ /* don't do anything in full-screen mode, because the FSwindow is used
+ * instead of the WMwindow, which will make the adjustment go wild
+ */
+ if (this->screen->flags & SDL_FULLSCREEN)
+ return;
+
+ /* this code is tricky because some window managers, but not all,
+ * will translate the final window position by a given offset
+ * corresponding to the frame decoration.
+ *
+ * so we first try to move the window, get the position that the
+ * window manager has set, and if they are different, re-position the
+ * window again with an adjustment.
+ *
+ * this causes a slight flicker since the window 'jumps' very
+ * quickly from one position to the other.
+ */
+
+ D("%s: move to [%d,%d] adjusted to [%d,%d]\n", __FUNCTION__,
+ x, y, x+xAdjust, y+yAdjust);
+ XMoveWindow(SDL_Display, WMwindow, x + xAdjust, y + yAdjust);
+ XSync(SDL_Display, True);
+ XTranslateCoordinates( SDL_Display, WMwindow, SDL_Root, 0, 0, &xNew, &yNew, &child );
+ if (xNew != x || yNew != y) {
+ X11_wmXAdjust = xAdjust = x - xNew;
+ X11_wmYAdjust = yAdjust = y - yNew;
+ D("%s: read pos [%d,%d], recomputing adjust=[%d,%d] moving to [%d,%d]\n",
+ __FUNCTION__, xNew, yNew, xAdjust, yAdjust, x+xAdjust, y+yAdjust);
+ XMoveWindow(SDL_Display, WMwindow, x + xAdjust, y + yAdjust );
+ }
+ XSync(SDL_Display, False);
+}
+
+/* Set window position */
+void X11_SetWindowPos(_THIS, int x, int y)
+{
+ SDL_Lock_EventThread();
+ set_window_pos_nolock(this, x, y);
+ SDL_Unlock_EventThread();
+}
+
+/* Get window position */
+void X11_GetWindowPos(_THIS, int *px, int *py)
+{
+ /* in full-screen mode, you can't move the window */
+ if (this->screen->flags & SDL_FULLSCREEN) {
+ *px = *py = 0;
+ return;
+ }
+
+
+ SDL_Lock_EventThread();
+ {
+ Window child;
+
+ XTranslateCoordinates( SDL_Display, WMwindow, SDL_Root, 0, 0, px, py, &child );
+ }
+ SDL_Unlock_EventThread();
+}
+
+static int
+is_window_visible(_THIS, int screen_x, int screen_y, int screen_w, int screen_h )
+{
+ XWindowAttributes attr;
+ int x, y;
+ Window child;
+
+ XGetWindowAttributes( SDL_Display, WMwindow, &attr );
+ XTranslateCoordinates( SDL_Display, WMwindow, SDL_Root, 0, 0, &x, &y, &child );
+
+ return ( x >= screen_x && x + attr.width <= screen_x + screen_w &&
+ y >= screen_y && y + attr.height <= screen_y + screen_h );
+}
+
+int X11_IsWindowVisible(_THIS, int recenter)
+{
+ int result = 0;
+ XWindowAttributes attr;
+ int screen_w, screen_h;
+
+ SDL_Lock_EventThread();
+ XGetWindowAttributes( SDL_Display, SDL_Root, &attr );
+ screen_w = attr.width;
+ screen_h = attr.height;
+
+#if SDL_VIDEO_DRIVER_X11_XINERAMA
+ if (use_xinerama) {
+ SDL_NAME(XineramaScreenInfo) *xinerama;
+ int i, screens;
+
+ xinerama = SDL_NAME(XineramaQueryScreens)(SDL_Display, &screens);
+ for (i = 0; i < screens; i++) {
+ if ( is_window_visible( this,
+ xinerama[i].x_org, xinerama[i].y_org,
+ xinerama[i].width, xinerama[i].height ) )
+ {
+ result = 1;
+ break;
+ }
+ }
+
+ if ( !result && recenter ) {
+ set_window_pos_nolock(this,
+ xinerama[0].x_org + (xinerama[0].width - this->screen->w)/2,
+ xinerama[0].y_org + (xinerama[0].height - this->screen->h)/2 );
+ }
+ XFree(xinerama);
+ goto Exit;
+ }
+#endif
+ if ( is_window_visible( this, 0, 0, screen_w, screen_h ) ) {
+ result = 1;
+ }
+
+ if ( !result && recenter ) {
+ set_window_pos_nolock( this,
+ (screen_w - this->screen->w)/2,
+ (screen_h - this->screen->h)/2 );
+ }
+#ifdef SDL_VIDEO_DRIVER_X11_XINERAMA
+Exit:
+#endif
+ SDL_Unlock_EventThread();
+ return result;
+}
+
SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode)
{
int result;
@@ -387,6 +528,51 @@ SDL_GrabMode X11_GrabInput(_THIS, SDL_GrabMode mode)
return(mode);
}
+#define MM_PER_INCH 25.4
+
+int
+X11_GetMonitorDPI(_THIS, int *px_dpi, int *py_dpi)
+{
+ Display* display = SDL_Display;
+ int screen = XDefaultScreen(display);
+ int xdpi, ydpi;
+
+ int width = XDisplayWidth(display, screen);
+ int width_mm = XDisplayWidthMM(display, screen);
+ int height = XDisplayHeight(display, screen);
+ int height_mm = XDisplayHeightMM(display, screen);
+
+ if (width_mm <= 0 || height_mm <= 0) {
+ return -1;
+ }
+
+ xdpi = (int)(width * MM_PER_INCH / width_mm + 0.5);
+ ydpi = (int)(height * MM_PER_INCH / height_mm + 0.5);
+
+ if (xdpi < 20 || xdpi > 400 || ydpi < 20 || ydpi > 400) {
+ return -1;
+ }
+
+ *px_dpi = xdpi;
+ *py_dpi = ydpi;
+
+ return 0;
+}
+
+int
+X11_GetMonitorRect(_THIS, SDL_Rect *rect)
+{
+ Display* display = SDL_Display;
+ int screen = XDefaultScreen(display);
+
+ rect->x = 0;
+ rect->y = 0;
+ rect->w = XDisplayWidth(display, screen);
+ rect->h = XDisplayHeight(display, screen);
+
+ return 0;
+}
+
/* If 'info' is the right version, this function fills it and returns 1.
Otherwise, in case of a version mismatch, it returns -1.
*/
diff --git a/distrib/sdl-1.2.15/src/video/x11/SDL_x11wm_c.h b/distrib/sdl-1.2.15/src/video/x11/SDL_x11wm_c.h
index f85477b..c0f938b 100644
--- a/distrib/sdl-1.2.15/src/video/x11/SDL_x11wm_c.h
+++ b/distrib/sdl-1.2.15/src/video/x11/SDL_x11wm_c.h
@@ -31,4 +31,8 @@ extern int X11_IconifyWindow(_THIS);
extern SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode);
extern SDL_GrabMode X11_GrabInput(_THIS, SDL_GrabMode mode);
extern int X11_GetWMInfo(_THIS, SDL_SysWMinfo *info);
-
+extern void X11_GetWindowPos(_THIS, int *px, int *py);
+extern void X11_SetWindowPos(_THIS, int x, int y);
+extern int X11_IsWindowVisible(_THIS, int recenter);
+extern int X11_GetMonitorDPI(_THIS, int* xdpi, int *ydpi);
+extern int X11_GetMonitorRect(_THIS, SDL_Rect *rect);