summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorScott Moreau <oreaus@gmail.com>2014-01-19 09:11:07 -0700
committerScott Moreau <oreaus@gmail.com>2014-01-19 10:36:20 -0700
commit84aa98a5a4587629d6fa2bc9b3b07a5432c2e131 (patch)
treee62a8f2ff2a0d6be51496f61a7e3622c1ad7f5b0 /Source/Core
parent3b25bf2f14189d74cd7dd00b32d8b20b9df3e024 (diff)
wayland: Add bits required to run as a wayland client.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DolphinWX/GLInterface/EGL.cpp2
-rw-r--r--Source/Core/DolphinWX/GLInterface/Platform.cpp14
-rw-r--r--Source/Core/DolphinWX/GLInterface/Platform.h3
-rw-r--r--Source/Core/DolphinWX/GLInterface/Wayland_Util.cpp95
-rw-r--r--Source/Core/DolphinWX/GLInterface/Wayland_Util.h1
-rw-r--r--Source/Core/DolphinWX/GLInterface/X11_Util.cpp5
-rw-r--r--Source/Core/DolphinWX/GLInterface/X11_Util.h1
-rw-r--r--Source/Core/DolphinWX/MainNoGUI.cpp54
-rw-r--r--Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp10
9 files changed, 105 insertions, 80 deletions
diff --git a/Source/Core/DolphinWX/GLInterface/EGL.cpp b/Source/Core/DolphinWX/GLInterface/EGL.cpp
index 222ceb952b..1b6b38f593 100644
--- a/Source/Core/DolphinWX/GLInterface/EGL.cpp
+++ b/Source/Core/DolphinWX/GLInterface/EGL.cpp
@@ -28,7 +28,7 @@ void cInterfaceEGL::UpdateFPSDisplay(const char *text)
}
void cInterfaceEGL::Swap()
{
- eglSwapBuffers(GLWin.egl_dpy, GLWin.egl_surf);
+ Platform.SwapBuffers();
}
void cInterfaceEGL::SwapInterval(int Interval)
{
diff --git a/Source/Core/DolphinWX/GLInterface/Platform.cpp b/Source/Core/DolphinWX/GLInterface/Platform.cpp
index 8094eef810..212ca49214 100644
--- a/Source/Core/DolphinWX/GLInterface/Platform.cpp
+++ b/Source/Core/DolphinWX/GLInterface/Platform.cpp
@@ -117,7 +117,6 @@ out:
if (GLWin.dpy)
{
XCloseDisplay(GLWin.dpy);
- XCloseDisplay(GLWin.evdpy);
}
}
#endif
@@ -219,3 +218,16 @@ cPlatform::ToggleFullscreen(bool fullscreen)
// Only wayland uses this function
#endif
}
+
+void
+cPlatform::SwapBuffers()
+{
+#if HAVE_WAYLAND
+ if (cPlatform::platform == EGL_PLATFORM_WAYLAND)
+ WaylandInterface.SwapBuffers();
+#endif
+#if HAVE_X11
+ if (cPlatform::platform == EGL_PLATFORM_X11)
+ XInterface.SwapBuffers();
+#endif
+}
diff --git a/Source/Core/DolphinWX/GLInterface/Platform.h b/Source/Core/DolphinWX/GLInterface/Platform.h
index a6b9d59cff..9c0d479a54 100644
--- a/Source/Core/DolphinWX/GLInterface/Platform.h
+++ b/Source/Core/DolphinWX/GLInterface/Platform.h
@@ -63,6 +63,7 @@ public:
void DestroyWindow(void);
void UpdateFPSDisplay(const char *text);
void ToggleFullscreen(bool fullscreen);
+ void SwapBuffers();
};
#include "GLInterface/EGL.h"
@@ -129,7 +130,7 @@ typedef struct {
struct wl_surface *wl_surface;
struct wl_shell_surface *wl_shell_surface;
struct wl_callback *wl_callback;
- bool fullscreen, configured, frame_drawn, swap_complete, running;
+ bool fullscreen, running;
#endif
#if HAVE_X11
int screen;
diff --git a/Source/Core/DolphinWX/GLInterface/Wayland_Util.cpp b/Source/Core/DolphinWX/GLInterface/Wayland_Util.cpp
index aa15917344..71b75c7c1e 100644
--- a/Source/Core/DolphinWX/GLInterface/Wayland_Util.cpp
+++ b/Source/Core/DolphinWX/GLInterface/Wayland_Util.cpp
@@ -21,38 +21,6 @@
#include <linux/input.h>
#include <sys/mman.h>
-
-static void
-redraw(void *data, struct wl_callback *callback, uint32_t time);
-
-static const struct wl_callback_listener frame_listener = {
- redraw
-};
-
-static void
-redraw(void *data, struct wl_callback *callback, uint32_t time)
-{
- if (GLWin.wl_callback != callback) {
- printf("Got wrong callback from wayland server\n");
- exit(-1);
- }
-
- GLWin.wl_callback = NULL;
-
- if (callback)
- wl_callback_destroy(callback);
-
- if (!GLWin.configured)
- return;
-
- // Reset the frame callback
- GLWin.wl_callback = wl_surface_frame(GLWin.wl_surface);
- wl_callback_add_listener(GLWin.wl_callback, &frame_listener, 0);
-
- // Present rendered buffer on screen
- //eglSwapBuffers(GLWin.egl_dpy, GLWin.egl_surf);
-}
-
static void
hide_cursor(void)
{
@@ -64,21 +32,6 @@ hide_cursor(void)
}
static void
-configure_callback(void *data, struct wl_callback *callback, uint32_t time)
-{
- wl_callback_destroy(callback);
-
- GLWin.configured = true;
-
- if (GLWin.wl_callback == NULL)
- redraw(data, NULL, time);
-}
-
-static struct wl_callback_listener configure_callback_listener = {
- configure_callback,
-};
-
-static void
handle_ping(void *data, struct wl_shell_surface *wl_shell_surface,
uint32_t serial)
{
@@ -89,7 +42,6 @@ static void
handle_configure(void *data, struct wl_shell_surface *wl_shell_surface,
uint32_t edges, int32_t width, int32_t height)
{
-
if (GLWin.wl_egl_native)
wl_egl_window_resize(GLWin.wl_egl_native, width, height, 0, 0);
@@ -120,8 +72,7 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
{
GLWin.pointer.serial = serial;
- if (GLWin.fullscreen)
- hide_cursor();
+ hide_cursor();
}
static void
@@ -157,19 +108,10 @@ static const struct wl_pointer_listener pointer_listener = {
pointer_handle_axis,
};
-void setup_callback_listener()
-{
- struct wl_callback *callback;
-
- callback = wl_display_sync(GLWin.wl_display);
- wl_callback_add_listener(callback, &configure_callback_listener, 0);
-}
-
static void
toggle_fullscreen(bool fullscreen)
{
GLWin.fullscreen = fullscreen;
- GLWin.configured = false;
if (fullscreen) {
wl_shell_surface_set_fullscreen(GLWin.wl_shell_surface,
@@ -181,8 +123,6 @@ toggle_fullscreen(bool fullscreen)
GLWin.window_size.width,
GLWin.window_size.height);
}
-
- setup_callback_listener();
}
static void
@@ -251,9 +191,10 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
return;
- if (key == KEY_ESC)
- GLWin.running = false;
- else if ((key == KEY_P) ||
+ if (key == KEY_ESC) {
+ Core::Stop();
+ GLWin.running = 0;
+ } else if ((key == KEY_P) ||
((key == KEY_ENTER) && (GLWin.keyboard.modifiers == 0)))
Core::SetState((Core::GetState() == Core::CORE_RUN) ?
Core::CORE_PAUSE : Core::CORE_RUN);
@@ -408,7 +349,8 @@ bool cWaylandInterface::Initialize(void *config)
wl_registry_add_listener(GLWin.wl_registry,
&registry_listener, NULL);
- wl_display_dispatch(GLWin.wl_display);
+ while (!GLWin.wl_compositor)
+ wl_display_dispatch(GLWin.wl_display);
GLWin.wl_cursor_surface =
wl_compositor_create_surface(GLWin.wl_compositor);
@@ -430,8 +372,6 @@ void *cWaylandInterface::CreateWindow(void)
GLWin.window_size.width = 640;
GLWin.window_size.height = 480;
GLWin.fullscreen = true;
- GLWin.frame_drawn = false;
- GLWin.swap_complete = false;
GLWin.wl_surface = wl_compositor_create_surface(GLWin.wl_compositor);
GLWin.wl_shell_surface = wl_shell_get_shell_surface(GLWin.wl_shell,
@@ -443,11 +383,8 @@ void *cWaylandInterface::CreateWindow(void)
GLWin.wl_egl_native = wl_egl_window_create(GLWin.wl_surface,
GLWin.window_size.width,
GLWin.window_size.height);
-#if HAVE_X11
- return GLWin.wl_egl_native;
-#else
+
return GLWin.wl_egl_native;
-#endif
}
void cWaylandInterface::DestroyWindow(void)
@@ -468,5 +405,19 @@ void cWaylandInterface::UpdateFPSDisplay(const char *text)
void cWaylandInterface::ToggleFullscreen(bool fullscreen)
{
- toggle_fullscreen(GLWin.fullscreen);
+ toggle_fullscreen(fullscreen);
+}
+
+void cWaylandInterface::SwapBuffers()
+{
+ struct wl_region *region;
+
+ region = wl_compositor_create_region(GLWin.wl_compositor);
+ wl_region_add(region, 0, 0,
+ GLWin.geometry.width,
+ GLWin.geometry.height);
+ wl_surface_set_opaque_region(GLWin.wl_surface, region);
+ wl_region_destroy(region);
+
+ eglSwapBuffers(GLWin.egl_dpy, GLWin.egl_surf);
}
diff --git a/Source/Core/DolphinWX/GLInterface/Wayland_Util.h b/Source/Core/DolphinWX/GLInterface/Wayland_Util.h
index db5504878a..6c3a10a7d6 100644
--- a/Source/Core/DolphinWX/GLInterface/Wayland_Util.h
+++ b/Source/Core/DolphinWX/GLInterface/Wayland_Util.h
@@ -37,6 +37,7 @@ public:
void DestroyWindow(void);
void UpdateFPSDisplay(const char *text);
void ToggleFullscreen(bool fullscreen);
+ void SwapBuffers();
};
#endif
diff --git a/Source/Core/DolphinWX/GLInterface/X11_Util.cpp b/Source/Core/DolphinWX/GLInterface/X11_Util.cpp
index c8aa476ee2..c6528a674c 100644
--- a/Source/Core/DolphinWX/GLInterface/X11_Util.cpp
+++ b/Source/Core/DolphinWX/GLInterface/X11_Util.cpp
@@ -120,6 +120,11 @@ void cXInterface::UpdateFPSDisplay(const char *text)
XStoreName(GLWin.evdpy, GLWin.win, text);
}
+void cXInterface::SwapBuffers()
+{
+ eglSwapBuffers(GLWin.egl_dpy, GLWin.egl_surf);
+}
+
void cXInterface::XEventThread()
#else
void cX11Window::CreateXWindow(void)
diff --git a/Source/Core/DolphinWX/GLInterface/X11_Util.h b/Source/Core/DolphinWX/GLInterface/X11_Util.h
index 321aa2a9b3..683749e260 100644
--- a/Source/Core/DolphinWX/GLInterface/X11_Util.h
+++ b/Source/Core/DolphinWX/GLInterface/X11_Util.h
@@ -33,6 +33,7 @@ public:
void *CreateWindow(void);
void DestroyWindow(void);
void UpdateFPSDisplay(const char *text);
+ void SwapBuffers();
};
#else
class cX11Window
diff --git a/Source/Core/DolphinWX/MainNoGUI.cpp b/Source/Core/DolphinWX/MainNoGUI.cpp
index c9e61b46f7..49ac423415 100644
--- a/Source/Core/DolphinWX/MainNoGUI.cpp
+++ b/Source/Core/DolphinWX/MainNoGUI.cpp
@@ -10,12 +10,17 @@
#include "Common.h"
#include "FileUtil.h"
-#if defined HAVE_X11 && HAVE_X11
+#if HAVE_X11
#include <X11/keysym.h>
#include "State.h"
#include "X11Utils.h"
#endif
+#if HAVE_WAYLAND
+#include <wayland-client.h>
+#include "GLInterface/Platform.h"
+#endif
+
#ifdef __APPLE__
#import <Cocoa/Cocoa.h>
#endif
@@ -122,7 +127,7 @@ void Host_SysMessage(const char *fmt, ...)
void Host_SetWiiMoteConnectionState(int _State) {}
-#if defined(HAVE_X11) && HAVE_X11
+#if HAVE_X11
void X11_MainLoop()
{
bool fullscreen = SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen;
@@ -256,6 +261,23 @@ void X11_MainLoop()
}
#endif
+#if HAVE_WAYLAND
+void Wayland_MainLoop()
+{
+ // Wait for display to be initialized
+ while(!GLWin.wl_display)
+ usleep(20000);
+
+ GLWin.running = 1;
+
+ while (GLWin.running)
+ wl_display_dispatch(GLWin.wl_display);
+
+ if (GLWin.wl_display)
+ wl_display_disconnect(GLWin.wl_display);
+}
+#endif
+
int main(int argc, char* argv[])
{
#ifdef __APPLE__
@@ -304,9 +326,34 @@ int main(int argc, char* argv[])
m_LocalCoreStartupParameter.m_strVideoBackend);
WiimoteReal::LoadSettings();
+#if USE_EGL
+ GLWin.platform = EGL_PLATFORM_NONE;
+#endif
+#if HAVE_WAYLAND
+ GLWin.wl_display = NULL;
+#endif
+
// No use running the loop when booting fails
if (BootManager::BootCore(argv[optind]))
{
+#if USE_EGL
+ while (GLWin.platform == EGL_PLATFORM_NONE)
+ usleep(20000);
+#endif
+#if HAVE_WAYLAND
+ if (GLWin.platform == EGL_PLATFORM_WAYLAND)
+ Wayland_MainLoop();
+#endif
+#if HAVE_X11
+#if USE_EGL
+ if (GLWin.platform == EGL_PLATFORM_X11) {
+#endif
+ XInitThreads();
+ X11_MainLoop();
+#if USE_EGL
+ }
+#endif
+#endif
#ifdef __APPLE__
while (running)
{
@@ -328,9 +375,6 @@ int main(int argc, char* argv[])
[event release];
[pool release];
-#elif defined HAVE_X11 && HAVE_X11
- XInitThreads();
- X11_MainLoop();
#else
while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)
updateMainFrameEvent.Wait();
diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
index 7287c380d5..493b8ba791 100644
--- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp
@@ -1,5 +1,9 @@
#include "ControllerInterface.h"
+#if USE_EGL
+#include "GLInterface/Platform.h"
+#endif
+
#ifdef CIFACE_USE_XINPUT
#include "XInput/XInput.h"
#endif
@@ -50,10 +54,16 @@ void ControllerInterface::Initialize()
ciface::XInput::Init(m_devices);
#endif
#ifdef CIFACE_USE_XLIB
+#if USE_EGL
+if (GLWin.platform == EGL_PLATFORM_X11) {
+#endif
ciface::Xlib::Init(m_devices, m_hwnd);
#ifdef CIFACE_USE_X11_XINPUT2
ciface::XInput2::Init(m_devices, m_hwnd);
#endif
+#if USE_EGL
+}
+#endif
#endif
#ifdef CIFACE_USE_OSX
ciface::OSX::Init(m_devices, m_hwnd);