Skip to content

Commit

Permalink
wayland_common: rework state handling & fullscreen
Browse files Browse the repository at this point in the history
Remove vo_wayland_{fullscreen,ontop,border} functions.

Fullscreen handling is done in window_set_fullscreen and the other 2 are not
implemented and used.
  • Loading branch information
giselher committed Sep 10, 2014
1 parent 25787de commit 840985a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 58 deletions.
88 changes: 31 additions & 57 deletions video/out/wayland_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ static void hide_cursor(struct vo_wayland_state * wl);
static void show_cursor(struct vo_wayland_state * wl);
static void window_move(struct vo_wayland_state * wl, uint32_t serial);
static void window_set_title(struct vo_wayland_state * wl, const char *title);
static void window_set_fullscreen(struct vo_wayland_state * wl);
static void schedule_resize(struct vo_wayland_state *wl,
int32_t width,
int32_t height);

static void vo_wayland_fullscreen (struct vo *vo);

static const struct mp_keymap keymap[] = {
// special keys
Expand Down Expand Up @@ -137,12 +137,16 @@ static void xdg_handle_configure(void *data,
schedule_resize(wl, width, height);

enum xdg_surface_state *state;

// reset states
wl->window.state.fullscreen = false;

wl_array_for_each(state, states) {
switch (*state) {
case XDG_SURFACE_STATE_MAXIMIZED:
break;
case XDG_SURFACE_STATE_FULLSCREEN:
wl->window.is_fullscreen = true;
wl->window.state.fullscreen = true;
break;
case XDG_SURFACE_STATE_RESIZING:
case XDG_SURFACE_STATE_ACTIVATED:
Expand Down Expand Up @@ -698,16 +702,30 @@ static void window_move(struct vo_wayland_state *wl, uint32_t serial)
xdg_surface_move(wl->window.xdg_surface, wl->input.seat, serial);
}

static void window_set_toplevel(struct vo_wayland_state *wl)
static void window_set_title(struct vo_wayland_state *wl, const char *title)
{
if (wl->display.shell)
xdg_surface_unset_fullscreen(wl->window.xdg_surface);
xdg_surface_set_title(wl->window.xdg_surface, title);
}

static void window_set_title(struct vo_wayland_state *wl, const char *title)
static void window_set_fullscreen(struct vo_wayland_state *wl)
{
if (wl->display.shell)
xdg_surface_set_title(wl->window.xdg_surface, title);
if (!wl->display.shell)
return;

if (!wl->window.state.fullscreen) {
MP_DBG(wl, "going fullscreen\n");
wl->window.p_width = wl->window.width;
wl->window.p_height = wl->window.height;
xdg_surface_set_fullscreen(wl->window.xdg_surface,
wl->display.fs_output);
}

else {
MP_DBG(wl, "leaving fullscreen\n");
xdg_surface_unset_fullscreen(wl->window.xdg_surface);
schedule_resize(wl, wl->window.p_width, wl->window.p_height);
}
}

static void schedule_resize(struct vo_wayland_state *wl,
Expand Down Expand Up @@ -938,50 +956,6 @@ void vo_wayland_uninit (struct vo *vo)
vo->wayland = NULL;
}

static void vo_wayland_ontop (struct vo *vo)
{
/*
* No ontop
*
*
*/
}

static void vo_wayland_border (struct vo *vo)
{
/* wayland clienst have to do the decorations themself
* (client side decorations) but there is no such code implement nor
* do I plan on implementing something like client side decorations
*
* The only exception would be resizing on when clicking and dragging
* on the border region of the window but this should be discussed at first
*/
}

static void vo_wayland_fullscreen (struct vo *vo)
{
struct vo_wayland_state *wl = vo->wayland;
if (!wl->display.shell)
return;


if (vo->opts->fullscreen) {
MP_DBG(wl, "going fullscreen\n");
wl->window.is_fullscreen = true;
wl->window.p_width = wl->window.width;
wl->window.p_height = wl->window.height;
xdg_surface_set_fullscreen(wl->window.xdg_surface,
wl->display.fs_output);
}

else {
MP_DBG(wl, "leaving fullscreen\n");
wl->window.is_fullscreen = false;
xdg_surface_unset_fullscreen(wl->window.xdg_surface);
schedule_resize(wl, wl->window.p_width, wl->window.p_height);
}
}

static int vo_wayland_check_events (struct vo *vo)
{
struct vo_wayland_state *wl = vo->wayland;
Expand Down Expand Up @@ -1128,10 +1102,7 @@ int vo_wayland_control (struct vo *vo, int *events, int request, void *arg)
*events |= vo_wayland_check_events(vo);
return VO_TRUE;
case VOCTRL_FULLSCREEN:
vo_wayland_fullscreen(vo);
return VO_TRUE;
case VOCTRL_ONTOP:
vo_wayland_ontop(vo);
window_set_fullscreen(wl);
return VO_TRUE;
case VOCTRL_GET_UNFS_WINDOW_SIZE: {
int *s = arg;
Expand All @@ -1141,7 +1112,7 @@ int vo_wayland_control (struct vo *vo, int *events, int request, void *arg)
}
case VOCTRL_SET_UNFS_WINDOW_SIZE: {
int *s = arg;
if (!wl->window.is_fullscreen)
if (!wl->window.state.fullscreen)
schedule_resize(wl, s[0], s[1]);
return VO_TRUE;
}
Expand Down Expand Up @@ -1176,6 +1147,9 @@ bool vo_wayland_config (struct vo *vo, uint32_t flags)
{
struct vo_wayland_state *wl = vo->wayland;

// reset states
wl->window.state.fullscreen = false;

struct mp_rect screenrc;
vo_wayland_update_screeninfo(vo, &screenrc);

Expand All @@ -1190,7 +1164,7 @@ bool vo_wayland_config (struct vo *vo, uint32_t flags)
if (!(flags & VOFLAG_HIDDEN)) {
wl->window.width = vo->dwidth;
wl->window.height = vo->dheight;
vo_wayland_fullscreen(vo);
window_set_fullscreen(wl);
}

return true;
Expand Down
5 changes: 4 additions & 1 deletion video/out/wayland_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ struct vo_wayland_state {
int32_t sh_height;
float aspect;

bool is_fullscreen; // don't keep aspect ratio in fullscreen mode
struct {
bool fullscreen; // don't keep aspect ratio in fullscreen mode
} state;

int32_t fs_width; // fullscreen sizes
int32_t fs_height;

Expand Down

0 comments on commit 840985a

Please sign in to comment.