18 #include <wayland-client-protocol.h>
20 #ifdef WITH_GHOST_WAYLAND_DYNLOAD
23 #include <wayland-egl.h>
27 #ifdef WITH_GHOST_WAYLAND_LIBDECOR
28 # ifdef WITH_GHOST_WAYLAND_DYNLOAD
31 # include <libdecor.h>
62 #ifdef WITH_GHOST_WAYLAND_LIBDECOR
63 struct libdecor_frame *decor_frame =
nullptr;
64 bool decor_configured =
false;
70 enum zxdg_toplevel_decoration_v1_mode
decoration_mode = (
enum zxdg_toplevel_decoration_v1_mode)0;
101 wl_fixed_from_int(output_a->
scale);
104 wl_fixed_from_int(output_b->
scale);
105 if (scale_fractional_a < scale_fractional_b) {
108 if (scale_fractional_a > scale_fractional_b) {
119 const output_t *output_max =
nullptr;
122 output_max = reg_output;
134 return output_max->
scale;
140 return scale_default;
149 #ifndef WITH_GHOST_WAYLAND_LIBDECOR
152 # define LOG (&LOG_WL_XDG_TOPLEVEL)
171 enum xdg_toplevel_state *
state;
172 WL_ARRAY_FOR_EACH (
state, states) {
174 case XDG_TOPLEVEL_STATE_MAXIMIZED:
177 case XDG_TOPLEVEL_STATE_FULLSCREEN:
180 case XDG_TOPLEVEL_STATE_ACTIVATED:
210 #ifdef WITH_GHOST_WAYLAND_LIBDECOR
212 static CLG_LogRef LOG_WL_LIBDECOR_FRAME = {
"ghost.wl.handle.libdecor_frame"};
213 # define LOG (&LOG_WL_LIBDECOR_FRAME)
215 static void frame_handle_configure(
struct libdecor_frame *frame,
216 struct libdecor_configuration *configuration,
224 enum libdecor_window_state window_state;
225 struct libdecor_state *
state;
228 configuration, frame, &size_next[0], &size_next[1])) {
229 size_next[0] = win->
size[0] / win->
scale;
230 size_next[1] = win->
size[1] / win->
scale;
233 win->
size[0] = win->
scale * size_next[0];
234 win->
size[1] = win->
scale * size_next[1];
240 window_state = LIBDECOR_WINDOW_STATE_NONE;
243 win->
is_maximised = window_state & LIBDECOR_WINDOW_STATE_MAXIMIZED;
244 win->
is_fullscreen = window_state & LIBDECOR_WINDOW_STATE_FULLSCREEN;
245 win->
is_active = window_state & LIBDECOR_WINDOW_STATE_ACTIVE;
253 win->decor_configured =
true;
256 static void frame_handle_close(
struct libdecor_frame * ,
void *
data)
263 static void frame_handle_commit(
struct libdecor_frame * ,
void *
data)
272 static struct libdecor_frame_interface libdecor_frame_iface = {
273 frame_handle_configure,
288 #ifndef WITH_GHOST_WAYLAND_LIBDECOR
291 # define LOG (&LOG_WL_XDG_TOPLEVEL_DECORATION)
295 struct zxdg_toplevel_decoration_v1 * ,
299 static_cast<window_t *
>(
data)->decoration_mode = (zxdg_toplevel_decoration_v1_mode)mode;
316 #ifndef WITH_GHOST_WAYLAND_LIBDECOR
319 # define LOG (&LOG_WL_XDG_SURFACE)
322 xdg_surface *xdg_surface,
332 CLOG_INFO(
LOG, 2,
"configure (do_resize=%d)", do_resize);
350 xdg_surface_ack_configure(xdg_surface, serial);
368 #define LOG (&LOG_WL_SURFACE)
371 struct wl_surface * ,
388 struct wl_surface * ,
433 const bool is_dialog,
434 const bool stereoVisual,
435 const bool exclusive)
450 w->is_dialog = is_dialog;
464 w->wl_surface = wl_compositor_create_surface(m_system->
compositor());
467 wl_surface_set_buffer_scale(
w->wl_surface,
w->scale);
477 const int32_t size_min[2] = {320, 240};
479 #ifdef WITH_GHOST_WAYLAND_LIBDECOR
482 m_system->decor_context(),
w->wl_surface, &libdecor_frame_iface,
w);
492 w->xdg_surface = xdg_wm_base_get_xdg_surface(m_system->
xdg_shell(),
w->wl_surface);
493 w->xdg_toplevel = xdg_surface_get_toplevel(
w->xdg_surface);
495 xdg_toplevel_set_min_size(
w->xdg_toplevel,
UNPACK2(size_min));
498 w->xdg_toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(
500 zxdg_toplevel_decoration_v1_add_listener(
502 zxdg_toplevel_decoration_v1_set_mode(
w->xdg_toplevel_decoration,
503 ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
509 if (parentWindow && is_dialog) {
510 xdg_toplevel_set_parent(
518 wl_surface_set_user_data(
w->wl_surface,
this);
521 wl_surface_commit(
w->wl_surface);
524 #ifdef WITH_GHOST_WAYLAND_LIBDECOR
527 while (!
w->decor_configured) {
534 #ifdef GHOST_OPENGL_ALPHA
538 #ifndef WITH_GHOST_WAYLAND_LIBDECOR
544 GHOST_PRINT(
"Failed to create EGL context" << std::endl);
586 uint8_t *bitmap,
uint8_t *
mask,
int sizex,
int sizey,
int hotX,
int hotY,
bool canInvertColor)
598 #ifdef WITH_GHOST_WAYLAND_LIBDECOR
602 xdg_toplevel_set_title(
w->xdg_toplevel, title);
603 xdg_toplevel_set_app_id(
w->xdg_toplevel, title);
611 return this->title.empty() ?
"untitled" : this->title;
639 w->size_pending[0] = 0;
640 w->size_pending[1] = 0;
674 #ifdef WITH_GHOST_WAYLAND_LIBDECOR
677 if (
w->xdg_toplevel_decoration) {
678 zxdg_toplevel_decoration_v1_destroy(
w->xdg_toplevel_decoration);
680 xdg_toplevel_destroy(
w->xdg_toplevel);
681 xdg_surface_destroy(
w->xdg_surface);
688 wl_surface_destroy(
w->wl_surface);
715 #ifdef WITH_GHOST_WAYLAND_LIBDECOR
718 xdg_toplevel_unset_maximized(
w->xdg_toplevel);
722 #ifdef WITH_GHOST_WAYLAND_LIBDECOR
725 xdg_toplevel_unset_fullscreen(
w->xdg_toplevel);
733 #ifdef WITH_GHOST_WAYLAND_LIBDECOR
736 xdg_toplevel_set_maximized(
w->xdg_toplevel);
740 #ifdef WITH_GHOST_WAYLAND_LIBDECOR
743 xdg_toplevel_set_minimized(
w->xdg_toplevel);
747 #ifdef WITH_GHOST_WAYLAND_LIBDECOR
750 xdg_toplevel_set_fullscreen(
w->xdg_toplevel,
nullptr);
761 if (
w->is_fullscreen) {
764 if (
w->is_maximised) {
782 #ifdef WITH_GHOST_WAYLAND_LIBDECOR
785 xdg_toplevel_set_fullscreen(
w->xdg_toplevel,
nullptr);
792 #ifdef WITH_GHOST_WAYLAND_LIBDECOR
795 xdg_toplevel_unset_fullscreen(
w->xdg_toplevel);
805 #ifdef GHOST_OPENGL_ALPHA
806 void GHOST_WindowWayland::setOpaque()
const
808 struct wl_region *region;
811 region = wl_compositor_create_region(m_system->
compositor());
812 wl_region_add(region, 0, 0,
UNPACK2(
w->size));
813 wl_surface_set_opaque_region(
w->surface, region);
814 wl_region_destroy(region);
830 for (
int minor = 6; minor >= 0; --minor) {
833 EGLNativeWindowType(
w->egl_window),
834 EGLNativeDisplayType(m_system->
display()),
835 EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
842 if (
context->initializeDrawingContext()) {
849 EGLNativeWindowType(
w->egl_window),
850 EGLNativeDisplayType(m_system->
display()),
851 EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT,
882 return w->wl_surface;
922 #ifdef GHOST_OPENGL_ALPHA
948 const int scale_curr = win->
scale;
949 bool changed =
false;
951 if (scale_next != scale_curr) {
956 win->
scale = scale_next;
957 wl_surface_set_buffer_scale(
w->wl_surface, scale_next);
961 if (dpi_next != dpi_curr) {
973 std::vector<output_t *> &
outputs =
w->outputs;
984 std::vector<output_t *> &
outputs =
w->outputs;
KDTree *BLI_kdtree_nd_() new(unsigned int maxsize)
#define CLOG_INFO(clg_ref, level,...)
#define GHOST_OPENGL_EGL_CONTEXT_FLAGS
#define GHOST_OPENGL_EGL_RESET_NOTIFICATION_STRATEGY
void ghost_wl_surface_tag(struct wl_surface *surface)
struct output_t * ghost_wl_output_user_data(struct wl_output *wl_output)
bool ghost_wl_output_own(const struct wl_output *output)
@ GHOST_kWindowStateMinimized
@ GHOST_kWindowStateMaximized
@ GHOST_kWindowStateEmbedded
@ GHOST_kWindowStateNormal
@ GHOST_kWindowStateFullScreen
@ GHOST_kStandardCursorDefault
@ GHOST_kEventWindowClose
@ GHOST_kEventWindowActivate
@ GHOST_kEventWindowDeactivate
GHOST_TDrawingContextType
@ GHOST_kDrawingContextTypeOpenGL
@ GHOST_kDrawingContextTypeNone
static void surface_handle_leave(void *data, struct wl_surface *, struct wl_output *output)
static GHOST_WindowManager * window_manager
static CLG_LogRef LOG_WL_XDG_TOPLEVEL_DECORATION
static void xdg_toplevel_handle_configure(void *data, xdg_toplevel *, const int32_t width, const int32_t height, wl_array *states)
static CLG_LogRef LOG_WL_XDG_SURFACE
static void xdg_surface_handle_configure(void *data, xdg_surface *xdg_surface, const uint32_t serial)
static void surface_handle_enter(void *data, struct wl_surface *, struct wl_output *output)
static CLG_LogRef LOG_WL_SURFACE
static int outputs_max_scale_or_default(const std::vector< output_t * > &outputs, const int32_t scale_default, uint32_t *r_dpi)
static void xdg_toplevel_decoration_handle_configure(void *data, struct zxdg_toplevel_decoration_v1 *, const uint32_t mode)
static const xdg_toplevel_listener toplevel_listener
static int output_scale_cmp(const output_t *output_a, const output_t *output_b)
static constexpr size_t base_dpi
static const xdg_surface_listener xdg_surface_listener
static CLG_LogRef LOG_WL_XDG_TOPLEVEL
static const zxdg_toplevel_decoration_v1_listener toplevel_decoration_v1_listener
static struct wl_surface_listener wl_surface_listener
static void xdg_toplevel_handle_close(void *data, xdg_toplevel *)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
zxdg_decoration_manager_v1 * xdg_decoration_manager()
void window_surface_unref(const wl_surface *surface)
wl_compositor * compositor()
GHOST_TSuccess setCursorVisibility(bool visible)
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 *surface, int scale)
const std::vector< output_t * > & outputs() const
GHOST_TSuccess getCursorBitmap(GHOST_CursorBitmapRef *bitmap)
GHOST_TSuccess setCursorShape(GHOST_TStandardCursor shape)
xdg_wm_base * xdg_shell()
GHOST_TSuccess hasCursorShape(GHOST_TStandardCursor cursorShape)
GHOST_TSuccess setCustomCursorShape(uint8_t *bitmap, uint8_t *mask, int sizex, int sizey, int hotX, int hotY, bool canInvertColor)
bool getCursorGrabUseSoftwareDisplay(const GHOST_TGrabCursorMode mode)
virtual uint64_t getMilliSeconds() const
GHOST_WindowManager * getWindowManager() const
GHOST_TSuccess pushEvent(GHOST_IEvent *event)
GHOST_TSuccess setActiveWindow(GHOST_IWindow *window)
void setWindowInactive(const GHOST_IWindow *window)
GHOST_TSuccess hasCursorShape(GHOST_TStandardCursor cursorShape) override
GHOST_TSuccess setClientSize(uint32_t width, uint32_t height) override
GHOST_TSuccess setClientWidth(uint32_t width) override
bool outputs_leave(output_t *reg_output)
GHOST_TSuccess setOrder(GHOST_TWindowOrder order) override
GHOST_TSuccess setWindowCursorGrab(GHOST_TGrabCursorMode mode) override
bool outputs_enter(output_t *reg_output)
GHOST_TSuccess notify_size()
GHOST_TSuccess setState(GHOST_TWindowState state) override
GHOST_TSuccess setWindowCursorVisibility(bool visible) override
GHOST_TWindowState getState() const override
bool getCursorGrabUseSoftwareDisplay() override
GHOST_TSuccess beginFullScreen() const override
bool isDialog() const override
struct wl_surface * surface() const
std::string getTitle() const override
GHOST_TSuccess deactivate()
bool outputs_changed_update_scale()
void getClientBounds(GHOST_Rect &bounds) const override
GHOST_TSuccess activate()
uint16_t getDPIHint() override
void clientToScreen(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override
GHOST_TSuccess endFullScreen() const override
GHOST_TSuccess setClientHeight(uint32_t height) override
GHOST_WindowWayland(GHOST_SystemWayland *system, const char *title, int32_t left, int32_t top, uint32_t width, uint32_t height, GHOST_TWindowState state, const GHOST_IWindow *parentWindow, GHOST_TDrawingContextType type, const bool is_dialog, const bool stereoVisual, const bool exclusive)
void screenToClient(int32_t inX, int32_t inY, int32_t &outX, int32_t &outY) const override
const std::vector< output_t * > & outputs()
~GHOST_WindowWayland() override
GHOST_TSuccess invalidate() override
GHOST_TSuccess setWindowCursorShape(GHOST_TStandardCursor shape) override
void setTitle(const char *title) override
GHOST_TSuccess setWindowCustomCursorShape(uint8_t *bitmap, uint8_t *mask, int sizex, int sizey, int hotX, int hotY, bool canInvertColor) override
void getWindowBounds(GHOST_Rect &bounds) const override
GHOST_TSuccess getCursorBitmap(GHOST_CursorBitmapRef *bitmap) override
GHOST_TSuccess getCursorGrabBounds(GHOST_Rect &bounds)
GHOST_TGrabCursorMode m_cursorGrab
int32_t m_cursorGrabInitPos[2]
GHOST_TSuccess setDrawingContextType(GHOST_TDrawingContextType type)
GHOST_TStandardCursor m_cursorShape
GHOST_TSuccess releaseNativeHandles()
GHOST_TAxisFlag m_cursorGrabAxis
GHOST_TSuccess setSwapInterval(int interval)
ccl_global KernelShaderEvalInput ccl_global float * output
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
static bNodeSocketTemplate outputs[]
wl_fixed_t scale_fractional
bool has_scale_fractional
enum zxdg_toplevel_decoration_v1_mode decoration_mode
wl_egl_window * egl_window
struct xdg_toplevel * xdg_toplevel
struct zxdg_toplevel_decoration_v1 * xdg_toplevel_decoration
struct wl_surface * wl_surface
struct xdg_surface * xdg_surface
std::vector< output_t * > outputs
#define wl_display_flush(...)
#define wl_display_roundtrip(...)
#define wl_egl_window_resize(...)
#define wl_egl_window_create(...)
#define wl_egl_window_destroy(...)
#define libdecor_frame_set_fullscreen(...)
#define libdecor_frame_map(...)
#define libdecor_state_new(...)
#define libdecor_frame_unset_fullscreen(...)
#define libdecor_configuration_get_content_size(...)
#define libdecor_dispatch(...)
#define libdecor_state_free(...)
#define libdecor_configuration_get_window_state(...)
#define libdecor_frame_unref(...)
#define libdecor_frame_unset_maximized(...)
#define libdecor_frame_set_app_id(...)
#define libdecor_frame_set_min_content_size(...)
#define libdecor_frame_set_parent(...)
#define libdecor_frame_set_title(...)
#define libdecor_frame_set_minimized(...)
#define libdecor_frame_commit(...)
#define libdecor_decorate(...)
#define libdecor_frame_set_maximized(...)