mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 14:57:20 +00:00
[client] wayland: pass scale factor information to renderer
This commit is contained in:
parent
b35e19fc27
commit
447aedc9a3
@ -71,16 +71,22 @@ void waylandEGLSwapBuffers(EGLDisplay display, EGLSurface surface)
|
||||
{
|
||||
eglSwapBuffers(display, surface);
|
||||
|
||||
if (wlWm.resizeSerial)
|
||||
if (wlWm.needsResize)
|
||||
{
|
||||
wl_egl_window_resize(wlWm.eglWindow, wlWm.width, wlWm.height, 0, 0);
|
||||
wl_egl_window_resize(wlWm.eglWindow, wlWm.width * wlWm.scale, wlWm.height * wlWm.scale, 0, 0);
|
||||
wl_surface_set_buffer_scale(wlWm.surface, wlWm.scale);
|
||||
|
||||
struct wl_region * region = wl_compositor_create_region(wlWm.compositor);
|
||||
wl_region_add(region, 0, 0, wlWm.width, wlWm.height);
|
||||
wl_surface_set_opaque_region(wlWm.surface, region);
|
||||
wl_region_destroy(region);
|
||||
|
||||
app_handleResizeEvent(wlWm.width, wlWm.height, 1, (struct Border) {0, 0, 0, 0});
|
||||
app_handleResizeEvent(wlWm.width, wlWm.height, wlWm.scale, (struct Border) {0, 0, 0, 0});
|
||||
wlWm.needsResize = false;
|
||||
}
|
||||
|
||||
if (wlWm.resizeSerial)
|
||||
{
|
||||
xdg_surface_ack_configure(wlWm.xdgSurface, wlWm.resizeSerial);
|
||||
wlWm.resizeSerial = 0;
|
||||
}
|
||||
|
@ -59,6 +59,12 @@ struct WaylandOutput
|
||||
struct wl_list link;
|
||||
};
|
||||
|
||||
struct SurfaceOutput
|
||||
{
|
||||
struct wl_output * output;
|
||||
struct wl_list link;
|
||||
};
|
||||
|
||||
struct WaylandDSState
|
||||
{
|
||||
bool pointerGrabbed;
|
||||
@ -71,7 +77,8 @@ struct WaylandDSState
|
||||
struct wl_shm * shm;
|
||||
struct wl_compositor * compositor;
|
||||
|
||||
int32_t width, height;
|
||||
int32_t width, height, scale;
|
||||
bool needsResize;
|
||||
bool fullscreen;
|
||||
uint32_t resizeSerial;
|
||||
bool configured;
|
||||
@ -117,6 +124,7 @@ struct WaylandDSState
|
||||
struct zwp_idle_inhibitor_v1 * idleInhibitor;
|
||||
|
||||
struct wl_list outputs; // WaylandOutput::link
|
||||
struct wl_list surfaceOutputs; // SurfaceOutput::link
|
||||
|
||||
struct wl_list poll; // WaylandPoll::link
|
||||
struct wl_list pollFree; // WaylandPoll::link
|
||||
|
@ -41,11 +41,60 @@ static const struct xdg_wm_base_listener xdgWmBaseListener = {
|
||||
|
||||
// Surface-handling listeners.
|
||||
|
||||
static void surfaceUpdateScale(void)
|
||||
{
|
||||
int32_t maxScale = 0;
|
||||
struct SurfaceOutput * node;
|
||||
|
||||
wl_list_for_each(node, &wlWm.surfaceOutputs, link)
|
||||
{
|
||||
int32_t scale = waylandOutputGetScale(node->output);
|
||||
if (scale > maxScale)
|
||||
maxScale = scale;
|
||||
}
|
||||
|
||||
if (maxScale)
|
||||
{
|
||||
wlWm.scale = maxScale;
|
||||
wlWm.needsResize = true;
|
||||
}
|
||||
}
|
||||
|
||||
static void wlSurfaceEnterHandler(void * data, struct wl_surface * surface, struct wl_output * output)
|
||||
{
|
||||
struct SurfaceOutput * node = malloc(sizeof(struct SurfaceOutput));
|
||||
node->output = output;
|
||||
wl_list_insert(&wlWm.surfaceOutputs, &node->link);
|
||||
surfaceUpdateScale();
|
||||
}
|
||||
|
||||
static void wlSurfaceLeaveHandler(void * data, struct wl_surface * surface, struct wl_output * output)
|
||||
{
|
||||
struct SurfaceOutput * node;
|
||||
wl_list_for_each(node, &wlWm.surfaceOutputs, link)
|
||||
if (node->output == output)
|
||||
{
|
||||
wl_list_remove(&node->link);
|
||||
break;
|
||||
}
|
||||
surfaceUpdateScale();
|
||||
}
|
||||
|
||||
static const struct wl_surface_listener wlSurfaceListener = {
|
||||
.enter = wlSurfaceEnterHandler,
|
||||
.leave = wlSurfaceLeaveHandler,
|
||||
};
|
||||
|
||||
// XDG Surface listeners.
|
||||
|
||||
static void xdgSurfaceConfigure(void * data, struct xdg_surface * xdgSurface,
|
||||
uint32_t serial)
|
||||
{
|
||||
if (wlWm.configured)
|
||||
{
|
||||
wlWm.needsResize = true;
|
||||
wlWm.resizeSerial = serial;
|
||||
}
|
||||
else
|
||||
{
|
||||
xdg_surface_ack_configure(xdgSurface, serial);
|
||||
@ -57,7 +106,7 @@ static const struct xdg_surface_listener xdgSurfaceListener = {
|
||||
.configure = xdgSurfaceConfigure,
|
||||
};
|
||||
|
||||
// XDG Surface listeners.
|
||||
// XDG Toplevel listeners.
|
||||
|
||||
static void xdgToplevelConfigure(void * data, struct xdg_toplevel * xdgToplevel,
|
||||
int32_t width, int32_t height, struct wl_array * states)
|
||||
@ -86,6 +135,8 @@ static const struct xdg_toplevel_listener xdgToplevelListener = {
|
||||
|
||||
bool waylandWindowInit(const char * title, bool fullscreen, bool maximize, bool borderless)
|
||||
{
|
||||
wlWm.scale = 1;
|
||||
|
||||
if (!wlWm.compositor)
|
||||
{
|
||||
DEBUG_ERROR("Compositor missing wl_compositor, will not proceed");
|
||||
@ -99,7 +150,6 @@ bool waylandWindowInit(const char * title, bool fullscreen, bool maximize, bool
|
||||
}
|
||||
|
||||
xdg_wm_base_add_listener(wlWm.xdgWmBase, &xdgWmBaseListener, NULL);
|
||||
//wl_display_roundtrip(wlWm.display);
|
||||
|
||||
wlWm.surface = wl_compositor_create_surface(wlWm.compositor);
|
||||
if (!wlWm.surface)
|
||||
@ -108,6 +158,9 @@ bool waylandWindowInit(const char * title, bool fullscreen, bool maximize, bool
|
||||
return false;
|
||||
}
|
||||
|
||||
wl_list_init(&wlWm.surfaceOutputs);
|
||||
wl_surface_add_listener(wlWm.surface, &wlSurfaceListener, NULL);
|
||||
|
||||
wlWm.xdgSurface = xdg_wm_base_get_xdg_surface(wlWm.xdgWmBase, wlWm.surface);
|
||||
xdg_surface_add_listener(wlWm.xdgSurface, &xdgSurfaceListener, NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user