From: Kristian Høgsberg Date: Tue, 24 Jul 2012 01:56:31 +0000 (-0400) Subject: window.c: Add fullscreen handler to keep fullscreen state consistent X-Git-Tag: 0.95.0~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=67ace20f8ebc2088d560874c49eb79ca122b68da;p=platform%2Fupstream%2Fweston.git window.c: Add fullscreen handler to keep fullscreen state consistent --- diff --git a/clients/terminal.c b/clients/terminal.c index 7e7a9fb..dd35ceb 100644 --- a/clients/terminal.c +++ b/clients/terminal.c @@ -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); diff --git a/clients/view.c b/clients/view.c index ee861e4..b40a992 100644 --- a/clients/view.c +++ b/clients/view.c @@ -159,6 +159,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, enum wl_keyboard_key_state state, void *data) @@ -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); diff --git a/clients/window.c b/clients/window.c index d374ab9..186eed9 100644 --- a/clients/window.c +++ b/clients/window.c @@ -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); @@ -2837,6 +2843,13 @@ window_set_close_handler(struct window *window, } 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) { free(window->title); diff --git a/clients/window.h b/clients/window.h index de38647..da18932 100644 --- a/clients/window.h +++ b/clients/window.h @@ -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);