aboutsummaryrefslogtreecommitdiff
path: root/src/window.c
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2019-07-12 21:45:40 +0100
committerHarry Jeffery <harry@exec64.co.uk>2019-07-12 21:45:40 +0100
commitd4bb4bd6437fa4222e5de38671d1fe9b5dc5c716 (patch)
treec32cbac6825d7fd6fcd2544ad2de53b380573de8 /src/window.c
parent3200b8f9db552db31fa90411c1ce7f851832d01c (diff)
downloadimv-d4bb4bd6437fa4222e5de38671d1fe9b5dc5c716.tar.gz
Fullscreen support
Diffstat (limited to 'src/window.c')
-rw-r--r--src/window.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/window.c b/src/window.c
index c330f84..34c5da1 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1,10 +1,10 @@
#include "window.h"
#include <assert.h>
-#include <stdlib.h>
+#include <pthread.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <pthread.h>
#include <wayland-client.h>
#include <wayland-egl.h>
@@ -30,6 +30,7 @@ struct imv_window {
int width;
int height;
+ bool fullscreen;
int scale;
struct {
@@ -84,7 +85,9 @@ static void keyboard_key(void *data, struct wl_keyboard *keyboard,
uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
{
(void)serial;
+ (void)keyboard;
(void)time;
+
struct imv_window *window = data;
struct imv_event e = {
.type = IMV_EVENT_KEYBOARD,
@@ -215,11 +218,18 @@ static void toplevel_configure(void *data, struct xdg_toplevel *toplevel,
int width, int height, struct wl_array *states)
{
(void)toplevel;
- (void)states;
struct imv_window *window = data;
window->width = width;
window->height = height;
+ window->fullscreen = false;
+
+ enum xdg_toplevel_state *state;
+ wl_array_for_each(state, states) {
+ if (*state == XDG_TOPLEVEL_STATE_FULLSCREEN) {
+ window->fullscreen = true;
+ }
+ }
wl_egl_window_resize(window->egl_window, width, height, 0, 0);
struct imv_event e = {
@@ -370,6 +380,20 @@ void imv_window_set_title(struct imv_window *window, const char *title)
xdg_toplevel_set_title(window->wl_xdg_toplevel, title);
}
+bool imv_window_is_fullscreen(struct imv_window *window)
+{
+ return window->fullscreen;
+}
+
+void imv_window_set_fullscreen(struct imv_window *window, bool fullscreen)
+{
+ if (window->fullscreen && !fullscreen) {
+ xdg_toplevel_unset_fullscreen(window->wl_xdg_toplevel);
+ } else if (!window->fullscreen && fullscreen) {
+ xdg_toplevel_set_fullscreen(window->wl_xdg_toplevel, NULL);
+ }
+}
+
void imv_window_present(struct imv_window *window)
{
eglSwapBuffers(window->egl_display, window->egl_surface);