diff --git a/Makefile b/Makefile
index 4bcc6a055d..5d7f7bc74b 100644
--- a/Makefile
+++ b/Makefile
@@ -143,11 +143,6 @@ ifeq ($(HAVE_SDL), 1)
DEFINES += $(SDL_CFLAGS) $(BSD_LOCAL_INC)
LIBS += $(SDL_LIBS)
- ifeq ($(HAVE_X11), 1)
- LIBS += $(X11_LIBS)
- DEFINES += $(X11_CFLAGS)
- endif
-
ifeq ($(HAVE_OPENGL), 1)
OBJ += gfx/gl.o gfx/gfx_context.o gfx/fonts/freetype.o gfx/math/matrix.o
@@ -202,7 +197,7 @@ ifeq ($(HAVE_XVIDEO), 1)
endif
ifeq ($(HAVE_X11), 1)
- OBJ += input/x11_input.o
+ OBJ += input/x11_input.o gfx/context/x11_common.o
LIBS += $(X11_LIBS) $(XEXT_LIBS)
DEFINES += $(X11_CFLAGS) $(XEXT_CFLAGS)
endif
diff --git a/gfx/context/sdl_ctx.c b/gfx/context/sdl_ctx.c
index b3397203f6..52207d8d46 100644
--- a/gfx/context/sdl_ctx.c
+++ b/gfx/context/sdl_ctx.c
@@ -13,13 +13,14 @@
* If not, see .
*/
-// Compatibility wrapper between SDL 1.2/1.3 for OpenGL.
-// Wraps functions which differ in 1.2 and 1.3.
-
#include "../gfx_context.h"
#include "../gfx_common.h"
#include "../../general.h"
+#ifdef HAVE_X11
+#include "x11_common.h"
+#endif
+
#ifdef __APPLE__
#include
#include
@@ -161,13 +162,13 @@ static bool gfx_ctx_set_video_mode(
SDL_ShowCursor(SDL_DISABLE);
// Suspend screensaver on X11.
-#if defined(HAVE_X11) && !defined(__APPLE__)
+#if defined(HAVE_X11)
RARCH_LOG("Suspending screensaver (X11).\n");
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if (SDL_GetWMInfo(&info) == 1)
- gfx_suspend_screensaver(info.info.x11.window);
+ x11_suspend_screensaver(info.info.x11.window);
else
RARCH_ERR("Failed to get SDL WM info, cannot suspend screensaver.\n");
#endif
@@ -192,7 +193,7 @@ static void gfx_ctx_swap_buffers(void)
}
// 1.2 specific workaround for tiling WMs.
-#if defined(HAVE_X11) && !defined(__APPLE__)
+#if defined(HAVE_X11)
// This X11 is set on OSX for some reason.
static bool gfx_ctx_get_window_size(unsigned *width, unsigned *height)
{
@@ -238,7 +239,7 @@ static void gfx_ctx_check_window(bool *quit,
}
}
-#if defined(HAVE_X11) && !defined(__APPLE__)
+#if defined(HAVE_X11)
if (!*resize && !g_fullscreen)
{
unsigned new_width, new_height;
diff --git a/gfx/context/x11_common.c b/gfx/context/x11_common.c
new file mode 100644
index 0000000000..639932472c
--- /dev/null
+++ b/gfx/context/x11_common.c
@@ -0,0 +1,91 @@
+/* RetroArch - A frontend for libretro.
+ * Copyright (C) 2010-2012 - Hans-Kristian Arntzen
+ * Copyright (C) 2011-2012 - Daniel De Matteis
+ *
+ * RetroArch is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Found-
+ * ation, either version 3 of the License, or (at your option) any later version.
+ *
+ * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with RetroArch.
+ * If not, see .
+ */
+
+#include "x11_common.h"
+#include
+#include
+#include "../../general.h"
+
+void x11_hide_mouse(Display *dpy, Window win)
+{
+ Cursor no_ptr;
+ Pixmap bm_no;
+ XColor black, dummy;
+ Colormap colormap;
+
+ static char bm_no_data[] = {0, 0, 0, 0, 0, 0, 0, 0};
+
+ colormap = DefaultColormap(dpy, DefaultScreen(dpy));
+ if (!XAllocNamedColor(dpy, colormap, "black", &black, &dummy))
+ return;
+
+ bm_no = XCreateBitmapFromData(dpy, win, bm_no_data, 8, 8);
+ no_ptr = XCreatePixmapCursor(dpy, bm_no, bm_no, &black, &black, 0, 0);
+
+ XDefineCursor(dpy, win, no_ptr);
+ XFreeCursor(dpy, no_ptr);
+
+ if (bm_no != None)
+ XFreePixmap(dpy, bm_no);
+
+ XFreeColors(dpy, colormap, &black.pixel, 1, 0);
+}
+
+static Atom XA_NET_WM_STATE;
+static Atom XA_NET_WM_STATE_FULLSCREEN;
+#define XA_INIT(x) XA##x = XInternAtom(dpy, #x, False)
+#define _NET_WM_STATE_ADD 1
+void x11_windowed_fullscreen(Display *dpy, Window win)
+{
+ XA_INIT(_NET_WM_STATE);
+ XA_INIT(_NET_WM_STATE_FULLSCREEN);
+
+ if (!XA_NET_WM_STATE || !XA_NET_WM_STATE_FULLSCREEN)
+ {
+ RARCH_ERR("[X/EGL]: Cannot set windowed fullscreen.\n");
+ return;
+ }
+
+ XEvent xev;
+
+ xev.xclient.type = ClientMessage;
+ xev.xclient.serial = 0;
+ xev.xclient.send_event = True;
+ xev.xclient.message_type = XA_NET_WM_STATE;
+ xev.xclient.window = win;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
+ xev.xclient.data.l[1] = XA_NET_WM_STATE_FULLSCREEN;
+ xev.xclient.data.l[2] = 0;
+ xev.xclient.data.l[3] = 0;
+ xev.xclient.data.l[4] = 0;
+
+ XSendEvent(dpy, DefaultRootWindow(dpy), False,
+ SubstructureRedirectMask | SubstructureNotifyMask,
+ &xev);
+}
+
+void x11_suspend_screensaver(Window wnd)
+{
+ char cmd[64];
+ snprintf(cmd, sizeof(cmd), "xdg-screensaver suspend %d", (int)wnd);
+
+ int ret = system(cmd);
+
+ if (ret != 0)
+ RARCH_WARN("Could not suspend screen saver.\n");
+}
+
diff --git a/gfx/context/x11_common.h b/gfx/context/x11_common.h
new file mode 100644
index 0000000000..0c4c0a849c
--- /dev/null
+++ b/gfx/context/x11_common.h
@@ -0,0 +1,28 @@
+/* RetroArch - A frontend for libretro.
+ * Copyright (C) 2010-2012 - Hans-Kristian Arntzen
+ * Copyright (C) 2011-2012 - Daniel De Matteis
+ *
+ * RetroArch is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Found-
+ * ation, either version 3 of the License, or (at your option) any later version.
+ *
+ * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with RetroArch.
+ * If not, see .
+ */
+
+#ifndef X11_COMMON_H__
+#define X11_COMMON_H__
+
+#include
+#include
+
+void x11_hide_mouse(Display *dpy, Window win);
+void x11_windowed_fullscreen(Display *dpy, Window win);
+void x11_suspend_screensaver(Window win);
+
+#endif
+
diff --git a/gfx/context/xegl_ctx.c b/gfx/context/xegl_ctx.c
index 0f5b5ae0b7..f455258e1a 100644
--- a/gfx/context/xegl_ctx.c
+++ b/gfx/context/xegl_ctx.c
@@ -21,6 +21,7 @@
#include "../gfx_context.h"
#include "../gl_common.h"
#include "../gfx_common.h"
+#include "x11_common.h"
#include "../../input/x11_input.h"
#include
@@ -55,65 +56,6 @@ static void sighandler(int sig)
static void gfx_ctx_get_video_size(unsigned *width, unsigned *height);
static void gfx_ctx_destroy(void);
-static void hide_mouse(void)
-{
- Cursor no_ptr;
- Pixmap bm_no;
- XColor black, dummy;
- Colormap colormap;
-
- static char bm_no_data[] = {0, 0, 0, 0, 0, 0, 0, 0};
-
- colormap = DefaultColormap(g_dpy, DefaultScreen(g_dpy));
- if (!XAllocNamedColor(g_dpy, colormap, "black", &black, &dummy))
- return;
-
- bm_no = XCreateBitmapFromData(g_dpy, g_win, bm_no_data, 8, 8);
- no_ptr = XCreatePixmapCursor(g_dpy, bm_no, bm_no, &black, &black, 0, 0);
-
- XDefineCursor(g_dpy, g_win, no_ptr);
- XFreeCursor(g_dpy, no_ptr);
-
- if (bm_no != None)
- XFreePixmap(g_dpy, bm_no);
-
- XFreeColors(g_dpy, colormap, &black.pixel, 1, 0);
-}
-
-static Atom XA_NET_WM_STATE;
-static Atom XA_NET_WM_STATE_FULLSCREEN;
-#define XA_INIT(x) XA##x = XInternAtom(g_dpy, #x, False)
-#define _NET_WM_STATE_ADD 1
-static void set_windowed_fullscreen(void)
-{
- XA_INIT(_NET_WM_STATE);
- XA_INIT(_NET_WM_STATE_FULLSCREEN);
-
- if (!XA_NET_WM_STATE || !XA_NET_WM_STATE_FULLSCREEN)
- {
- RARCH_ERR("[X/EGL]: Cannot set windowed fullscreen.\n");
- return;
- }
-
- XEvent xev;
-
- xev.xclient.type = ClientMessage;
- xev.xclient.serial = 0;
- xev.xclient.send_event = True;
- xev.xclient.message_type = XA_NET_WM_STATE;
- xev.xclient.window = g_win;
- xev.xclient.format = 32;
- xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
- xev.xclient.data.l[1] = XA_NET_WM_STATE_FULLSCREEN;
- xev.xclient.data.l[2] = 0;
- xev.xclient.data.l[3] = 0;
- xev.xclient.data.l[4] = 0;
-
- XSendEvent(g_dpy, DefaultRootWindow(g_dpy), False,
- SubstructureRedirectMask | SubstructureNotifyMask,
- &xev);
-}
-
static void gfx_ctx_swap_interval(unsigned interval)
{
g_interval = interval;
@@ -350,17 +292,17 @@ static bool gfx_ctx_set_video_mode(
goto error;
gfx_ctx_update_window_title(true);
- hide_mouse();
+ x11_hide_mouse(g_dpy, g_win);
XMapWindow(g_dpy, g_win);
if (fullscreen)
- set_windowed_fullscreen();
+ x11_windowed_fullscreen(g_dpy, g_win);
g_quit_atom = XInternAtom(g_dpy, "WM_DELETE_WINDOW", False);
if (g_quit_atom)
XSetWMProtocols(g_dpy, g_win, &g_quit_atom, 1);
- gfx_suspend_screensaver(g_win);
+ x11_suspend_screensaver(g_win);
gfx_ctx_swap_interval(g_interval);
XFree(vi);
diff --git a/gfx/gfx_common.c b/gfx/gfx_common.c
index 3f72f0aec6..0ee9a1b45c 100644
--- a/gfx/gfx_common.c
+++ b/gfx/gfx_common.c
@@ -120,19 +120,6 @@ bool gfx_window_title(char *buf, size_t size)
return ret;
}
-#if defined(HAVE_X11) && !defined(__APPLE__)
-void gfx_suspend_screensaver(Window wnd)
-{
- char cmd[64];
- snprintf(cmd, sizeof(cmd), "xdg-screensaver suspend %d", (int)wnd);
-
- int ret = system(cmd);
-
- if (ret != 0)
- RARCH_WARN("Could not suspend screen saver.\n");
-}
-#endif
-
#if defined(_WIN32) && !defined(_XBOX)
#include
#include "../dynamic.h"
diff --git a/gfx/gfx_common.h b/gfx/gfx_common.h
index 3291b70f15..5b48d7ae7a 100644
--- a/gfx/gfx_common.h
+++ b/gfx/gfx_common.h
@@ -26,11 +26,6 @@
bool gfx_window_title(char *buf, size_t size);
void gfx_window_title_reset(void);
-#if defined(HAVE_X11) && !defined(__APPLE__)
-#include
-void gfx_suspend_screensaver(Window wnd);
-#endif
-
#ifdef _WIN32
void gfx_set_dwm(void);
#endif
diff --git a/gfx/sdl_gfx.c b/gfx/sdl_gfx.c
index bac137d603..20a0bffff6 100644
--- a/gfx/sdl_gfx.c
+++ b/gfx/sdl_gfx.c
@@ -23,6 +23,10 @@
#include "gfx_common.h"
#include "gfx_context.h"
+#ifdef HAVE_X11
+#include "context/x11_common.h"
+#endif
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -289,12 +293,12 @@ static void *sdl_gfx_init(const video_info_t *video, const input_driver_t **inpu
SDL_ShowCursor(SDL_DISABLE);
-#if defined(HAVE_X11) && !defined(__APPLE__)
+#if defined(HAVE_X11)
RARCH_LOG("Suspending screensaver (X11).\n");
SDL_SysWMinfo wm_info;
SDL_VERSION(&wm_info.version);
if (SDL_GetWMInfo(&wm_info) == 1)
- gfx_suspend_screensaver(wm_info.info.x11.window);
+ x11_suspend_screensaver(wm_info.info.x11.window);
else
RARCH_ERR("Failed to suspend screensaver.\n");
#endif
diff --git a/gfx/xvideo.c b/gfx/xvideo.c
index 46c8e46258..73cf041e62 100644
--- a/gfx/xvideo.c
+++ b/gfx/xvideo.c
@@ -19,11 +19,14 @@
#include
#include
#include
+#include "gfx_common.h"
+#include "../input/x11_input.h"
+
#ifdef HAVE_FREETYPE
#include "fonts/fonts.h"
#endif
-#include "gfx_common.h"
-#include "../input/x11_input.h"
+
+#include "context/x11_common.h"
#include
#include
@@ -529,7 +532,7 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo
xv->focus = true;
RARCH_LOG("Suspending screensaver (X11).\n");
- gfx_suspend_screensaver(xv->window);
+ x11_suspend_screensaver(xv->window);
xinput = input_x.init();
if (xinput)
diff --git a/qb/config.libs.sh b/qb/config.libs.sh
index b8865ecf28..1a51621825 100644
--- a/qb/config.libs.sh
+++ b/qb/config.libs.sh
@@ -9,6 +9,7 @@ add_define_make NOUNUSED "$HAVE_NOUNUSED"
[ -d /opt/local/lib ] && add_library_dirs /opt/local/lib
if [ "$OS" = 'BSD' ]; then DYLIB=-lc; else DYLIB=-ldl; fi
+[ "$OS" = 'OSX' ] && HAVE_X11=no # X11 breaks on recent OSXes even if present.
[ -d /opt/vc/lib ] && add_library_dirs /opt/vc/lib
check_lib VIDEOCORE -lbcm_host bcm_host_init "-lvcos -lvchiq_arm"