diff --git a/CMakeLists.txt b/CMakeLists.txt index be92b6c222..0d5159b000 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,6 @@ cmake_minimum_required(VERSION 2.8) option(ANDROID "Enables a build for Android" OFF) option(USE_EGL "Enables EGL OpenGL Interface" OFF) option(TRY_X11 "Enables X11 Support" ON) -option(TRY_WAYLAND "Enables Wayland Support" OFF) option(USE_UPNP "Enables UPnP port mapping support" ON) option(DISABLE_WX "Disable wxWidgets (use CLI interface)" OFF) option(ENABLE_PCH "Use PCH to speed up compilation" ON) @@ -324,7 +323,6 @@ if(ANDROID) message("Building for Android") add_definitions(-DANDROID) set(USE_X11 0) - set(USE_WAYLAND 0) set(USE_UPNP 0) set(USE_EGL 1) endif() @@ -407,26 +405,8 @@ if(NOT ANDROID) endif(OPENAL_FOUND) set(USE_X11 0) - set(USE_WAYLAND 0) if(UNIX AND NOT APPLE) - # Note: The convention is to check TRY_X11 or TRY_WAYLAND where needed. - # This is where we detect platforms and set the variables accordingly. - pkg_check_modules(WAYLAND wayland-egl wayland-client wayland-cursor) - if(TRY_WAYLAND AND WAYLAND_FOUND) - pkg_check_modules(XKBCOMMON xkbcommon) - if(XKBCOMMON_FOUND) - set(USE_WAYLAND 1) - add_definitions(-DHAVE_WAYLAND) - include_directories(${WAYLAND_INCLUDE_DIR}) - message("Wayland support enabled") - endif(XKBCOMMON_FOUND) - else() - set(USE_WAYLAND 0) - message("Wayland support disabled") - add_definitions(-DHAVE_WAYLAND=0) - endif(TRY_WAYLAND AND WAYLAND_FOUND) - # Note: We do not need to explicitly check for X11 as it is done in the cmake # FindOpenGL module on linux. if(TRY_X11 AND X11_FOUND) @@ -441,19 +421,13 @@ if(NOT ANDROID) add_definitions(-DHAVE_X11=0) endif(TRY_X11 AND X11_FOUND) - if (NOT USE_WAYLAND AND NOT USE_X11) + if (NOT USE_X11) message(FATAL_ERROR "\n" "No suitable display platform found\n" - "Requires wayland or x11 to run") + "Requires x11 to run") endif() endif() - # For now Wayland and EGL are tied to each other. - # The alternative would be an shm path - if(USE_WAYLAND) - set(USE_EGL 1) - endif() - if(USE_X11) check_lib(XRANDR Xrandr) if(XRANDR_FOUND) diff --git a/Source/Core/DolphinWX/CMakeLists.txt b/Source/Core/DolphinWX/CMakeLists.txt index 9717e50a4b..82ef1236a1 100644 --- a/Source/Core/DolphinWX/CMakeLists.txt +++ b/Source/Core/DolphinWX/CMakeLists.txt @@ -10,9 +10,6 @@ if(NOT ANDROID) if(USE_X11) set(LIBS ${LIBS} ${XRANDR_LIBRARIES}) endif() - if(USE_WAYLAND) - set(LIBS ${LIBS} ${WAYLAND_LIBRARIES} ${XKBCOMMON_LIBRARIES}) - endif() link_directories(${CMAKE_PREFIX_PATH}/lib) else() @@ -78,9 +75,6 @@ set(ANDROID_SRCS Android/ButtonManager.cpp if(USE_EGL) set(SRCS ${SRCS} GLInterface/Platform.cpp GLInterface/EGL.cpp) - if(USE_WAYLAND) - set(SRCS ${SRCS} GLInterface/Wayland_Util.cpp) - endif() if(USE_X11) set(SRCS ${SRCS} GLInterface/X11_Util.cpp) endif() diff --git a/Source/Core/DolphinWX/GLInterface/EGL.cpp b/Source/Core/DolphinWX/GLInterface/EGL.cpp index 440e4bab03..d336a8e63f 100644 --- a/Source/Core/DolphinWX/GLInterface/EGL.cpp +++ b/Source/Core/DolphinWX/GLInterface/EGL.cpp @@ -93,9 +93,6 @@ bool cInterfaceEGL::Create(void *&window_handle) const char *s; EGLint egl_major, egl_minor; - if (!Platform.SelectDisplay()) - return false; - GLWin.egl_dpy = Platform.EGLGetDisplay(); if (!GLWin.egl_dpy) @@ -104,8 +101,6 @@ bool cInterfaceEGL::Create(void *&window_handle) return false; } - GLWin.platform = Platform.platform; - if (!eglInitialize(GLWin.egl_dpy, &egl_major, &egl_minor)) { INFO_LOG(VIDEO, "Error: eglInitialize() failed\n"); diff --git a/Source/Core/DolphinWX/GLInterface/EGL.h b/Source/Core/DolphinWX/GLInterface/EGL.h index e2994f3b96..5a66a41f79 100644 --- a/Source/Core/DolphinWX/GLInterface/EGL.h +++ b/Source/Core/DolphinWX/GLInterface/EGL.h @@ -17,18 +17,12 @@ private: #if HAVE_X11 cXInterface XInterface; #endif -#if HAVE_WAYLAND - cWaylandInterface WaylandInterface; -#endif public: - enum egl_platform platform; - bool SelectDisplay(void); bool Init(EGLConfig config, void *window_handle); EGLDisplay EGLGetDisplay(void); EGLNativeWindowType CreateWindow(void); void DestroyWindow(void); void UpdateFPSDisplay(const std::string& text); - void ToggleFullscreen(bool fullscreen); void SwapBuffers(); }; diff --git a/Source/Core/DolphinWX/GLInterface/GLInterface.h b/Source/Core/DolphinWX/GLInterface/GLInterface.h index c57194140e..b837a671f4 100644 --- a/Source/Core/DolphinWX/GLInterface/GLInterface.h +++ b/Source/Core/DolphinWX/GLInterface/GLInterface.h @@ -7,23 +7,11 @@ #include "Common/Thread.h" #if USE_EGL -// Currently Wayland/EGL and X11/EGL platforms are supported. -// The platform may be spelected at run time by setting the -// environment variable DOLPHIN_EGL_PLATFORM to "wayland" or "x11". - -enum egl_platform { - EGL_PLATFORM_NONE, - EGL_PLATFORM_WAYLAND, - EGL_PLATFORM_X11, - EGL_PLATFORM_ANDROID -}; +// Currently Android/EGL and X11/EGL platforms are supported. #if HAVE_X11 #include "DolphinWX/GLInterface/X11_Util.h" #endif -#if HAVE_WAYLAND -#include "DolphinWX/GLInterface/Wayland_Util.h" -#endif #include "DolphinWX/GLInterface/EGL.h" #elif defined(__APPLE__) @@ -37,55 +25,11 @@ enum egl_platform { #error Platform doesnt have a GLInterface #endif -#if HAVE_WAYLAND -struct geometry { - int width; - int height; -}; - -struct xkb { - struct xkb_context *context; - struct xkb_keymap *keymap; - struct xkb_state *state; - xkb_mod_mask_t control_mask; - xkb_mod_mask_t alt_mask; - xkb_mod_mask_t shift_mask; -}; -#endif - typedef struct { -#if HAVE_WAYLAND - struct wl_display *wl_display; - struct wl_registry *wl_registry; - struct wl_compositor *wl_compositor; - struct wl_shell *wl_shell; - struct wl_seat *wl_seat; - struct { - struct wl_pointer *wl_pointer; - uint32_t serial; - } pointer; - struct { - struct wl_keyboard *wl_keyboard; - struct xkb xkb; - uint32_t modifiers; - } keyboard; - struct wl_shm *wl_shm; - struct wl_cursor_theme *wl_cursor_theme; - struct wl_cursor *wl_cursor; - struct wl_surface *wl_cursor_surface; - struct geometry geometry, window_size; - struct wl_egl_window *wl_egl_native; - struct wl_surface *wl_surface; - struct wl_shell_surface *wl_shell_surface; - bool fullscreen, running; -#endif - - #if USE_EGL EGLSurface egl_surf; EGLContext egl_ctx; EGLDisplay egl_dpy; - enum egl_platform platform; EGLNativeWindowType native_window; #elif HAVE_X11 GLXContext ctx; diff --git a/Source/Core/DolphinWX/GLInterface/Platform.cpp b/Source/Core/DolphinWX/GLInterface/Platform.cpp index 86b12858dc..cdd78e973d 100644 --- a/Source/Core/DolphinWX/GLInterface/Platform.cpp +++ b/Source/Core/DolphinWX/GLInterface/Platform.cpp @@ -6,130 +6,12 @@ #include "Core/Host.h" #include "DolphinWX/GLInterface/GLInterface.h" -bool cPlatform::SelectDisplay(void) -{ - enum egl_platform selected_platform = EGL_PLATFORM_NONE; - enum egl_platform desired_platform = EGL_PLATFORM_NONE; - char *platform_env = getenv("DOLPHIN_EGL_PLATFORM"); - - if (platform_env) - platform_env = strdup(platform_env); - - if (!platform_env) - printf("Running automatic platform detection\n"); - - // Try to select the platform set in the environment variable first -#if HAVE_WAYLAND - bool wayland_possible = WaylandInterface.ServerConnect(); - - if (platform_env && !strcmp(platform_env, "wayland")) - { - desired_platform = EGL_PLATFORM_WAYLAND; - if (wayland_possible) - selected_platform = EGL_PLATFORM_WAYLAND; - else - printf("Wayland display server connection failed\n"); - } -#endif - -#if HAVE_X11 - bool x11_possible = XInterface.ServerConnect(); - - if (platform_env && !strcmp(platform_env, "x11")) - { - desired_platform = EGL_PLATFORM_X11; - if ((selected_platform != EGL_PLATFORM_WAYLAND) && x11_possible) - selected_platform = EGL_PLATFORM_X11; - else - printf("X11 display server connection failed\n"); - } -#endif - // Fall back to automatic detection - if (selected_platform == EGL_PLATFORM_NONE) - { - if (platform_env && (desired_platform == EGL_PLATFORM_NONE)) { - printf("DOLPHIN_EGL_PLATFORM set to unrecognized platform \"%s\".\n" -#if HAVE_WAYLAND && !HAVE_X11 - "Note: Valid value is \"wayland\" (built without x11 support)\n", -#endif -#if HAVE_X11 && !HAVE_WAYLAND - "Note: Valid values is \"x11\" (built without wayland support)\n", -#endif -#if HAVE_WAYLAND && HAVE_X11 - "Note: Valid values are \"wayland\" and \"x11\"\n", -#endif -#if !HAVE_WAYLAND && !HAVE_X11 - "Note: No Valid platform. Must be Android\n", -#endif - platform_env); - free(platform_env); - platform_env = nullptr; - } -#if HAVE_WAYLAND - if (wayland_possible) - { - selected_platform = EGL_PLATFORM_WAYLAND; - platform_env = strdup("wayland"); - } -#endif -#if HAVE_X11 - if ((selected_platform != EGL_PLATFORM_WAYLAND) && x11_possible) - { - selected_platform = EGL_PLATFORM_X11; - platform_env = strdup("x11"); - } -#endif -#ifdef ANDROID - selected_platform = EGL_PLATFORM_ANDROID; -#endif - if (selected_platform == EGL_PLATFORM_NONE) - { - printf("FATAL: Failed to find suitable platform for display connection\n"); - goto out; - } - } - - printf("Using EGL Native Display Platform: %s\n", platform_env); -out: - cPlatform::platform = selected_platform; - free(platform_env); -#if HAVE_WAYLAND - if (selected_platform != EGL_PLATFORM_WAYLAND) { - if (GLWin.wl_display) - wl_display_disconnect(GLWin.wl_display); - } - -#endif -#if HAVE_X11 - if (selected_platform != EGL_PLATFORM_X11) { - if (GLWin.dpy) - { - XCloseDisplay(GLWin.dpy); - } - } -#endif -#if ANDROID - selected_platform = EGL_PLATFORM_ANDROID; -#endif - if (selected_platform == EGL_PLATFORM_NONE) - return false; - - return true; -} - bool cPlatform::Init(EGLConfig config, void *window_handle) { -#if HAVE_WAYLAND - if (cPlatform::platform == EGL_PLATFORM_WAYLAND) - if (!WaylandInterface.Initialize(config)) - return false; -#endif #if HAVE_X11 - if (cPlatform::platform == EGL_PLATFORM_X11) - if (!XInterface.Initialize(config, window_handle)) - return false; -#endif -#ifdef ANDROID + if (!XInterface.Initialize(config, window_handle)) + return false; +#elif ANDROID EGLint format; eglGetConfigAttrib(GLWin.egl_dpy, config, EGL_NATIVE_VISUAL_ID, &format); ANativeWindow_setBuffersGeometry((EGLNativeWindowType)Host_GetRenderHandle(), 0, 0, format); @@ -142,15 +24,9 @@ bool cPlatform::Init(EGLConfig config, void *window_handle) EGLDisplay cPlatform::EGLGetDisplay(void) { -#if HAVE_WAYLAND - if (cPlatform::platform == EGL_PLATFORM_WAYLAND) - return (EGLDisplay) WaylandInterface.EGLGetDisplay(); -#endif #if HAVE_X11 - if (cPlatform::platform == EGL_PLATFORM_X11) - return (EGLDisplay) XInterface.EGLGetDisplay(); -#endif -#ifdef ANDROID + return (EGLDisplay) XInterface.EGLGetDisplay(); +#elif ANDROID return eglGetDisplay(EGL_DEFAULT_DISPLAY); #endif return nullptr; @@ -158,13 +34,8 @@ EGLDisplay cPlatform::EGLGetDisplay(void) EGLNativeWindowType cPlatform::CreateWindow(void) { -#if HAVE_WAYLAND - if (cPlatform::platform == EGL_PLATFORM_WAYLAND) - return (EGLNativeWindowType) WaylandInterface.CreateWindow(); -#endif #if HAVE_X11 - if (cPlatform::platform == EGL_PLATFORM_X11) - return (EGLNativeWindowType) XInterface.CreateWindow(); + return (EGLNativeWindowType) XInterface.CreateWindow(); #endif #ifdef ANDROID return (EGLNativeWindowType)Host_GetRenderHandle(); @@ -174,52 +45,24 @@ EGLNativeWindowType cPlatform::CreateWindow(void) void cPlatform::DestroyWindow(void) { -#if HAVE_WAYLAND - if (cPlatform::platform == EGL_PLATFORM_WAYLAND) - WaylandInterface.DestroyWindow(); -#endif #if HAVE_X11 - if (cPlatform::platform == EGL_PLATFORM_X11) - XInterface.DestroyWindow(); + XInterface.DestroyWindow(); #endif } void cPlatform::UpdateFPSDisplay(const std::string& text) { -#if HAVE_WAYLAND - if (cPlatform::platform == EGL_PLATFORM_WAYLAND) - WaylandInterface.UpdateFPSDisplay(text); -#endif #if HAVE_X11 - if (cPlatform::platform == EGL_PLATFORM_X11) - XInterface.UpdateFPSDisplay(text); -#endif -} - -void -cPlatform::ToggleFullscreen(bool fullscreen) -{ -#if HAVE_WAYLAND - if (cPlatform::platform == EGL_PLATFORM_WAYLAND) - WaylandInterface.ToggleFullscreen(fullscreen); -#endif -#if HAVE_X11 - // Only wayland uses this function + XInterface.UpdateFPSDisplay(text); #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 -#if ANDROID + XInterface.SwapBuffers(); +#elif ANDROID eglSwapBuffers(GLWin.egl_dpy, GLWin.egl_surf); #endif } diff --git a/Source/Core/DolphinWX/GLInterface/Wayland_Util.cpp b/Source/Core/DolphinWX/GLInterface/Wayland_Util.cpp deleted file mode 100644 index 577d8a5a13..0000000000 --- a/Source/Core/DolphinWX/GLInterface/Wayland_Util.cpp +++ /dev/null @@ -1,404 +0,0 @@ -// Copyright (C) 2013 Scott Moreau -// Licensed under GPLv2 -// Refer to the license.txt file included. - -#include -#include - -#include "Core/Core.h" -#include "Core/State.h" -#include "DolphinWX/GLInterface/GLInterface.h" - -static void -hide_cursor(void) -{ - if (!GLWin.pointer.wl_pointer) - return; - - wl_pointer_set_cursor(GLWin.pointer.wl_pointer, - GLWin.pointer.serial, nullptr, 0, 0); -} - -static void -handle_ping(void *data, struct wl_shell_surface *wl_shell_surface, - uint32_t serial) -{ - wl_shell_surface_pong(wl_shell_surface, serial); -} - -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); - - GLWin.geometry.width = width; - GLWin.geometry.height = height; - - GLInterface->SetBackBufferDimensions(width, height); - - if (!GLWin.fullscreen) - GLWin.window_size = GLWin.geometry; -} - -static void -handle_popup_done(void *data, struct wl_shell_surface *wl_shell_surface) -{ -} - -static const struct wl_shell_surface_listener shell_surface_listener = { - handle_ping, - handle_configure, - handle_popup_done -}; - -static void -pointer_handle_enter(void *data, struct wl_pointer *pointer, - uint32_t serial, struct wl_surface *surface, - wl_fixed_t sx, wl_fixed_t sy) -{ - GLWin.pointer.serial = serial; - - hide_cursor(); -} - -static void -pointer_handle_leave(void *data, struct wl_pointer *pointer, - uint32_t serial, struct wl_surface *surface) -{ -} - -static void -pointer_handle_motion(void *data, struct wl_pointer *pointer, - uint32_t time, wl_fixed_t sx, wl_fixed_t sy) -{ -} - -static void -pointer_handle_button(void *data, struct wl_pointer *wl_pointer, - uint32_t serial, uint32_t time, uint32_t button, - uint32_t state) -{ -} - -static void -pointer_handle_axis(void *data, struct wl_pointer *wl_pointer, - uint32_t time, uint32_t axis, wl_fixed_t value) -{ -} - -static const struct wl_pointer_listener pointer_listener = { - pointer_handle_enter, - pointer_handle_leave, - pointer_handle_motion, - pointer_handle_button, - pointer_handle_axis, -}; - -static void -toggle_fullscreen(bool fullscreen) -{ - GLWin.fullscreen = fullscreen; - - if (fullscreen) { - wl_shell_surface_set_fullscreen(GLWin.wl_shell_surface, - WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, - 0, nullptr); - } else { - wl_shell_surface_set_toplevel(GLWin.wl_shell_surface); - handle_configure(nullptr, GLWin.wl_shell_surface, 0, - GLWin.window_size.width, - GLWin.window_size.height); - } -} - -static void -keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, - uint32_t format, int fd, uint32_t size) -{ - char *map_str; - - if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) { - close(fd); - return; - } - - map_str = (char *) mmap(nullptr, size, PROT_READ, MAP_SHARED, fd, 0); - if (map_str == MAP_FAILED) { - close(fd); - return; - } - - GLWin.keyboard.xkb.keymap = xkb_map_new_from_string(GLWin.keyboard.xkb.context, - map_str, - XKB_KEYMAP_FORMAT_TEXT_V1, - (xkb_keymap_compile_flags) 0); - munmap(map_str, size); - close(fd); - - if (!GLWin.keyboard.xkb.keymap) { - fprintf(stderr, "failed to compile keymap\n"); - return; - } - - GLWin.keyboard.xkb.state = xkb_state_new(GLWin.keyboard.xkb.keymap); - if (!GLWin.keyboard.xkb.state) { - fprintf(stderr, "failed to create XKB state\n"); - xkb_map_unref(GLWin.keyboard.xkb.keymap); - GLWin.keyboard.xkb.keymap = nullptr; - return; - } - - GLWin.keyboard.xkb.control_mask = - 1 << xkb_map_mod_get_index(GLWin.keyboard.xkb.keymap, "Control"); - GLWin.keyboard.xkb.alt_mask = - 1 << xkb_map_mod_get_index(GLWin.keyboard.xkb.keymap, "Mod1"); - GLWin.keyboard.xkb.shift_mask = - 1 << xkb_map_mod_get_index(GLWin.keyboard.xkb.keymap, "Shift"); -} - -static void -keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, - uint32_t serial, struct wl_surface *surface, - struct wl_array *keys) -{ -} - -static void -keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, - uint32_t serial, struct wl_surface *surface) -{ -} - -static void -keyboard_handle_key(void *data, struct wl_keyboard *keyboard, - uint32_t serial, uint32_t time, uint32_t key, - uint32_t state) -{ - if (state == WL_KEYBOARD_KEY_STATE_RELEASED) - return; - - 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); - else if (key == KEY_F) - toggle_fullscreen(!GLWin.fullscreen); - else if ((key == KEY_ENTER) && (GLWin.keyboard.modifiers == MOD_ALT_MASK)) - toggle_fullscreen(!GLWin.fullscreen); - else if (key >= KEY_F1 && key <= KEY_F8) { - int slot_number = key - KEY_F1 + 1; - if (GLWin.keyboard.modifiers == MOD_SHIFT_MASK) - State::Save(slot_number); - else - State::Load(slot_number); - } - else if (key == KEY_F9) - Core::SaveScreenShot(); - else if (key == KEY_F11) - State::LoadLastSaved(); - else if (key == KEY_F12) { - if (GLWin.keyboard.modifiers == MOD_SHIFT_MASK) - State::UndoLoadState(); - else - State::UndoSaveState(); - } -} - -static void -keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, - uint32_t serial, uint32_t mods_depressed, - uint32_t mods_latched, uint32_t mods_locked, - uint32_t group) -{ - xkb_mod_mask_t mask; - - xkb_state_update_mask(GLWin.keyboard.xkb.state, mods_depressed, mods_latched, - mods_locked, 0, 0, group); - mask = xkb_state_serialize_mods(GLWin.keyboard.xkb.state, - (xkb_state_component) - (XKB_STATE_DEPRESSED | - XKB_STATE_LATCHED)); - GLWin.keyboard.modifiers = 0; - if (mask & GLWin.keyboard.xkb.control_mask) - GLWin.keyboard.modifiers |= MOD_CONTROL_MASK; - if (mask & GLWin.keyboard.xkb.alt_mask) - GLWin.keyboard.modifiers |= MOD_ALT_MASK; - if (mask & GLWin.keyboard.xkb.shift_mask) - GLWin.keyboard.modifiers |= MOD_SHIFT_MASK; -} - -static const struct wl_keyboard_listener keyboard_listener = { - keyboard_handle_keymap, - keyboard_handle_enter, - keyboard_handle_leave, - keyboard_handle_key, - keyboard_handle_modifiers, -}; - -static void -seat_handle_capabilities(void *data, struct wl_seat *seat, - uint32_t caps) -{ - struct wl_pointer *wl_pointer = nullptr; - struct wl_keyboard *wl_keyboard = nullptr; - - if ((caps & WL_SEAT_CAPABILITY_POINTER) && !wl_pointer) { - wl_pointer = wl_seat_get_pointer(seat); - wl_pointer_add_listener(wl_pointer, &pointer_listener, 0); - } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && wl_pointer) { - wl_pointer_destroy(wl_pointer); - wl_pointer = nullptr; - } - - GLWin.pointer.wl_pointer = wl_pointer; - - if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !wl_keyboard) { - wl_keyboard = wl_seat_get_keyboard(seat); - wl_keyboard_add_listener(wl_keyboard, &keyboard_listener, 0); - } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && wl_keyboard) { - wl_keyboard_destroy(wl_keyboard); - wl_keyboard = nullptr; - } - - GLWin.keyboard.wl_keyboard = wl_keyboard; -} - -static const struct wl_seat_listener seat_listener = { - seat_handle_capabilities, -}; - -static void -registry_handle_global(void *data, struct wl_registry *registry, - uint32_t name, const char *interface, uint32_t version) -{ - if (strcmp(interface, "wl_compositor") == 0) { - GLWin.wl_compositor = (wl_compositor *) - wl_registry_bind(registry, name, - &wl_compositor_interface, 1); - } else if (strcmp(interface, "wl_shell") == 0) { - GLWin.wl_shell = (wl_shell *) wl_registry_bind(registry, name, - &wl_shell_interface, 1); - } else if (strcmp(interface, "wl_seat") == 0) { - GLWin.wl_seat = (wl_seat *) wl_registry_bind(registry, name, - &wl_seat_interface, 1); - wl_seat_add_listener(GLWin.wl_seat, &seat_listener, 0); - } else if (strcmp(interface, "wl_shm") == 0) { - GLWin.wl_shm = (wl_shm *) wl_registry_bind(registry, name, - &wl_shm_interface, 1); - GLWin.wl_cursor_theme = (wl_cursor_theme *) wl_cursor_theme_load(nullptr, 32, GLWin.wl_shm); - GLWin.wl_cursor = (wl_cursor *) - wl_cursor_theme_get_cursor(GLWin.wl_cursor_theme, "left_ptr"); - } -} - -static void -registry_handle_global_remove(void *data, struct wl_registry *registry, - uint32_t name) -{ -} - -static const struct wl_registry_listener registry_listener = { - registry_handle_global, - registry_handle_global_remove -}; - -bool cWaylandInterface::ServerConnect(void) -{ - GLWin.wl_display = wl_display_connect(nullptr); - - if (!GLWin.wl_display) - return false; - - return true; -} - -bool cWaylandInterface::Initialize(void *config) -{ - if (!GLWin.wl_display) { - printf("Error: couldn't open wayland display\n"); - return false; - } - - GLWin.pointer.wl_pointer = nullptr; - GLWin.keyboard.wl_keyboard = nullptr; - - GLWin.keyboard.xkb.context = xkb_context_new((xkb_context_flags) 0); - if (GLWin.keyboard.xkb.context == nullptr) { - fprintf(stderr, "Failed to create XKB context\n"); - return nullptr; - } - - GLWin.wl_registry = wl_display_get_registry(GLWin.wl_display); - wl_registry_add_listener(GLWin.wl_registry, - ®istry_listener, nullptr); - - while (!GLWin.wl_compositor) - wl_display_dispatch(GLWin.wl_display); - - GLWin.wl_cursor_surface = - wl_compositor_create_surface(GLWin.wl_compositor); - - return true; -} - -void *cWaylandInterface::EGLGetDisplay(void) -{ - return eglGetDisplay(GLWin.wl_display); -} - -void *cWaylandInterface::CreateWindow(void) -{ - GLWin.window_size.width = 640; - GLWin.window_size.height = 480; - GLWin.fullscreen = true; - - GLWin.wl_surface = wl_compositor_create_surface(GLWin.wl_compositor); - GLWin.wl_shell_surface = wl_shell_get_shell_surface(GLWin.wl_shell, - GLWin.wl_surface); - - wl_shell_surface_add_listener(GLWin.wl_shell_surface, - &shell_surface_listener, 0); - - GLWin.wl_egl_native = wl_egl_window_create(GLWin.wl_surface, - GLWin.window_size.width, - GLWin.window_size.height); - - return GLWin.wl_egl_native; -} - -void cWaylandInterface::DestroyWindow(void) -{ - wl_egl_window_destroy(GLWin.wl_egl_native); - - wl_shell_surface_destroy(GLWin.wl_shell_surface); - wl_surface_destroy(GLWin.wl_surface); -} - -void cWaylandInterface::UpdateFPSDisplay(const std::string& text) -{ - wl_shell_surface_set_title(GLWin.wl_shell_surface, text.c_str()); -} - -void cWaylandInterface::ToggleFullscreen(bool 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 deleted file mode 100644 index 53caf62f79..0000000000 --- a/Source/Core/DolphinWX/GLInterface/Wayland_Util.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2013 Scott Moreau -// Licensed under GPLv2 -// Refer to the license.txt file included. - -#pragma once - -#include -#include -#include -#include -#include - -#define MOD_SHIFT_MASK 0x01 -#define MOD_ALT_MASK 0x02 -#define MOD_CONTROL_MASK 0x04 - - -class cWaylandInterface -{ -public: - bool ServerConnect(void); - bool Initialize(void *config); - void *EGLGetDisplay(void); - void *CreateWindow(void); - void DestroyWindow(void); - void UpdateFPSDisplay(const std::string& text); - void ToggleFullscreen(bool fullscreen); - void SwapBuffers(); -}; diff --git a/Source/Core/DolphinWX/GLInterface/X11_Util.cpp b/Source/Core/DolphinWX/GLInterface/X11_Util.cpp index 32ab4699e2..e42a744713 100644 --- a/Source/Core/DolphinWX/GLInterface/X11_Util.cpp +++ b/Source/Core/DolphinWX/GLInterface/X11_Util.cpp @@ -53,11 +53,7 @@ bool cXInterface::Initialize(void *config, void *window_handle) void *cXInterface::EGLGetDisplay(void) { -#if HAVE_WAYLAND - return eglGetDisplay((wl_display *) GLWin.dpy); -#else return eglGetDisplay(GLWin.dpy); -#endif } void *cXInterface::CreateWindow(void) diff --git a/Source/Core/DolphinWX/MainNoGUI.cpp b/Source/Core/DolphinWX/MainNoGUI.cpp index 9befeb4b59..0b9e2f783b 100644 --- a/Source/Core/DolphinWX/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/MainNoGUI.cpp @@ -29,10 +29,6 @@ #include "DolphinWX/X11Utils.h" #endif -#if HAVE_WAYLAND -#include -#endif - #ifdef USE_EGL #include "DolphinWX/GLInterface/GLInterface.h" #endif @@ -262,23 +258,6 @@ static void X11_MainLoop() } #endif -#if HAVE_WAYLAND -static 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__ @@ -330,34 +309,12 @@ 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 = nullptr; -#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 + XInitThreads(); + X11_MainLoop(); #endif #ifdef __APPLE__ while (running) diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index 366485daa2..d90b3bf02a 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -57,15 +57,10 @@ 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); + ciface::Xlib::Init(m_devices, m_hwnd); #ifdef CIFACE_USE_X11_XINPUT2 - ciface::XInput2::Init(m_devices, m_hwnd); + ciface::XInput2::Init(m_devices, m_hwnd); #endif - } #endif #ifdef CIFACE_USE_OSX ciface::OSX::Init(m_devices, m_hwnd);