wlt: toggle fullscreen on F11

This adds a --grab-fullscreen parameter which configures the key that
toggles fullscreen. This is handled in the theme widget as we consider it
the main window-handler.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann 2012-10-01 17:09:14 +02:00
parent c28ea5c974
commit ead84b9dca
3 changed files with 32 additions and 0 deletions

View File

@ -234,6 +234,9 @@ static void print_help()
"\t Shortcut to scroll page up\n"
"\t --grab-page-down <grab> [<Shift>Next]\n"
"\t Shortcut to scroll page down\n"
"\t --grab-fullscreen <grab> [F11]\n"
"\t Shortcut to toggle fullscreen mode\n"
"\n"
"Font Options:\n"
"\t --font-engine <engine> [pango]\n"
"\t Font engine\n"
@ -321,6 +324,11 @@ static struct conf_grab def_grab_page_down = {
.keysym = XKB_KEY_Next,
};
static struct conf_grab def_grab_fullscreen = {
.mods = 0,
.keysym = XKB_KEY_F11,
};
struct conf_option options[] = {
CONF_OPTION_BOOL('h', "help", aftercheck_help, &wlt_conf.help, false),
CONF_OPTION_BOOL('v', "verbose", NULL, &wlt_conf.verbose, false),
@ -336,6 +344,7 @@ struct conf_option options[] = {
CONF_OPTION_GRAB(0, "grab-scroll-down", NULL, &wlt_conf.grab_scroll_down, &def_grab_scroll_down),
CONF_OPTION_GRAB(0, "grab-page-up", NULL, &wlt_conf.grab_page_up, &def_grab_page_up),
CONF_OPTION_GRAB(0, "grab-page-down", NULL, &wlt_conf.grab_page_down, &def_grab_page_down),
CONF_OPTION_GRAB(0, "grab-fullscreen", NULL, &wlt_conf.grab_fullscreen, &def_grab_fullscreen),
CONF_OPTION_STRING(0, "font-engine", NULL, &wlt_conf.font_engine, "pango"),
CONF_OPTION_UINT(0, "font-size", NULL, &wlt_conf.font_size, 12),

View File

@ -65,6 +65,8 @@ struct wlt_conf_t {
struct conf_grab *grab_page_up;
/* page-down grab */
struct conf_grab *grab_page_down;
/* fullscreen grab */
struct conf_grab *grab_fullscreen;
/* font engine */
char *font_engine;

View File

@ -33,6 +33,8 @@
#include <string.h>
#include <wayland-client.h>
#include "log.h"
#include "shl_misc.h"
#include "wlt_main.h"
#include "wlt_theme.h"
#include "wlt_toolkit.h"
@ -519,6 +521,24 @@ static void widget_pointer_button(struct wlt_widget *widget,
}
}
static bool widget_key(struct wlt_widget *widget, unsigned int mask,
uint32_t sym, uint32_t state, bool handled, void *data)
{
struct wlt_theme *theme = data;
if (handled || state != WL_KEYBOARD_KEY_STATE_PRESSED)
return false;
if (SHL_HAS_BITS(mask, wlt_conf.grab_fullscreen->mods) &&
sym == wlt_conf.grab_fullscreen->keysym) {
wlt_window_toggle_fullscreen(theme->wnd);
return true;
}
return false;
}
static void widget_destroy(struct wlt_widget *widget, void *data)
{
struct wlt_theme *theme = data;
@ -565,6 +585,7 @@ int wlt_theme_new(struct wlt_theme **out, struct wlt_window *wnd)
wlt_widget_set_pointer_cb(theme->widget, widget_pointer_enter,
widget_pointer_leave, widget_pointer_motion,
widget_pointer_button);
wlt_widget_set_keyboard_cb(theme->widget, widget_key);
*out = theme;
return 0;