Ind_Win * e_mod_ind_win_new(E_Zone *zone) { Ind_Win *iwin; Ecore_X_Window_State states[2]; Evas_Coord h = 0; /* create our new indicator window object */ iwin = E_OBJECT_ALLOC(Ind_Win, IND_WIN_TYPE, _e_mod_ind_win_cb_free); if (!iwin) return NULL; h = (il_ind_cfg->height * e_scale); iwin->zone = zone; /* create new window */ iwin->win = e_win_new(zone->container); iwin->win->data = iwin; /* set some properties on the window */ e_win_title_set(iwin->win, _("Illume Indicator")); e_win_name_class_set(iwin->win, "Illume-Indicator", "Illume-Indicator"); e_win_no_remember_set(iwin->win, EINA_TRUE); /* hook into window resize so we can resize our objects */ e_win_resize_callback_set(iwin->win, _e_mod_ind_win_cb_resize); /* set this window to not show in taskbar or pager */ states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR; states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER; ecore_x_netwm_window_state_set(iwin->win->evas_win, states, 2); /* set this window to not accept or take focus */ ecore_x_icccm_hints_set(iwin->win->evas_win, 0, 0, 0, 0, 0, 0, 0); /* create the popup */ iwin->popup = e_popup_new(zone, 0, 0, zone->w, h); e_popup_name_set(iwin->popup, "indicator"); e_popup_layer_set(iwin->popup, 200); /* create our event rectangle */ iwin->o_event = evas_object_rectangle_add(iwin->win->evas); evas_object_color_set(iwin->o_event, 0, 0, 0, 0); evas_object_event_callback_add(iwin->o_event, EVAS_CALLBACK_MOUSE_DOWN, _e_mod_ind_win_cb_mouse_down, iwin); evas_object_event_callback_add(iwin->o_event, EVAS_CALLBACK_MOUSE_UP, _e_mod_ind_win_cb_mouse_up, iwin); evas_object_event_callback_add(iwin->o_event, EVAS_CALLBACK_MOUSE_MOVE, _e_mod_ind_win_cb_mouse_move, iwin); evas_object_move(iwin->o_event, 0, 0); evas_object_show(iwin->o_event); /* create our base object */ iwin->o_base = edje_object_add(iwin->win->evas); if (!e_theme_edje_object_set(iwin->o_base, "base/theme/modules/illume-indicator", "modules/illume-indicator/window")) { char buff[PATH_MAX]; snprintf(buff, sizeof(buff), "%s/e-module-illume-indicator.edj", _ind_mod_dir); edje_object_file_set(iwin->o_base, buff, "modules/illume-indicator/window"); } evas_object_move(iwin->o_base, 0, 0); evas_object_show(iwin->o_base); e_popup_edje_bg_object_set(iwin->popup, iwin->o_base); /* create our gadget container */ iwin->gadcon = e_gadcon_swallowed_new("illume-indicator", zone->id, iwin->o_base, "e.swallow.content"); edje_extern_object_min_size_set(iwin->gadcon->o_container, zone->w, h); e_gadcon_min_size_request_callback_set(iwin->gadcon, _e_mod_ind_win_cb_min_size_request, iwin); e_gadcon_size_request_callback_set(iwin->gadcon, _e_mod_ind_win_cb_size_request, iwin); e_gadcon_frame_request_callback_set(iwin->gadcon, _e_mod_ind_win_cb_frame_request, iwin); e_gadcon_orient(iwin->gadcon, E_GADCON_ORIENT_FLOAT); e_gadcon_zone_set(iwin->gadcon, zone); e_gadcon_ecore_evas_set(iwin->gadcon, iwin->win->ecore_evas); e_gadcon_util_menu_attach_func_set(iwin->gadcon, _e_mod_ind_win_cb_menu_items_append, iwin); e_gadcon_populate(iwin->gadcon); /* hook into property change so we can adjust w/ e_scale */ iwin->hdls = eina_list_append(iwin->hdls, ecore_event_handler_add(ECORE_X_EVENT_WINDOW_PROPERTY, _e_mod_ind_win_cb_win_prop, iwin)); /* hook into zone resize so we can set minimum window width when zone * size changes */ iwin->hdls = eina_list_append(iwin->hdls, ecore_event_handler_add(E_EVENT_ZONE_MOVE_RESIZE, _e_mod_ind_win_cb_zone_resize, iwin)); iwin->hdls = eina_list_append(iwin->hdls, ecore_event_handler_add(E_EVENT_BORDER_HIDE, _e_mod_ind_win_cb_border_hide, iwin)); iwin->hdls = eina_list_append(iwin->hdls, ecore_event_handler_add(E_EVENT_BORDER_SHOW, _e_mod_ind_win_cb_border_show, iwin)); /* set minimum size of this window & popup */ e_win_size_min_set(iwin->win, zone->w, h); ecore_evas_size_min_set(iwin->popup->ecore_evas, zone->w, h); /* position and resize this window */ e_win_move_resize(iwin->win, zone->x, zone->y, zone->w, h); e_popup_move_resize(iwin->popup, zone->x, zone->y, zone->w, h); /* show the window */ e_win_show(iwin->win); e_popup_show(iwin->popup); /* set this window on proper zone */ e_border_zone_set(iwin->win->border, zone); iwin->win->border->user_skip_winlist = 1; iwin->win->border->lock_focus_in = 1; iwin->win->border->lock_focus_out = 1; /* set this window to be a dock window. This needs to be done after show * as E will sometimes reset the window type */ ecore_x_netwm_window_type_set(iwin->win->evas_win, ECORE_X_WINDOW_TYPE_DOCK); /* tell conformant apps our position and size */ ecore_x_e_illume_indicator_geometry_set(zone->black_win, zone->x, zone->y, zone->w, h); return iwin; }
int e_syscon_show(E_Zone *zone, const char *defact) { Evas_Object *o, *o2; Evas_Coord mw, mh; int x, y, w, h, zx, zy, zw, zh; int iw, ih; Eina_List *l; double t; t = ecore_loop_time_get(); if (popup) { if ((t - show_time) > 0.5) { for (l = e_config->syscon.actions; l; l = l->next) { E_Config_Syscon_Action *sca; E_Action *a; if (!(sca = l->data)) continue; if (!sca->action) continue; a = e_action_find(sca->action); if (!a) continue; if (sca->is_main == 2) { a->func.go(NULL, sca->params); e_syscon_hide(); break; } } } return 0; } input_window = ecore_x_window_input_new(zone->container->win, zone->x, zone->y, zone->w, zone->h); ecore_x_window_show(input_window); if (!e_grabinput_get(input_window, 1, input_window)) { ecore_x_window_free(input_window); input_window = 0; return 0; } popup = e_popup_new(zone, 0, 0, 1, 1); if (!popup) { e_grabinput_release(input_window, input_window); ecore_x_window_free(input_window); input_window = 0; return 0; } evas_event_freeze(popup->evas); e_popup_layer_set(popup, E_LAYER_POPUP); handlers = eina_list_append (handlers, ecore_event_handler_add (ECORE_EVENT_KEY_DOWN, _cb_key_down, NULL)); handlers = eina_list_append (handlers, ecore_event_handler_add (ECORE_EVENT_MOUSE_BUTTON_DOWN, _cb_mouse_down, NULL)); handlers = eina_list_append (handlers, ecore_event_handler_add (ECORE_EVENT_MOUSE_BUTTON_UP, _cb_mouse_up, NULL)); handlers = eina_list_append (handlers, ecore_event_handler_add (ECORE_EVENT_MOUSE_MOVE, _cb_mouse_move, NULL)); handlers = eina_list_append (handlers, ecore_event_handler_add (ECORE_EVENT_MOUSE_WHEEL, _cb_mouse_wheel, NULL)); o = edje_object_add(popup->evas); o_bg = o; e_theme_edje_object_set(o, "base/theme/syscon", "e/widgets/syscon/main"); edje_object_part_text_set(o, "e.text.label", _("Cancel")); edje_object_signal_callback_add(o, "e,action,close", "", _cb_signal_close, NULL); edje_object_signal_callback_add(o, "e,action,syscon", "*", _cb_signal_syscon, NULL); act_count = 0; show_time = t; // main (default): // halt | suspend | desk_lock // secondary (default): // reboot | hibernate | logout // extra (example for illume): // home | close | kill o = e_flowlayout_add(popup->evas); o_flow_main = o; e_flowlayout_orientation_set(o, 1); e_flowlayout_flowdirection_set(o, 1, 1); e_flowlayout_homogenous_set(o, 1); o = e_flowlayout_add(popup->evas); o_flow_secondary = o; e_flowlayout_orientation_set(o, 1); e_flowlayout_flowdirection_set(o, 1, 1); e_flowlayout_homogenous_set(o, 1); o = e_flowlayout_add(popup->evas); o_flow_extra = o; e_flowlayout_orientation_set(o, 1); e_flowlayout_flowdirection_set(o, 1, 1); e_flowlayout_homogenous_set(o, 1); for (l = e_config->syscon.actions; l; l = l->next) { E_Config_Syscon_Action *sca; char buf[1024]; E_Action *a; int disabled; if (!(sca = l->data)) continue; if (!sca->action) continue; a = e_action_find(sca->action); if (!a) continue; disabled = 0; if ((!strcmp(sca->action, "logout")) && (!e_sys_action_possible_get(E_SYS_LOGOUT))) disabled = 1; else if ((!strcmp(sca->action, "halt")) && (!e_sys_action_possible_get(E_SYS_HALT))) disabled = 1; else if ((!strcmp(sca->action, "halt_now")) && (!e_sys_action_possible_get(E_SYS_HALT_NOW))) disabled = 1; else if ((!strcmp(sca->action, "reboot")) && (!e_sys_action_possible_get(E_SYS_REBOOT))) disabled = 1; else if ((!strcmp(sca->action, "suspend")) && (!e_sys_action_possible_get(E_SYS_SUSPEND))) disabled = 1; else if ((!strcmp(sca->action, "hibernate")) && (!e_sys_action_possible_get(E_SYS_HIBERNATE))) disabled = 1; o = edje_object_add(popup->evas); edje_object_signal_callback_add(o, "e,action,click", "", _cb_signal_action, sca); if (sca->button) { snprintf(buf, sizeof(buf), "e/widgets/syscon/item/%s", sca->button); e_theme_edje_object_set(o, "base/theme/widgets", buf); } else e_theme_edje_object_set(o, "base/theme/widgets", "e/widgets/syscon/item/button"); edje_object_part_text_set(o, "e.text.label", _(e_action_predef_label_get(sca->action, sca->params))); if (sca->icon) { o2 = e_icon_add(popup->evas); e_util_icon_theme_set(o2, sca->icon); edje_object_part_swallow(o, "e.swallow.icon", o2); evas_object_show(o2); if (disabled) edje_object_signal_emit(o2, "e,state,disabled", "e"); } if (disabled) edje_object_signal_emit(o, "e,state,disabled", "e"); if (sca->is_main) { e_flowlayout_pack_end(o_flow_main, o); iw = ih = e_config->syscon.main.icon_size * e_scale; } else { e_flowlayout_pack_end(o_flow_secondary, o); iw = ih = e_config->syscon.secondary.icon_size * e_scale; } edje_object_message_signal_process(o); edje_object_size_min_calc(o, &mw, &mh); if (mw > iw) iw = mw; if (mh > ih) ih = mh; e_flowlayout_pack_options_set(o, 1, 1, 0, 0, 0.5, 0.5, iw, ih, iw, ih); evas_object_show(o); } for (l = (Eina_List *)e_sys_con_extra_action_list_get(); l; l = l->next) { E_Sys_Con_Action *sca; char buf[1024]; sca = l->data; o = edje_object_add(popup->evas); edje_object_signal_callback_add(o, "e,action,click", "", _cb_signal_action_extra, sca); if (sca->button_name) { snprintf(buf, sizeof(buf), "e/widgets/syscon/item/%s", sca->button_name); e_theme_edje_object_set(o, "base/theme/widgets", buf); } else e_theme_edje_object_set(o, "base/theme/widgets", "e/widgets/syscon/item/button"); edje_object_part_text_set(o, "e.text.label", sca->label); if (sca->icon_group) { o2 = edje_object_add(popup->evas); e_util_edje_icon_set(o2, sca->icon_group); edje_object_part_swallow(o, "e.swallow.icon", o2); evas_object_show(o2); if (sca->disabled) edje_object_signal_emit(o2, "e,state,disabled", "e"); } if (sca->disabled) edje_object_signal_emit(o, "e,state,disabled", "e"); e_flowlayout_pack_end(o_flow_extra, o); iw = ih = e_config->syscon.extra.icon_size * e_scale; e_flowlayout_pack_options_set(o, 1, 1, 0, 0, 0.5, 0.5, iw, ih, iw, ih); evas_object_show(o); } e_flowlayout_fill_set(o_flow_main, 1); edje_object_part_swallow(o_bg, "e.swallow.main", o_flow_main); e_flowlayout_fill_set(o_flow_secondary, 1); edje_object_part_swallow(o_bg, "e.swallow.secondary", o_flow_secondary); e_flowlayout_fill_set(o_flow_extra, 1); edje_object_part_swallow(o_bg, "e.swallow.extra", o_flow_extra); e_zone_useful_geometry_get(zone, &zx, &zy, &zw, &zh); evas_object_resize(o_bg, zw, zh); edje_object_calc_force(o_bg); e_flowlayout_size_min_get(o_flow_main, &mw, &mh); edje_extern_object_min_size_set(o_flow_main, mw, mh); edje_object_part_swallow(o_bg, "e.swallow.main", o_flow_main); e_flowlayout_size_min_get(o_flow_secondary, &mw, &mh); edje_extern_object_min_size_set(o_flow_secondary, mw, mh); edje_object_part_swallow(o_bg, "e.swallow.secondary", o_flow_secondary); e_flowlayout_size_min_get(o_flow_extra, &mw, &mh); edje_extern_object_min_size_set(o_flow_extra, mw, mh); edje_object_part_swallow(o_bg, "e.swallow.extra", o_flow_extra); edje_object_size_min_calc(o_bg, &mw, &mh); w = mw; if (w > zw) w = zw; x = zx - zone->x + (zw - w) / 2; h = mh; if (h > zh) h = zh; y = zy - zone->y + (zh - h) / 2; e_popup_move_resize(popup, x, y, w, h); evas_object_move(o_bg, 0, 0); evas_object_resize(o_bg, w, h); evas_object_show(o_bg); e_popup_edje_bg_object_set(popup, o_bg); if (e_config->syscon.do_input) { deftimer = ecore_timer_add(e_config->syscon.timeout, _cb_timeout_defaction, NULL); if (defact) do_defact = eina_stringshare_add(defact); } evas_event_thaw(popup->evas); inevas = 0; e_popup_show(popup); return 1; }
static void _e_gadcon_popup_position(E_Gadcon_Popup *pop) { Evas_Coord gx, gy, gw, gh, zw, zh, zx, zy, px, py; /* Popup positioning */ e_gadcon_client_geometry_get(pop->gcc, &gx, &gy, &gw, &gh); zx = pop->win->zone->x; zy = pop->win->zone->y; zw = pop->win->zone->w; zh = pop->win->zone->h; switch (pop->gcc->gadcon->orient) { case E_GADCON_ORIENT_CORNER_RT: case E_GADCON_ORIENT_CORNER_RB: case E_GADCON_ORIENT_RIGHT: px = gx - pop->w; py = gy; if (py + pop->h >= (zy + zh)) py = gy + gh - pop->h; break; case E_GADCON_ORIENT_LEFT: case E_GADCON_ORIENT_CORNER_LT: case E_GADCON_ORIENT_CORNER_LB: px = gx + gw; py = gy; if (py + pop->h >= (zy + zh)) py = gy + gh - pop->h; break; case E_GADCON_ORIENT_TOP: case E_GADCON_ORIENT_CORNER_TL: case E_GADCON_ORIENT_CORNER_TR: py = gy + gh; px = (gx + (gw / 2)) - (pop->w / 2); if ((px + pop->w) >= (zx + zw)) px = gx + gw - pop->w; else if (px < zx) px = zx; break; case E_GADCON_ORIENT_BOTTOM: case E_GADCON_ORIENT_CORNER_BL: case E_GADCON_ORIENT_CORNER_BR: py = gy - pop->h; px = (gx + (gw / 2)) - (pop->w / 2); if ((px + pop->w) >= (zx + zw)) px = gx + gw - pop->w; else if (px < zx) px = zx; break; case E_GADCON_ORIENT_FLOAT: px = (gx + (gw / 2)) - (pop->w / 2); if (gy >= (zy + (zh / 2))) py = gy - pop->h; else py = gy + gh; if ((px + pop->w) >= (zx + zw)) px = gx + gw - pop->w; else if (px < zx) px = zx; break; default: e_popup_move_resize(pop->win, 50, 50, pop->w, pop->h); return; } if (px - zx < 0) px = zx; if (py - zy < 0) py = zy; e_popup_move_resize(pop->win, px - zx, py - zy, pop->w, pop->h); if (pop->gadcon_lock && (!pop->gadcon_was_locked)) _e_gadcon_popup_locked_set(pop, 1); }