diff options
Diffstat (limited to 'intern/ghost/intern/GHOST_SystemWayland.h')
-rw-r--r-- | intern/ghost/intern/GHOST_SystemWayland.h | 109 |
1 files changed, 85 insertions, 24 deletions
diff --git a/intern/ghost/intern/GHOST_SystemWayland.h b/intern/ghost/intern/GHOST_SystemWayland.h index 762ceb80e38..caea7b0d748 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.h +++ b/intern/ghost/intern/GHOST_SystemWayland.h @@ -11,17 +11,51 @@ #include "GHOST_System.h" #include "GHOST_WindowWayland.h" +#ifdef WITH_GHOST_WAYLAND_DYNLOAD +# include <wayland_dynload_client.h> +#endif #include <wayland-client.h> -#include <xdg-decoration-client-protocol.h> -#include <xdg-shell-client-protocol.h> + +#ifdef WITH_GHOST_WAYLAND_LIBDECOR +# ifdef WITH_GHOST_WAYLAND_DYNLOAD +# include <wayland_dynload_libdecor.h> +# endif +# include <libdecor.h> +#else +/* Generated by `wayland-scanner`. */ +# include <xdg-decoration-unstable-v1-client-protocol.h> +# include <xdg-shell-client-protocol.h> +#endif #include <string> class GHOST_WindowWayland; -struct display_t; +struct GWL_Display; + +bool ghost_wl_output_own(const struct wl_output *wl_output); +void ghost_wl_output_tag(struct wl_output *wl_output); +struct GWL_Output *ghost_wl_output_user_data(struct wl_output *wl_output); + +bool ghost_wl_surface_own(const struct wl_surface *surface); +void ghost_wl_surface_tag(struct wl_surface *surface); +GHOST_WindowWayland *ghost_wl_surface_user_data(struct wl_surface *surface); + +bool ghost_wl_surface_own_cursor_pointer(const struct wl_surface *surface); +void ghost_wl_surface_tag_cursor_pointer(struct wl_surface *surface); + +bool ghost_wl_surface_own_cursor_tablet(const struct wl_surface *surface); +void ghost_wl_surface_tag_cursor_tablet(struct wl_surface *surface); -struct output_t { +#ifdef WITH_GHOST_WAYLAND_DYNLOAD +/** + * Return true when all required WAYLAND libraries are present, + * Performs dynamic loading when `WITH_GHOST_WAYLAND_DYNLOAD` is in use. + */ +bool ghost_wl_dynload_libraries(); +#endif + +struct GWL_Output { struct wl_output *wl_output = nullptr; struct zxdg_output_v1 *xdg_output = nullptr; /** Dimensions in pixels. */ @@ -32,6 +66,7 @@ struct output_t { int32_t size_logical[2] = {0, 0}; bool has_size_logical = false; + /** Monitor position in pixels. */ int32_t position_logical[2] = {0, 0}; bool has_position_logical = false; @@ -58,9 +93,11 @@ class GHOST_SystemWayland : public GHOST_System { ~GHOST_SystemWayland() override; + GHOST_TSuccess init(); + bool processEvents(bool waitForEvent) override; - int setConsoleWindowState(GHOST_TConsoleWindowState action) override; + bool setConsoleWindowState(GHOST_TConsoleWindowState action) override; GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys &keys) const override; @@ -72,8 +109,14 @@ class GHOST_SystemWayland : public GHOST_System { uint8_t getNumDisplays() const override; - GHOST_TSuccess getCursorPosition(int32_t &x, int32_t &y) const override; + GHOST_TSuccess getCursorPositionClientRelative(const GHOST_IWindow *window, + int32_t &x, + int32_t &y) const override; + GHOST_TSuccess setCursorPositionClientRelative(GHOST_IWindow *window, + int32_t x, + int32_t y) override; + GHOST_TSuccess getCursorPosition(int32_t &x, int32_t &y) const override; GHOST_TSuccess setCursorPosition(int32_t x, int32_t y) override; void getMainDisplayDimensions(uint32_t &width, uint32_t &height) const override; @@ -96,20 +139,6 @@ class GHOST_SystemWayland : public GHOST_System { const bool is_dialog, const GHOST_IWindow *parentWindow) override; - wl_display *display(); - - wl_compositor *compositor(); - - xdg_wm_base *xdg_shell(); - - zxdg_decoration_manager_v1 *xdg_decoration_manager(); - - const std::vector<output_t *> &outputs() const; - - wl_shm *shm() const; - - void setSelection(const std::string &selection); - GHOST_TSuccess setCursorShape(GHOST_TStandardCursor shape); GHOST_TSuccess hasCursorShape(GHOST_TStandardCursor cursorShape); @@ -122,16 +151,48 @@ class GHOST_SystemWayland : public GHOST_System { int hotY, bool canInvertColor); + GHOST_TSuccess getCursorBitmap(GHOST_CursorBitmapRef *bitmap); + GHOST_TSuccess setCursorVisibility(bool visible); bool supportsCursorWarp(); bool supportsWindowPosition(); - GHOST_TSuccess setCursorGrab(const GHOST_TGrabCursorMode mode, - const GHOST_TGrabCursorMode mode_current, - wl_surface *surface); + bool getCursorGrabUseSoftwareDisplay(const GHOST_TGrabCursorMode mode); + + /* WAYLAND direct-data access. */ + + wl_display *display(); + + wl_compositor *compositor(); + +#ifdef WITH_GHOST_WAYLAND_LIBDECOR + libdecor *decor_context(); +#else + xdg_wm_base *xdg_shell(); + zxdg_decoration_manager_v1 *xdg_decoration_manager(); +#endif + + const std::vector<GWL_Output *> &outputs() const; + + wl_shm *shm() const; + + /* WAYLAND utility functions. */ + + void selection_set(const std::string &selection); + + /** Clear all references to this surface to prevent accessing NULL pointers. */ + void window_surface_unref(const wl_surface *wl_surface); + + bool window_cursor_grab_set(const GHOST_TGrabCursorMode mode, + const GHOST_TGrabCursorMode mode_current, + int32_t init_grab_xy[2], + const GHOST_Rect *wrap_bounds, + GHOST_TAxisFlag wrap_axis, + wl_surface *wl_surface, + int scale); private: - struct display_t *d; + struct GWL_Display *d; std::string selection; }; |