mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-18 11:42:36 +00:00
wayland: Add bits required to run as a wayland client.
This commit is contained in:
parent
3b25bf2f14
commit
84aa98a5a4
@ -28,7 +28,7 @@ void cInterfaceEGL::UpdateFPSDisplay(const char *text)
|
|||||||
}
|
}
|
||||||
void cInterfaceEGL::Swap()
|
void cInterfaceEGL::Swap()
|
||||||
{
|
{
|
||||||
eglSwapBuffers(GLWin.egl_dpy, GLWin.egl_surf);
|
Platform.SwapBuffers();
|
||||||
}
|
}
|
||||||
void cInterfaceEGL::SwapInterval(int Interval)
|
void cInterfaceEGL::SwapInterval(int Interval)
|
||||||
{
|
{
|
||||||
|
@ -117,7 +117,6 @@ out:
|
|||||||
if (GLWin.dpy)
|
if (GLWin.dpy)
|
||||||
{
|
{
|
||||||
XCloseDisplay(GLWin.dpy);
|
XCloseDisplay(GLWin.dpy);
|
||||||
XCloseDisplay(GLWin.evdpy);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -219,3 +218,16 @@ cPlatform::ToggleFullscreen(bool fullscreen)
|
|||||||
// Only wayland uses this function
|
// Only wayland uses this function
|
||||||
#endif
|
#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
|
||||||
|
}
|
||||||
|
@ -63,6 +63,7 @@ public:
|
|||||||
void DestroyWindow(void);
|
void DestroyWindow(void);
|
||||||
void UpdateFPSDisplay(const char *text);
|
void UpdateFPSDisplay(const char *text);
|
||||||
void ToggleFullscreen(bool fullscreen);
|
void ToggleFullscreen(bool fullscreen);
|
||||||
|
void SwapBuffers();
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "GLInterface/EGL.h"
|
#include "GLInterface/EGL.h"
|
||||||
@ -129,7 +130,7 @@ typedef struct {
|
|||||||
struct wl_surface *wl_surface;
|
struct wl_surface *wl_surface;
|
||||||
struct wl_shell_surface *wl_shell_surface;
|
struct wl_shell_surface *wl_shell_surface;
|
||||||
struct wl_callback *wl_callback;
|
struct wl_callback *wl_callback;
|
||||||
bool fullscreen, configured, frame_drawn, swap_complete, running;
|
bool fullscreen, running;
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_X11
|
#if HAVE_X11
|
||||||
int screen;
|
int screen;
|
||||||
|
@ -21,38 +21,6 @@
|
|||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <sys/mman.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
|
static void
|
||||||
hide_cursor(void)
|
hide_cursor(void)
|
||||||
{
|
{
|
||||||
@ -63,21 +31,6 @@ hide_cursor(void)
|
|||||||
GLWin.pointer.serial, NULL, 0, 0);
|
GLWin.pointer.serial, NULL, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
static void
|
||||||
handle_ping(void *data, struct wl_shell_surface *wl_shell_surface,
|
handle_ping(void *data, struct wl_shell_surface *wl_shell_surface,
|
||||||
uint32_t serial)
|
uint32_t serial)
|
||||||
@ -89,7 +42,6 @@ static void
|
|||||||
handle_configure(void *data, struct wl_shell_surface *wl_shell_surface,
|
handle_configure(void *data, struct wl_shell_surface *wl_shell_surface,
|
||||||
uint32_t edges, int32_t width, int32_t height)
|
uint32_t edges, int32_t width, int32_t height)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (GLWin.wl_egl_native)
|
if (GLWin.wl_egl_native)
|
||||||
wl_egl_window_resize(GLWin.wl_egl_native, width, height, 0, 0);
|
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;
|
GLWin.pointer.serial = serial;
|
||||||
|
|
||||||
if (GLWin.fullscreen)
|
hide_cursor();
|
||||||
hide_cursor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -157,19 +108,10 @@ static const struct wl_pointer_listener pointer_listener = {
|
|||||||
pointer_handle_axis,
|
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
|
static void
|
||||||
toggle_fullscreen(bool fullscreen)
|
toggle_fullscreen(bool fullscreen)
|
||||||
{
|
{
|
||||||
GLWin.fullscreen = fullscreen;
|
GLWin.fullscreen = fullscreen;
|
||||||
GLWin.configured = false;
|
|
||||||
|
|
||||||
if (fullscreen) {
|
if (fullscreen) {
|
||||||
wl_shell_surface_set_fullscreen(GLWin.wl_shell_surface,
|
wl_shell_surface_set_fullscreen(GLWin.wl_shell_surface,
|
||||||
@ -181,8 +123,6 @@ toggle_fullscreen(bool fullscreen)
|
|||||||
GLWin.window_size.width,
|
GLWin.window_size.width,
|
||||||
GLWin.window_size.height);
|
GLWin.window_size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_callback_listener();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -251,9 +191,10 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
|
|||||||
if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
|
if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (key == KEY_ESC)
|
if (key == KEY_ESC) {
|
||||||
GLWin.running = false;
|
Core::Stop();
|
||||||
else if ((key == KEY_P) ||
|
GLWin.running = 0;
|
||||||
|
} else if ((key == KEY_P) ||
|
||||||
((key == KEY_ENTER) && (GLWin.keyboard.modifiers == 0)))
|
((key == KEY_ENTER) && (GLWin.keyboard.modifiers == 0)))
|
||||||
Core::SetState((Core::GetState() == Core::CORE_RUN) ?
|
Core::SetState((Core::GetState() == Core::CORE_RUN) ?
|
||||||
Core::CORE_PAUSE : 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,
|
wl_registry_add_listener(GLWin.wl_registry,
|
||||||
®istry_listener, NULL);
|
®istry_listener, NULL);
|
||||||
|
|
||||||
wl_display_dispatch(GLWin.wl_display);
|
while (!GLWin.wl_compositor)
|
||||||
|
wl_display_dispatch(GLWin.wl_display);
|
||||||
|
|
||||||
GLWin.wl_cursor_surface =
|
GLWin.wl_cursor_surface =
|
||||||
wl_compositor_create_surface(GLWin.wl_compositor);
|
wl_compositor_create_surface(GLWin.wl_compositor);
|
||||||
@ -430,8 +372,6 @@ void *cWaylandInterface::CreateWindow(void)
|
|||||||
GLWin.window_size.width = 640;
|
GLWin.window_size.width = 640;
|
||||||
GLWin.window_size.height = 480;
|
GLWin.window_size.height = 480;
|
||||||
GLWin.fullscreen = true;
|
GLWin.fullscreen = true;
|
||||||
GLWin.frame_drawn = false;
|
|
||||||
GLWin.swap_complete = false;
|
|
||||||
|
|
||||||
GLWin.wl_surface = wl_compositor_create_surface(GLWin.wl_compositor);
|
GLWin.wl_surface = wl_compositor_create_surface(GLWin.wl_compositor);
|
||||||
GLWin.wl_shell_surface = wl_shell_get_shell_surface(GLWin.wl_shell,
|
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.wl_egl_native = wl_egl_window_create(GLWin.wl_surface,
|
||||||
GLWin.window_size.width,
|
GLWin.window_size.width,
|
||||||
GLWin.window_size.height);
|
GLWin.window_size.height);
|
||||||
#if HAVE_X11
|
|
||||||
return GLWin.wl_egl_native;
|
return GLWin.wl_egl_native;
|
||||||
#else
|
|
||||||
return GLWin.wl_egl_native;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cWaylandInterface::DestroyWindow(void)
|
void cWaylandInterface::DestroyWindow(void)
|
||||||
@ -468,5 +405,19 @@ void cWaylandInterface::UpdateFPSDisplay(const char *text)
|
|||||||
|
|
||||||
void cWaylandInterface::ToggleFullscreen(bool fullscreen)
|
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);
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ public:
|
|||||||
void DestroyWindow(void);
|
void DestroyWindow(void);
|
||||||
void UpdateFPSDisplay(const char *text);
|
void UpdateFPSDisplay(const char *text);
|
||||||
void ToggleFullscreen(bool fullscreen);
|
void ToggleFullscreen(bool fullscreen);
|
||||||
|
void SwapBuffers();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -120,6 +120,11 @@ void cXInterface::UpdateFPSDisplay(const char *text)
|
|||||||
XStoreName(GLWin.evdpy, GLWin.win, text);
|
XStoreName(GLWin.evdpy, GLWin.win, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cXInterface::SwapBuffers()
|
||||||
|
{
|
||||||
|
eglSwapBuffers(GLWin.egl_dpy, GLWin.egl_surf);
|
||||||
|
}
|
||||||
|
|
||||||
void cXInterface::XEventThread()
|
void cXInterface::XEventThread()
|
||||||
#else
|
#else
|
||||||
void cX11Window::CreateXWindow(void)
|
void cX11Window::CreateXWindow(void)
|
||||||
|
@ -33,6 +33,7 @@ public:
|
|||||||
void *CreateWindow(void);
|
void *CreateWindow(void);
|
||||||
void DestroyWindow(void);
|
void DestroyWindow(void);
|
||||||
void UpdateFPSDisplay(const char *text);
|
void UpdateFPSDisplay(const char *text);
|
||||||
|
void SwapBuffers();
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
class cX11Window
|
class cX11Window
|
||||||
|
@ -10,12 +10,17 @@
|
|||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "FileUtil.h"
|
#include "FileUtil.h"
|
||||||
|
|
||||||
#if defined HAVE_X11 && HAVE_X11
|
#if HAVE_X11
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include "State.h"
|
#include "State.h"
|
||||||
#include "X11Utils.h"
|
#include "X11Utils.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_WAYLAND
|
||||||
|
#include <wayland-client.h>
|
||||||
|
#include "GLInterface/Platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#endif
|
#endif
|
||||||
@ -122,7 +127,7 @@ void Host_SysMessage(const char *fmt, ...)
|
|||||||
|
|
||||||
void Host_SetWiiMoteConnectionState(int _State) {}
|
void Host_SetWiiMoteConnectionState(int _State) {}
|
||||||
|
|
||||||
#if defined(HAVE_X11) && HAVE_X11
|
#if HAVE_X11
|
||||||
void X11_MainLoop()
|
void X11_MainLoop()
|
||||||
{
|
{
|
||||||
bool fullscreen = SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen;
|
bool fullscreen = SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen;
|
||||||
@ -256,6 +261,23 @@ void X11_MainLoop()
|
|||||||
}
|
}
|
||||||
#endif
|
#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[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@ -304,9 +326,34 @@ int main(int argc, char* argv[])
|
|||||||
m_LocalCoreStartupParameter.m_strVideoBackend);
|
m_LocalCoreStartupParameter.m_strVideoBackend);
|
||||||
WiimoteReal::LoadSettings();
|
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
|
// No use running the loop when booting fails
|
||||||
if (BootManager::BootCore(argv[optind]))
|
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__
|
#ifdef __APPLE__
|
||||||
while (running)
|
while (running)
|
||||||
{
|
{
|
||||||
@ -328,9 +375,6 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
[event release];
|
[event release];
|
||||||
[pool release];
|
[pool release];
|
||||||
#elif defined HAVE_X11 && HAVE_X11
|
|
||||||
XInitThreads();
|
|
||||||
X11_MainLoop();
|
|
||||||
#else
|
#else
|
||||||
while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)
|
while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)
|
||||||
updateMainFrameEvent.Wait();
|
updateMainFrameEvent.Wait();
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
#include "ControllerInterface.h"
|
#include "ControllerInterface.h"
|
||||||
|
|
||||||
|
#if USE_EGL
|
||||||
|
#include "GLInterface/Platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CIFACE_USE_XINPUT
|
#ifdef CIFACE_USE_XINPUT
|
||||||
#include "XInput/XInput.h"
|
#include "XInput/XInput.h"
|
||||||
#endif
|
#endif
|
||||||
@ -50,10 +54,16 @@ void ControllerInterface::Initialize()
|
|||||||
ciface::XInput::Init(m_devices);
|
ciface::XInput::Init(m_devices);
|
||||||
#endif
|
#endif
|
||||||
#ifdef CIFACE_USE_XLIB
|
#ifdef CIFACE_USE_XLIB
|
||||||
|
#if USE_EGL
|
||||||
|
if (GLWin.platform == EGL_PLATFORM_X11) {
|
||||||
|
#endif
|
||||||
ciface::Xlib::Init(m_devices, m_hwnd);
|
ciface::Xlib::Init(m_devices, m_hwnd);
|
||||||
#ifdef CIFACE_USE_X11_XINPUT2
|
#ifdef CIFACE_USE_X11_XINPUT2
|
||||||
ciface::XInput2::Init(m_devices, m_hwnd);
|
ciface::XInput2::Init(m_devices, m_hwnd);
|
||||||
#endif
|
#endif
|
||||||
|
#if USE_EGL
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef CIFACE_USE_OSX
|
#ifdef CIFACE_USE_OSX
|
||||||
ciface::OSX::Init(m_devices, m_hwnd);
|
ciface::OSX::Init(m_devices, m_hwnd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user