/** * Hide window * * @param __window - window to be hided */ void w_window_hide (w_window_t *__window) { if (!__window || !WIDGET_LAYOUT (__window)) { return; } if (__window->focused_widget) { widget_pop_context (__window->focused_widget); __window->focused_widget->focused = FALSE; } widget_pop_context (WIDGET (__window)); __window->focused = FALSE; if (__window->show_mode != WSM_MODAL) { /* For modal windows closing confirmation is in window_proc */ if (WIDGET_CALL_USER_CALLBACK (__window, property_changed, __window, W_WINDOW_CONFIRMHIDE_PROP)) { /* User's handler denied window closing */ return; } } widget_delete_root (WIDGET (__window)); WIDGET_CALL_CALLBACK (__window, blured, __window); /* Window is now invisible */ WIDGET_POSITION (__window).z = 0; panel_hide (__window->panel); }
/** * Default part of window showing stuff * * @param __window - window to be shown * @param _show_mode - mode in which window have to be shown. * Possible values: * WSM_NORLAM - Normal window * WSM_MODAL - Modal window * @return zero or modal result of window on success. * Less-zero value on failure. */ static int window_show_entry (w_window_t *__window, int __show_mode) { if (!__window) { return -1; } /* Window is now visible */ WIDGET_POSITION (__window).z = 1; __window->focused = TRUE; panel_show (__window->panel); widget_add_root (WIDGET (__window)); widget_push_context (WIDGET (__window)); __window->show_mode = __show_mode; __window->modal_result = MR_NONE; /* widget_set_current_widget (WIDGET (__window)); */ /* Is it okay if we think that showing of window */ /* is the same as focusing of window? */ WIDGET_CALL_CALLBACK (__window, focused, __window); /* Set focus to first widget in window */ if (WIDGET_CONTAINER_LENGTH (__window)) { widget_t *w; if (!WIDGET_CONTAINER_FOCUSED (__window)) { w = widget_first_focusable (WIDGET_CONTAINER (__window)); } else { w = WIDGET_CONTAINER_FOCUSED (__window); w->focused = FALSE; } if (w) { widget_set_focus (w); } } /* Draw window */ widget_redraw (WIDGET (__window)); if (__show_mode == WSM_MODAL) { widget_t *w; window_proc (__window); if (!__window->mode_changing) { if ((w = __window->focused_widget)) { WIDGET_CALL_CALLBACK (w, blured, w); } w_window_hide (__window); return __window->modal_result; } } return 0; }
/* Callback for mouse events */ static void panel_check_click(struct yutani_msg_window_mouse_event * evt) { if (evt->wid == panel->wid) { if (evt->command == YUTANI_MOUSE_EVENT_CLICK) { /* Up-down click */ if (evt->new_x >= width - 24 ) { yutani_session_end(yctx); _continue = 0; } else if (evt->new_x < APP_OFFSET) { if (!appmenu) { appmenu = yutani_window_create(yctx, APPMENU_WIDTH + APPMENU_PAD_RIGHT, APPMENU_ITEM_HEIGHT * appmenu_items_count + APPMENU_PAD_BOTTOM); yutani_window_move(yctx, appmenu, 0, PANEL_HEIGHT); bctx = init_graphics_yutani_double_buffer(appmenu); redraw_appmenu(-1); yutani_focus_window(yctx, appmenu->wid); } else { /* ??? */ } } else if (evt->new_x > WIDGET_POSITION(1) && evt->new_x < WIDGET_POSITION(0)) { /* TODO: More generic widget click handling */ /* TODO: Show the volume manager */ } else if (evt->new_x >= APP_OFFSET && evt->new_x < LEFT_BOUND) { for (int i = 0; i < MAX_WINDOW_COUNT; ++i) { if (ads_by_l[i] == NULL) break; if (evt->new_x >= ads_by_l[i]->left && evt->new_x < ads_by_l[i]->left + TOTAL_CELL_WIDTH) { yutani_focus_window(yctx, ads_by_l[i]->wid); break; } } } } else if (evt->command == YUTANI_MOUSE_EVENT_MOVE || evt->command == YUTANI_MOUSE_EVENT_ENTER) { /* Movement, or mouse entered window */ if (evt->new_y < PANEL_HEIGHT) { for (int i = 0; i < MAX_WINDOW_COUNT; ++i) { if (ads_by_l[i] == NULL) { set_focused(-1); break; } if (evt->new_x >= ads_by_l[i]->left && evt->new_x < ads_by_l[i]->left + TOTAL_CELL_WIDTH) { set_focused(i); break; } } } else { set_focused(-1); } int scroll_direction = 0; if (evt->buttons & YUTANI_MOUSE_SCROLL_UP) scroll_direction = -1; else if (evt->buttons & YUTANI_MOUSE_SCROLL_DOWN) scroll_direction = 1; if (scroll_direction) { if (evt->new_x > WIDGET_POSITION(1) && evt->new_y < WIDGET_POSITION(0)) { if (scroll_direction == 1) { volume_lower(); } else if (scroll_direction == -1) { volume_raise(); } } else if (evt->new_x >= APP_OFFSET && evt->new_x < LEFT_BOUND) { if (scroll_direction != 0) { struct window_ad * last = window_list->tail ? window_list->tail->value : NULL; int focus_next = 0; foreach(node, window_list) { struct window_ad * ad = node->value; if (focus_next) { yutani_focus_window(yctx, ad->wid); return; } if (ad->flags & 1) { if (scroll_direction == -1) { yutani_focus_window(yctx, last->wid); return; } if (scroll_direction == 1) { focus_next = 1; } } last = ad; } if (focus_next && window_list->head) { struct window_ad * ad = window_list->head->value; yutani_focus_window(yctx, ad->wid); return; } } } } } else if (evt->command == YUTANI_MOUSE_EVENT_LEAVE) { /* Mouse left panel window */ set_focused(-1); } } else {