mirror of
https://github.com/glfw/glfw.git
synced 2026-09-19 15:25:50 +00:00
Wayland: Use tags to verify proxy ownership
This is in preparation for adding support for libdecor, which creates its own proxies on our display. It will likely also be helpful to some people using native access on Wayland. This is partly based on the implementation of libdecor support in PR #1693 by @ christianrauch.
This commit is contained in:
+24
-2
@@ -199,6 +199,7 @@ static void createFallbackDecoration(_GLFWdecorationWayland* decoration,
|
||||
int width, int height)
|
||||
{
|
||||
decoration->surface = wl_compositor_create_surface(_glfw.wl.compositor);
|
||||
wl_proxy_set_tag((struct wl_proxy*) decoration->surface, &_glfw.wl.tag);
|
||||
decoration->subsurface =
|
||||
wl_subcompositor_get_subsurface(_glfw.wl.subcompositor,
|
||||
decoration->surface, parent);
|
||||
@@ -371,6 +372,9 @@ static void surfaceHandleEnter(void* userData,
|
||||
struct wl_surface* surface,
|
||||
struct wl_output* output)
|
||||
{
|
||||
if (wl_proxy_get_tag((struct wl_proxy*) output) != &_glfw.wl.tag)
|
||||
return;
|
||||
|
||||
_GLFWwindow* window = userData;
|
||||
_GLFWmonitor* monitor = wl_output_get_user_data(output);
|
||||
|
||||
@@ -391,6 +395,9 @@ static void surfaceHandleLeave(void* userData,
|
||||
struct wl_surface* surface,
|
||||
struct wl_output* output)
|
||||
{
|
||||
if (wl_proxy_get_tag((struct wl_proxy*) output) != &_glfw.wl.tag)
|
||||
return;
|
||||
|
||||
_GLFWwindow* window = userData;
|
||||
_GLFWmonitor* monitor = wl_output_get_user_data(output);
|
||||
GLFWbool found = GLFW_FALSE;
|
||||
@@ -729,6 +736,7 @@ static GLFWbool createNativeSurface(_GLFWwindow* window,
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
wl_proxy_set_tag((struct wl_proxy*) window->wl.surface, &_glfw.wl.tag);
|
||||
wl_surface_add_listener(window->wl.surface,
|
||||
&surfaceListener,
|
||||
window);
|
||||
@@ -1063,6 +1071,9 @@ static void pointerHandleEnter(void* userData,
|
||||
if (!surface)
|
||||
return;
|
||||
|
||||
if (wl_proxy_get_tag((struct wl_proxy*) surface) != &_glfw.wl.tag)
|
||||
return;
|
||||
|
||||
_GLFWdecorationSideWayland focus = mainWindow;
|
||||
_GLFWwindow* window = wl_surface_get_user_data(surface);
|
||||
if (!window)
|
||||
@@ -1088,8 +1099,13 @@ static void pointerHandleLeave(void* userData,
|
||||
uint32_t serial,
|
||||
struct wl_surface* surface)
|
||||
{
|
||||
_GLFWwindow* window = _glfw.wl.pointerFocus;
|
||||
if (!surface)
|
||||
return;
|
||||
|
||||
if (wl_proxy_get_tag((struct wl_proxy*) surface) != &_glfw.wl.tag)
|
||||
return;
|
||||
|
||||
_GLFWwindow* window = _glfw.wl.pointerFocus;
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
@@ -1681,7 +1697,10 @@ static void dataDeviceHandleEnter(void* userData,
|
||||
_GLFWwindow* window = NULL;
|
||||
|
||||
if (surface)
|
||||
window = wl_surface_get_user_data(surface);
|
||||
{
|
||||
if (wl_proxy_get_tag((struct wl_proxy*) surface) == &_glfw.wl.tag)
|
||||
window = wl_surface_get_user_data(surface);
|
||||
}
|
||||
|
||||
if (window && _glfw.wl.offers[i].text_uri_list)
|
||||
{
|
||||
@@ -1696,6 +1715,9 @@ static void dataDeviceHandleEnter(void* userData,
|
||||
}
|
||||
}
|
||||
|
||||
if (wl_proxy_get_tag((struct wl_proxy*) surface) != &_glfw.wl.tag)
|
||||
return;
|
||||
|
||||
if (_glfw.wl.dragOffer)
|
||||
wl_data_offer_accept(offer, serial, "text/uri-list");
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user