window.c: Add fullscreen handler to keep fullscreen state consistent

dev
Kristian Høgsberg 13 years ago
parent 0fd49aa886
commit 67ace20f8e
  1. 18
      clients/terminal.c
  2. 15
      clients/view.c
  3. 15
      clients/window.c
  4. 4
      clients/window.h

@ -2057,6 +2057,15 @@ static const struct wl_data_source_listener data_source_listener = {
data_source_cancelled
};
static void
fullscreen_handler(struct window *window, void *data)
{
struct terminal *terminal = data;
terminal->fullscreen ^= 1;
window_set_fullscreen(window, terminal->fullscreen);
}
static int
handle_bound_key(struct terminal *terminal,
struct input *input, uint32_t sym, uint32_t time)
@ -2115,13 +2124,6 @@ key_handler(struct window *window, struct input *input, uint32_t time,
return;
switch (sym) {
case XKB_KEY_F11:
if (state == WL_KEYBOARD_KEY_STATE_RELEASED)
break;
terminal->fullscreen ^= 1;
window_set_fullscreen(window, terminal->fullscreen);
break;
case XKB_KEY_BackSpace:
if (modifiers & MOD_ALT_MASK)
ch[len++] = 0x1b;
@ -2457,6 +2459,8 @@ terminal_create(struct display *display, int fullscreen)
window_set_key_handler(terminal->window, key_handler);
window_set_keyboard_focus_handler(terminal->window,
keyboard_focus_handler);
window_set_fullscreen_handler(terminal->window, fullscreen_handler);
widget_set_redraw_handler(terminal->widget, redraw_handler);
widget_set_resize_handler(terminal->widget, resize_handler);
widget_set_button_handler(terminal->widget, button_handler);

@ -158,6 +158,15 @@ button_handler(struct widget *widget, struct input *input, uint32_t time,
}
}
static void
fullscreen_handler(struct window *window, void *data)
{
struct view *view = data;
view->fullscreen ^= 1;
window_set_fullscreen(window, view->fullscreen);
}
static void
key_handler(struct window *window, struct input *input, uint32_t time,
uint32_t key, uint32_t unicode,
@ -169,10 +178,6 @@ key_handler(struct window *window, struct input *input, uint32_t time,
return;
switch (key) {
case KEY_F11:
view->fullscreen ^= 1;
window_set_fullscreen(window, view->fullscreen);
break;
case KEY_SPACE:
case KEY_PAGEDOWN:
case KEY_RIGHT:
@ -238,6 +243,8 @@ view_create(struct display *display,
window_set_key_handler(view->window, key_handler);
window_set_keyboard_focus_handler(view->window,
keyboard_focus_handler);
window_set_fullscreen_handler(view->window, fullscreen_handler);
widget_set_button_handler(view->widget, button_handler);
widget_set_resize_handler(view->widget, resize_handler);
widget_set_redraw_handler(view->widget, redraw_handler);

@ -157,6 +157,7 @@ struct window {
window_data_handler_t data_handler;
window_drop_handler_t drop_handler;
window_close_handler_t close_handler;
window_fullscreen_handler_t fullscreen_handler;
struct frame *frame;
struct widget *widget;
@ -1560,7 +1561,8 @@ frame_menu_func(struct window *window, int index, void *data)
break;
case 1: /* fullscreen */
/* we don't have a way to get out of fullscreen for now */
window_set_fullscreen(window, 1);
if (window->fullscreen_handler)
window->fullscreen_handler(window, window->user_data);
break;
case 2: /* rotate */
case 3: /* scale */
@ -1886,6 +1888,10 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
if (state == WL_KEYBOARD_KEY_STATE_PRESSED)
window_set_maximized(window,
window->type != TYPE_MAXIMIZED);
} else if (sym == XKB_KEY_F11 &&
window->fullscreen_handler &&
state == WL_KEYBOARD_KEY_STATE_PRESSED) {
window->fullscreen_handler(window, window->user_data);
} else if (window->key_handler) {
(*window->key_handler)(window, input, time, key,
sym, state, window->user_data);
@ -2836,6 +2842,13 @@ window_set_close_handler(struct window *window,
window->close_handler = handler;
}
void
window_set_fullscreen_handler(struct window *window,
window_fullscreen_handler_t handler)
{
window->fullscreen_handler = handler;
}
void
window_set_title(struct window *window, const char *title)
{

@ -176,6 +176,7 @@ typedef void (*window_drop_handler_t)(struct window *window,
int32_t x, int32_t y, void *data);
typedef void (*window_close_handler_t)(struct window *window, void *data);
typedef void (*window_fullscreen_handler_t)(struct window *window, void *data);
typedef void (*widget_resize_handler_t)(struct widget *widget,
int32_t width, int32_t height,
@ -303,6 +304,9 @@ window_set_drop_handler(struct window *window,
void
window_set_close_handler(struct window *window,
window_close_handler_t handler);
void
window_set_fullscreen_handler(struct window *window,
window_fullscreen_handler_t handler);
void
window_set_title(struct window *window, const char *title);

Loading…
Cancel
Save