Some work on xdg shell support

This commit is contained in:
Deve 2018-01-09 23:41:34 +01:00
parent 62fe84ecc7
commit 74b071494c
5 changed files with 2051 additions and 29 deletions

View File

@ -564,7 +564,8 @@ include/vector3d.h
if(ENABLE_WAYLAND_DEVICE)
set(IRRLICHT_SOURCES
${IRRLICHT_SOURCES}
source/Irrlicht/server_decoration_client_protocol.c)
source/Irrlicht/server_decoration_client_protocol.c
source/Irrlicht/xdg-shell-unstable-v6-protocol.c)
endif()

View File

@ -73,6 +73,9 @@ public:
static const wl_output_listener output_listener;
static const wl_shell_surface_listener shell_surface_listener;
static const wl_registry_listener registry_listener;
static const zxdg_shell_v6_listener xdg_shell_listener;
static const zxdg_surface_v6_listener xdg_surface_listener;
static const zxdg_toplevel_v6_listener xdg_toplevel_listener;
static void pointer_enter(void* data, wl_pointer* pointer, uint32_t serial,
wl_surface* surface, wl_fixed_t sx, wl_fixed_t sy)
@ -511,6 +514,48 @@ public:
{
}
static void xdg_shell_ping(void* data, zxdg_shell_v6* shell,
uint32_t serial)
{
zxdg_shell_v6_pong(shell, serial);
}
static void xdg_surface_configure(void* data, zxdg_surface_v6* surface,
uint32_t serial)
{
zxdg_surface_v6_ack_configure(surface, serial);
}
static void xdg_toplevel_configure(void* data, zxdg_toplevel_v6* toplevel,
int32_t width, int32_t height,
wl_array* states)
{
void* state_p;
wl_array_for_each(state_p, states)
{
uint32_t state = *(uint32_t*)state_p;
switch (state)
{
case ZXDG_TOPLEVEL_V6_STATE_FULLSCREEN:
case ZXDG_TOPLEVEL_V6_STATE_MAXIMIZED:
case ZXDG_TOPLEVEL_V6_STATE_ACTIVATED:
case ZXDG_TOPLEVEL_V6_STATE_RESIZING:
break;
default:
break;
}
}
}
static void xdg_toplevel_close(void* data, zxdg_toplevel_v6* xdg_toplevel)
{
CIrrDeviceWayland* device = static_cast<CIrrDeviceWayland*>(data);
device->closeDevice();
}
static void registry_global(void* data, wl_registry* registry,
uint32_t name, const char* interface,
uint32_t version)
@ -521,17 +566,18 @@ public:
return;
std::string interface_str = interface;
printf("interface: %s\n", interface_str.c_str());
if (interface_str == "wl_compositor")
{
device->m_compositor = static_cast<wl_compositor*>(wl_registry_bind(
registry, name, &wl_compositor_interface, 1));
}
else if (interface_str == "wl_shell")
{
device->m_shell = static_cast<wl_shell*>(wl_registry_bind(registry,
name, &wl_shell_interface, 1));
}
//~ else if (interface_str == "wl_shell")
//~ {
//~ device->m_shell = static_cast<wl_shell*>(wl_registry_bind(registry,
//~ name, &wl_shell_interface, 1));
//~ }
else if (interface_str == "wl_seat")
{
device->m_seat = static_cast<wl_seat*>(wl_registry_bind(registry,
@ -557,6 +603,14 @@ public:
wl_registry_bind(registry, name,
&org_kde_kwin_server_decoration_manager_interface, 1));
}
else if (interface_str == "zxdg_shell_v6")
{
device->m_xdg_shell = static_cast<zxdg_shell_v6*>(wl_registry_bind(
registry, name, &zxdg_shell_v6_interface, 1));
zxdg_shell_v6_add_listener(device->m_xdg_shell, &xdg_shell_listener,
device);
}
}
static void registry_global_remove(void* data, wl_registry* registry,
@ -611,6 +665,22 @@ const wl_registry_listener WaylandCallbacks::registry_listener =
WaylandCallbacks::registry_global_remove
};
const zxdg_shell_v6_listener WaylandCallbacks::xdg_shell_listener =
{
WaylandCallbacks::xdg_shell_ping
};
const zxdg_surface_v6_listener WaylandCallbacks::xdg_surface_listener =
{
WaylandCallbacks::xdg_surface_configure
};
const zxdg_toplevel_v6_listener WaylandCallbacks::xdg_toplevel_listener =
{
WaylandCallbacks::xdg_toplevel_configure,
WaylandCallbacks::xdg_toplevel_close
};
bool CIrrDeviceWayland::isWaylandDeviceWorking()
@ -645,13 +715,17 @@ CIrrDeviceWayland::CIrrDeviceWayland(const SIrrlichtCreationParameters& params)
m_pointer = NULL;
m_registry = NULL;
m_seat = NULL;
m_shell = NULL;
m_shell_surface = NULL;
//~ m_shell = NULL;
//~ m_shell_surface = NULL;
m_shm = NULL;
m_cursor_surface = NULL;
m_surface = NULL;
m_enter_serial = 0;
m_xdg_shell = NULL;
m_xdg_surface = NULL;
m_xdg_toplevel = NULL;
m_decoration_manager = NULL;
m_decoration = NULL;
@ -746,15 +820,24 @@ CIrrDeviceWayland::~CIrrDeviceWayland()
if (m_cursor_theme)
wl_cursor_theme_destroy(m_cursor_theme);
if (m_shell_surface)
wl_shell_surface_destroy(m_shell_surface);
if (m_xdg_toplevel)
zxdg_toplevel_v6_destroy(m_xdg_toplevel);
if (m_xdg_surface)
zxdg_surface_v6_destroy(m_xdg_surface);
if (m_xdg_shell)
zxdg_shell_v6_destroy(m_xdg_shell);
//~ if (m_shell_surface)
//~ wl_shell_surface_destroy(m_shell_surface);
//~ if (m_shell)
//~ wl_shell_destroy(m_shell);
if (m_surface)
wl_surface_destroy(m_surface);
if (m_shell)
wl_shell_destroy(m_shell);
if (m_shm)
wl_shm_destroy(m_shm);
@ -841,19 +924,36 @@ bool CIrrDeviceWayland::initEGL()
bool CIrrDeviceWayland::createWindow()
{
m_surface = wl_compositor_create_surface(m_compositor);
m_shell_surface = wl_shell_get_shell_surface(m_shell, m_surface);
//~ m_shell_surface = wl_shell_get_shell_surface(m_shell, m_surface);
wl_shell_surface_add_listener(m_shell_surface,
&WaylandCallbacks::shell_surface_listener, this);
//~ wl_shell_surface_add_listener(m_shell_surface,
//~ &WaylandCallbacks::shell_surface_listener, this);
//~ if (CreationParams.Fullscreen)
//~ {
//~ wl_shell_surface_set_fullscreen(m_shell_surface,
//~ WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, m_output);
//~ }
//~ else
//~ {
//~ wl_shell_surface_set_toplevel(m_shell_surface);
//~ }
m_xdg_surface = zxdg_shell_v6_get_xdg_surface(m_xdg_shell, m_surface);
zxdg_surface_v6_add_listener(m_xdg_surface,
&WaylandCallbacks::xdg_surface_listener, this);
m_xdg_toplevel = zxdg_surface_v6_get_toplevel(m_xdg_surface);
zxdg_toplevel_v6_add_listener(m_xdg_toplevel,
&WaylandCallbacks::xdg_toplevel_listener, this);
wl_surface_commit(m_surface);
if (CreationParams.Fullscreen)
{
wl_shell_surface_set_fullscreen(m_shell_surface,
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, m_output);
}
else
{
wl_shell_surface_set_toplevel(m_shell_surface);
zxdg_toplevel_v6_set_fullscreen(m_xdg_toplevel, NULL);
}
if (m_decoration_manager != NULL)
@ -878,6 +978,8 @@ bool CIrrDeviceWayland::createWindow()
return false;
}
zxdg_surface_v6_set_window_geometry(m_xdg_surface, 0, 0, m_width, m_height);
wl_region* region = wl_compositor_create_region(m_compositor);
wl_region_add(region, 0, 0, m_width, m_height);
wl_surface_set_opaque_region(m_surface, region);
@ -1020,23 +1122,31 @@ void CIrrDeviceWayland::sleep(u32 timeMs, bool pauseTimer=false)
//! sets the caption of the window
void CIrrDeviceWayland::setWindowCaption(const wchar_t* text)
{
if (!m_shell_surface)
//~ if (!m_shell_surface)
//~ return;
if (!m_xdg_toplevel)
return;
char title[1024];
wcstombs(title, text, sizeof(title));
title[1023] = '\0';
wl_shell_surface_set_title(m_shell_surface, title);
//~ wl_shell_surface_set_title(m_shell_surface, title);
zxdg_toplevel_v6_set_title(m_xdg_toplevel, title);
}
//! sets the class of the window
void CIrrDeviceWayland::setWindowClass(const char* text)
{
if (!m_shell_surface)
//~ if (!m_shell_surface)
//~ return;
if (!m_xdg_toplevel)
return;
wl_shell_surface_set_class(m_shell_surface, text);
//~ wl_shell_surface_set_class(m_shell_surface, text);
zxdg_toplevel_v6_set_app_id(m_xdg_toplevel, text);
}
//! presents a surface in the client area

View File

@ -27,6 +27,7 @@
#include "IImagePresenter.h"
#include "ICursorControl.h"
#include "server_decoration_client_protocol.h"
#include "xdg-shell-unstable-v6-client-protocol.h"
#include <wayland-client.h>
#include <wayland-cursor.h>
@ -172,13 +173,17 @@ namespace irr
wl_pointer* m_pointer;
wl_registry* m_registry;
wl_seat* m_seat;
wl_shell* m_shell;
wl_shell_surface* m_shell_surface;
//~ wl_shell* m_shell;
//~ wl_shell_surface* m_shell_surface;
wl_shm* m_shm;
wl_surface* m_cursor_surface;
wl_surface* m_surface;
uint32_t m_enter_serial;
zxdg_shell_v6* m_xdg_shell;
zxdg_surface_v6* m_xdg_surface;
zxdg_toplevel_v6* m_xdg_toplevel;
org_kde_kwin_server_decoration_manager* m_decoration_manager;
org_kde_kwin_server_decoration* m_decoration;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,162 @@
/* Generated by wayland-scanner 1.12.0 */
/*
* Copyright © 2008-2013 Kristian Høgsberg
* Copyright © 2013 Rafael Antognolli
* Copyright © 2013 Jasper St. Pierre
* Copyright © 2010-2013 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#include <stdlib.h>
#include <stdint.h>
#include "wayland-util.h"
extern const struct wl_interface wl_output_interface;
extern const struct wl_interface wl_seat_interface;
extern const struct wl_interface wl_surface_interface;
extern const struct wl_interface zxdg_popup_v6_interface;
extern const struct wl_interface zxdg_positioner_v6_interface;
extern const struct wl_interface zxdg_surface_v6_interface;
extern const struct wl_interface zxdg_toplevel_v6_interface;
static const struct wl_interface *types[] = {
NULL,
NULL,
NULL,
NULL,
&zxdg_positioner_v6_interface,
&zxdg_surface_v6_interface,
&wl_surface_interface,
&zxdg_toplevel_v6_interface,
&zxdg_popup_v6_interface,
&zxdg_surface_v6_interface,
&zxdg_positioner_v6_interface,
&zxdg_toplevel_v6_interface,
&wl_seat_interface,
NULL,
NULL,
NULL,
&wl_seat_interface,
NULL,
&wl_seat_interface,
NULL,
NULL,
&wl_output_interface,
&wl_seat_interface,
NULL,
};
static const struct wl_message zxdg_shell_v6_requests[] = {
{ "destroy", "", types + 0 },
{ "create_positioner", "n", types + 4 },
{ "get_xdg_surface", "no", types + 5 },
{ "pong", "u", types + 0 },
};
static const struct wl_message zxdg_shell_v6_events[] = {
{ "ping", "u", types + 0 },
};
WL_EXPORT const struct wl_interface zxdg_shell_v6_interface = {
"zxdg_shell_v6", 1,
4, zxdg_shell_v6_requests,
1, zxdg_shell_v6_events,
};
static const struct wl_message zxdg_positioner_v6_requests[] = {
{ "destroy", "", types + 0 },
{ "set_size", "ii", types + 0 },
{ "set_anchor_rect", "iiii", types + 0 },
{ "set_anchor", "u", types + 0 },
{ "set_gravity", "u", types + 0 },
{ "set_constraint_adjustment", "u", types + 0 },
{ "set_offset", "ii", types + 0 },
};
WL_EXPORT const struct wl_interface zxdg_positioner_v6_interface = {
"zxdg_positioner_v6", 1,
7, zxdg_positioner_v6_requests,
0, NULL,
};
static const struct wl_message zxdg_surface_v6_requests[] = {
{ "destroy", "", types + 0 },
{ "get_toplevel", "n", types + 7 },
{ "get_popup", "noo", types + 8 },
{ "set_window_geometry", "iiii", types + 0 },
{ "ack_configure", "u", types + 0 },
};
static const struct wl_message zxdg_surface_v6_events[] = {
{ "configure", "u", types + 0 },
};
WL_EXPORT const struct wl_interface zxdg_surface_v6_interface = {
"zxdg_surface_v6", 1,
5, zxdg_surface_v6_requests,
1, zxdg_surface_v6_events,
};
static const struct wl_message zxdg_toplevel_v6_requests[] = {
{ "destroy", "", types + 0 },
{ "set_parent", "?o", types + 11 },
{ "set_title", "s", types + 0 },
{ "set_app_id", "s", types + 0 },
{ "show_window_menu", "ouii", types + 12 },
{ "move", "ou", types + 16 },
{ "resize", "ouu", types + 18 },
{ "set_max_size", "ii", types + 0 },
{ "set_min_size", "ii", types + 0 },
{ "set_maximized", "", types + 0 },
{ "unset_maximized", "", types + 0 },
{ "set_fullscreen", "?o", types + 21 },
{ "unset_fullscreen", "", types + 0 },
{ "set_minimized", "", types + 0 },
};
static const struct wl_message zxdg_toplevel_v6_events[] = {
{ "configure", "iia", types + 0 },
{ "close", "", types + 0 },
};
WL_EXPORT const struct wl_interface zxdg_toplevel_v6_interface = {
"zxdg_toplevel_v6", 1,
14, zxdg_toplevel_v6_requests,
2, zxdg_toplevel_v6_events,
};
static const struct wl_message zxdg_popup_v6_requests[] = {
{ "destroy", "", types + 0 },
{ "grab", "ou", types + 22 },
};
static const struct wl_message zxdg_popup_v6_events[] = {
{ "configure", "iiii", types + 0 },
{ "popup_done", "", types + 0 },
};
WL_EXPORT const struct wl_interface zxdg_popup_v6_interface = {
"zxdg_popup_v6", 1,
2, zxdg_popup_v6_requests,
2, zxdg_popup_v6_events,
};