add block system.. not quite functional yet.. but will be needed...

now iconbars can have their buttons "disabled" whislt apps launch.. tis a
nasty trick with an ld_preload... has caveats.. if youdsont set it as on it
wont be used atm.


SVN revision: 5748
This commit is contained in:
Carsten Haitzler 2001-12-06 08:06:52 +00:00
parent 510d0ded29
commit 7880065bff
15 changed files with 420 additions and 21 deletions

View File

@ -26,6 +26,7 @@ endif
enlightenment_SOURCES = \
actions.h actions.c \
background.h background.c \
block.c block.h \
border.h border.c \
bordermenu.h bordermenu.c \
config.h config.c \

View File

@ -10,6 +10,7 @@
#include "util.h"
#include "guides.h"
#include "bordermenu.h"
#include "block.h"
static Evas_List action_impls = NULL;
static Evas_List current_actions = NULL;
@ -665,6 +666,8 @@ e_act_move_start (E_Object *object, E_Action *a, void *data, int x, int y, int r
E_CFG_INT(cfg_guides_display_location, "settings", "/guides/display/location", E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE);
D_ENTER;
e_block_start("menus");
E_CONFIG_INT_GET(cfg_window_move_mode, move_mode);
E_CONFIG_FLOAT_GET(cfg_guides_display_x, align_x);
@ -723,6 +726,8 @@ e_act_move_stop (E_Object *object, E_Action *a, void *data, int x, int y, int r
b = (E_Border*) object;
e_block_stop("menus");
if (!b)
b = e_border_current_focused();
@ -814,6 +819,8 @@ e_act_resize_start (E_Object *object, E_Action *a, void *data, int x, int y, int
E_CFG_INT(cfg_guides_display_location, "settings", "/guides/display/location", E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE);
D_ENTER;
e_block_start("menus");
E_CONFIG_INT_GET(cfg_window_resize_mode, resize_mode);
E_CONFIG_FLOAT_GET(cfg_guides_display_x, align_x);
@ -896,6 +903,8 @@ e_act_resize_stop (E_Object *object, E_Action *a, void *data, int x, int y, int
D_ENTER;
e_block_stop("menus");
b = (E_Border*) object;
if (!b) b = e_border_current_focused();
if (!b) D_RETURN;
@ -995,6 +1004,8 @@ e_act_resize_h_start (E_Object *object, E_Action *a, void *data, int x, int y, i
E_CFG_INT(cfg_guides_display_location, "settings", "/guides/display/location", E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE);
D_ENTER;
e_block_start("menus");
E_CONFIG_INT_GET(cfg_window_resize_mode, resize_mode);
E_CONFIG_FLOAT_GET(cfg_guides_display_x, align_x);
@ -1053,9 +1064,10 @@ e_act_resize_h_stop (E_Object *object, E_Action *a, void *data, int x, int y, i
{
E_Border *b;
D_ENTER;
e_block_stop("menus");
b = (E_Border*) object;
if (!b) b = e_border_current_focused();
if (!b) D_RETURN;
@ -1138,7 +1150,9 @@ e_act_resize_v_start (E_Object *object, E_Action *a, void *data, int x, int y, i
E_CFG_INT(cfg_guides_display_location, "settings", "/guides/display/location", E_GUIDES_DISPLAY_LOCATION_WINDOW_MIDDLE);
D_ENTER;
e_block_start("menus");
E_CONFIG_INT_GET(cfg_window_resize_mode, resize_mode);
E_CONFIG_FLOAT_GET(cfg_guides_display_x, align_x);
E_CONFIG_FLOAT_GET(cfg_guides_display_y, align_y);
@ -1199,6 +1213,8 @@ e_act_resize_v_stop (E_Object *object, E_Action *a, void *data, int x, int y, i
D_ENTER;
e_block_stop("menus");
b = (E_Border*) object;
if (!b) b = e_border_current_focused();
if (!b) D_RETURN;
@ -1527,6 +1543,7 @@ e_act_menu_start (E_Object *object, E_Action *a, void *data, int x, int y, int r
D_ENTER;
if (e_block_is_active("menus")) D_RETURN;
b = (E_Border*) object;
if (!b) b = e_border_current_focused();
if (!b) D_RETURN;
@ -1554,7 +1571,7 @@ e_act_exit_start (E_Object *object, E_Action *a, void *data, int x, int y, int r
ecore_focus_mode_reset();
ecore_sync();
e_db_flush();
e_db_runtime_flush();
exit(0);
@ -1579,7 +1596,7 @@ e_act_restart_start (E_Object *object, E_Action *a, void *data, int x, int y, in
ecore_focus_mode_reset();
ecore_sync();
e_db_flush();
e_db_runtime_flush();
e_exec_restart();

90
src/block.c Normal file
View File

@ -0,0 +1,90 @@
#include "block.h"
#include "debug.h"
#include "util.h"
typedef struct _e_block E_Block;
struct _e_block
{
char *name;
int refs;
};
static Evas_List blocks = NULL;
static E_Block *e_block_find(char *name);
static E_Block *
e_block_find(char *name)
{
Evas_List l;
D_ENTER;
for (l = blocks; l; l = l->next)
{
E_Block *b;
b = l->data;
if (!strcmp(b->name, name))
{
blocks = evas_list_remove(blocks, b);
blocks = evas_list_prepend(blocks, b);
D_RETURN_(b);
}
}
D_RETURN_(NULL);
}
void
e_block_start(char *name)
{
E_Block *b;
D_ENTER;
b = e_block_find(name);
if (b)
{
b->refs++;
D_RETURN;
}
b = NEW(E_Block, 1);
ZERO(b, E_Block, 1);
e_strdup(b->name, name);
b->refs = 1;
blocks = evas_list_prepend(blocks, b);
D_RETURN;
}
void
e_block_stop(char *name)
{
E_Block *b;
D_ENTER;
b = e_block_find(name);
if (b)
{
b->refs--;
if (b->refs < 1)
{
blocks = evas_list_remove(blocks, b);
IF_FREE(b->name);
FREE(b);
}
}
D_RETURN;
}
int
e_block_is_active(char *name)
{
E_Block *b;
D_ENTER;
b = e_block_find(name);
if (b)
{
D_RETURN_(b->refs);
}
D_RETURN_(0);
}

11
src/block.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef E_BLOCK_H
#define E_BLOCK_H
#include "e.h"
void e_block_start(char *name);
void e_block_stop(char *name);
int e_block_is_active(char *name);
#endif

View File

@ -13,6 +13,7 @@
#include "match.h"
#include "focus.h"
#include "menu.h"
#include "exec.h"
/* Window border rendering, querying, setting & modification code */
@ -122,7 +123,7 @@ e_border_update_borders(void)
evas_render(b->evas.b);
}
}
e_db_flush();
e_db_runtime_flush();
D_RETURN;
}
@ -1482,6 +1483,7 @@ e_border_adopt(Window win, int use_client_pos)
e_icccm_get_machine(win, b);
e_icccm_get_command(win, b);
e_icccm_get_icon_name(win, b);
e_icccm_get_e_hack_launch_id(win, b);
b->current.shaped_client = e_icccm_is_shaped(win);
/* we have now placed the bugger */
b->placed = 1;
@ -1594,6 +1596,9 @@ e_border_adopt(Window win, int use_client_pos)
e_border_raise(b);
ecore_window_show(win);
if (b->client.e.launch_id)
e_exec_broadcast_e_hack_found(b->win.client);
D_RETURN_(b);
}

View File

@ -97,6 +97,12 @@ struct _E_Border
int is_desktop;
int w, h;
int no_place;
struct {
int launch_id;
pid_t pid;
pid_t ppid;
uid_t user;
} e;
struct {
int requested;
int x, y;

View File

@ -21,7 +21,7 @@ ecore_idle(void *data)
D_ENTER;
/* FIXME -- Raster, how is this related to the desktop code? */
e_db_flush();
e_db_runtime_flush();
D_RETURN;
UN(data);
}

View File

@ -6,6 +6,69 @@
static int e_argc = 0;
static char **e_argv = NULL;
typedef struct _e_hack_found_cb E_Hack_Found_CB;
struct _e_hack_found_cb
{
int dirty;
void (*func) (Window win, void *data);
void *func_data;
};
static Evas_List hack_found_cb = NULL;
void *
e_exec_broadcast_cb_add(void (*func) (Window win, void *_data), void *data)
{
E_Hack_Found_CB *cb;
cb = NEW(E_Hack_Found_CB, 1);
ZERO(cb, E_Hack_Found_CB, 1);
cb->func = func;
cb->func_data = data;
hack_found_cb = evas_list_append(hack_found_cb, cb);
return cb;
}
void
e_exec_broadcast_cb_del(void *cbp)
{
E_Hack_Found_CB *cb;
cb = (E_Hack_Found_CB *)cbp;
cb->dirty = 1;
}
void
e_exec_broadcast_e_hack_found(Window win)
{
Evas_List l;
for (l = hack_found_cb; l; l = l->next)
{
E_Hack_Found_CB *cb;
cb = l->data;
if (!cb->dirty)
{
if (cb->func)
cb->func(win, cb->func_data);
}
}
again:
for (l = hack_found_cb; l; l = l->next)
{
E_Hack_Found_CB *cb;
cb = l->data;
if (cb->dirty)
{
hack_found_cb = evas_list_remove(hack_found_cb, cb);
goto again;
}
}
}
void
e_exec_set_args(int argc, char **argv)
{

View File

@ -3,6 +3,9 @@
#include "e.h"
void *e_exec_broadcast_cb_add(void (*func) (Window win, void *data), void *data);
void e_exec_broadcast_cb_del(void *cb);
void e_exec_broadcast_e_hack_found(Window win);
void e_exec_set_args(int argc, char **argv);
void e_exec_restart(void);
pid_t e_exec_run(char *exe);

View File

@ -76,16 +76,16 @@ e_guides_update(void)
{
if (!guides.win.display)
{
guides.win.display = ecore_window_override_new(0, 0, 0, 1, 1);
guides.win.l = ecore_window_override_new(0, 0, 0, 1, 1);
guides.win.r = ecore_window_override_new(0, 0, 0, 1, 1);
guides.win.t = ecore_window_override_new(0, 0, 0, 1, 1);
guides.win.b = ecore_window_override_new(0, 0, 0, 1, 1);
ecore_window_save_under(guides.win.display);
guides.win.display = ecore_window_override_new(0, 0, 0, 1, 1);
ecore_window_save_under(guides.win.l);
ecore_window_save_under(guides.win.r);
ecore_window_save_under(guides.win.t);
ecore_window_save_under(guides.win.b);
ecore_window_save_under(guides.win.display);
redraw = 1;
}
if (!guides.disp.evas)
@ -463,14 +463,19 @@ e_guides_update(void)
{
if (guides.current.mode == E_GUIDES_BOX)
{
ecore_window_raise(guides.win.l);
ecore_window_show(guides.win.l);
ecore_window_raise(guides.win.r);
ecore_window_show(guides.win.r);
ecore_window_raise(guides.win.t);
ecore_window_show(guides.win.t);
ecore_window_raise(guides.win.b);
ecore_window_show(guides.win.b);
if (guides.current.visible)
{
ecore_window_raise(guides.win.l);
ecore_window_show(guides.win.l);
ecore_window_raise(guides.win.r);
ecore_window_show(guides.win.r);
ecore_window_raise(guides.win.t);
ecore_window_show(guides.win.t);
ecore_window_raise(guides.win.b);
ecore_window_show(guides.win.b);
ecore_window_raise(guides.win.display);
ecore_window_show(guides.win.display);
}
}
else if (guides.prev.mode == E_GUIDES_OPAQUE)
{

View File

@ -577,6 +577,35 @@ e_icccm_is_shaped(Window win)
D_RETURN_(shaped);
}
void
e_icccm_get_e_hack_launch_id(Window win, E_Border *b)
{
static Atom a_e_hack_launch_id = 0;
int *props;
int size;
D_ENTER;
ECORE_ATOM(a_e_hack_launch_id, "_E_HACK_LAUNCH_ID");
props = ecore_window_property_get(win, a_e_hack_launch_id, XA_STRING, &size);
if (props)
{
char *str;
str = NEW(char, size + 1);
ZERO(str, char, size + 1);
memcpy(str, props, size);
b->client.e.launch_id = atoi(str);
FREE(str);
FREE(props);
}
else
b->client.e.launch_id = 0;
D_RETURN;
}
void
e_icccm_handle_property_change(Atom a, E_Border *b)
{
@ -589,6 +618,7 @@ e_icccm_handle_property_change(Atom a, E_Border *b)
static Atom a_wm_command = 0;
static Atom a_wm_icon_name = 0;
static Atom a_wm_state = 0;
static Atom a_e_hack_launch_id = 0;
D_ENTER;
@ -601,7 +631,8 @@ e_icccm_handle_property_change(Atom a, E_Border *b)
ECORE_ATOM(a_wm_command, "WM_COMMAND");
ECORE_ATOM(a_wm_icon_name, "WM_ICON_NAME");
ECORE_ATOM(a_wm_state, "WM_STATE");
ECORE_ATOM(a_e_hack_launch_id, "_E_HACK_LAUNCH_ID");
if (a == a_wm_normal_hints) e_icccm_get_size_info(b->win.client, b);
else if (a == a_motif_wm_hints) e_icccm_get_mwm_hints(b->win.client, b);
else if (a == a_wm_name) e_icccm_get_title(b->win.client, b);
@ -611,7 +642,8 @@ e_icccm_handle_property_change(Atom a, E_Border *b)
else if (a == a_wm_command) e_icccm_get_command(b->win.client, b);
else if (a == a_wm_icon_name) e_icccm_get_icon_name(b->win.client, b);
else if (a == a_wm_state) e_icccm_get_state(b->win.client, b);
else if (a == a_e_hack_launch_id) e_icccm_get_e_hack_launch_id(b->win.client, b);
D_RETURN;
}

View File

@ -27,6 +27,7 @@ void e_icccm_set_desk_area(Window win, int ax, int ay);
void e_icccm_set_desk_area_size(Window win, int ax, int ay);
void e_icccm_set_desk(Window win, int d);
int e_icccm_is_shaped(Window win);
void e_icccm_get_e_hack_launch_id(Window win, E_Border *b);
void e_icccm_handle_property_change(Atom a, E_Border *b);
void e_icccm_handle_client_message(Ecore_Event_Message *e);
void e_icccm_advertise_e_compat(void);

View File

@ -1,10 +1,14 @@
#include "debug.h"
#include "iconbar.h"
#include "util.h"
#include "desktops.h"
#include "border.h"
static E_Config_Base_Type *cf_iconbar = NULL;
static E_Config_Base_Type *cf_iconbar_icon = NULL;
static Evas_List iconbars = NULL;
/* internal func (iconbar use only) prototypes */
static void e_ib_bit_down_cb(void *data, Ebits_Object o, char *class, int bt, int x, int y, int ox, int oy, int ow, int oh);
@ -13,6 +17,7 @@ static void e_ib_bit_up_cb(void *data, Ebits_Object o, char *class, int bt, int
static void ib_reload_timeout(int val, void *data);
static void ib_scroll_timeout(int val, void *data);
static void ib_timeout(int val, void *data);
static void ib_cancel_launch_timeout(int val, void *data);
static void ib_bits_show(void *data);
static void ib_bits_hide(void *data);
@ -33,6 +38,8 @@ static void ib_mouse_up(void *data, Evas _e, Evas_Object _o, int _b, int _x, int
static void e_iconbar_icon_cleanup(E_Iconbar_Icon *ic);
static void ib_child_handle(Ecore_Event *ev);
/* NB: comments here for illustration & helping people understand E's code */
/* This is a start of the comments. if you feel they are not quite good */
/* as you figure things out and if you think they could be more helpful */
@ -95,6 +102,9 @@ e_iconbar_cleanup(E_Iconbar *ib)
char buf[PATH_MAX];
D_ENTER;
/* remove from our list */
iconbars = evas_list_remove(iconbars, ib);
/* save scroll position */
/* tell the view we attached to that somehting in it changed. this way */
@ -154,6 +164,8 @@ e_iconbar_init()
/* the struct memebr is exec. the default value is "". see the config.h */
/* header for more info */
E_CONFIG_NODE(cf_iconbar_icon, "exec", E_CFG_TYPE_STR, NULL, E_Iconbar_Icon, exec, 0, 0, "");
E_CONFIG_NODE(cf_iconbar_icon, "wait", E_CFG_TYPE_INT, NULL, E_Iconbar_Icon, wait, 0, 0, "");
E_CONFIG_NODE(cf_iconbar_icon, "wait_timeout", E_CFG_TYPE_FLOAT, NULL, E_Iconbar_Icon, wait_timeout, 0, 0, "");
/* this memebr will be replaced by the relative key path in the db as a */
/* string */
E_CONFIG_NODE(cf_iconbar_icon, "image", E_CFG_TYPE_KEY, NULL, E_Iconbar_Icon, image_path, 0, 0, "");
@ -165,6 +177,8 @@ e_iconbar_init()
E_CONFIG_NODE(cf_iconbar, "icons", E_CFG_TYPE_LIST, cf_iconbar_icon, E_Iconbar, icons, 0, 0, NULL);
E_CONFIG_NODE(cf_iconbar, "scroll", E_CFG_TYPE_FLOAT, NULL, E_Iconbar, scroll, 0, 0, NULL);
ecore_event_filter_handler_add(ECORE_EVENT_CHILD, ib_child_handle);
D_RETURN;
}
@ -245,6 +259,9 @@ e_iconbar_new(E_View *v)
ebits_set_classed_bit_callback(ib->bit, "Scrollbar_Arrow2", CALLBACK_MOUSE_DOWN, e_ib_bit_down_cb, ib);
ebits_set_classed_bit_callback(ib->bit, "Scrollbar_Arrow2", CALLBACK_MOUSE_UP, e_ib_bit_up_cb, ib);
/* add to our list of iconbars */
iconbars = evas_list_append(iconbars, ib);
/* aaah. our nicely constructed iconbar data struct with all the goodies */
/* we need. return it. she's ready for use. */
D_RETURN_(ib);
@ -273,6 +290,19 @@ e_iconbar_icon_cleanup(E_Iconbar_Icon *ic)
}
if (ic->hi.image) evas_del_object(ic->iconbar->view->evas, ic->hi.image);
if (ic->launch_id_cb)
{
e_exec_broadcast_cb_del(ic->launch_id_cb);
ic->launch_id_cb = NULL;
}
if (ic->launch_id)
{
char buf[PATH_MAX];
sprintf(buf, "iconbar_launch_wait:%i", ic->launch_id);
ecore_del_event_timer(buf);
ic->launch_id = 0;
}
/* Call the destructor of the base class */
e_object_cleanup(E_OBJECT(ic));
@ -657,6 +687,31 @@ e_iconbar_save_out_final(E_Iconbar *ib)
}
}
void
e_iconbar_handle_launch_id(Window win, void *data)
{
E_Iconbar_Icon *ic;
E_Border *b;
ic = (E_Iconbar_Icon *)data;
b = e_border_find_by_window(win);
if (!b) return;
if ((ic->launch_id) && (b->client.e.launch_id))
{
if (b->client.e.launch_id == ic->launch_id)
{
ic->launch_id = 0;
if (ic->launch_id_cb)
{
e_exec_broadcast_cb_del(ic->launch_id_cb);
ic->launch_id_cb = NULL;
}
evas_set_color(ic->iconbar->view->evas, ic->image, 255, 255, 255, 128);
ic->iconbar->view->changed = 1;
}
}
}
/* static (internal to iconbar use only) callbacks */
/* reload timeout. called whenevr iconbar special files changed/added to */
@ -710,6 +765,26 @@ ib_scroll_timeout(int val, void *data)
D_RETURN;
}
static void
ib_cancel_launch_timeout(int val, void *data)
{
E_Iconbar_Icon *ic;
ic = (E_Iconbar_Icon *)data;
if (ic->launch_id)
{
ic->launch_id = 0;
if (ic->launch_id_cb)
{
e_exec_broadcast_cb_del(ic->launch_id_cb);
ic->launch_id_cb = NULL;
}
evas_set_color(ic->iconbar->view->evas, ic->image, 255, 255, 255, 128);
ic->iconbar->view->changed = 1;
}
}
/* this timeout is responsible for doing the mouse over animation */
static void
ib_timeout(int val, void *data)
@ -751,8 +826,14 @@ ib_timeout(int val, void *data)
}
/* what tame is it ? */
t = ecore_get_time();
if (ic->launch_id)
{
evas_set_color(ic->iconbar->view->evas, ic->image, 255, 255, 255, 50);
if (ic->hi.image)
evas_set_color(ic->iconbar->view->evas, ic->hi.image, 255, 255, 255, 0);
}
/* if the icon is hilited */
if (ic->hilited)
else if (ic->hilited)
{
double x, y, w, h;
double nw, nh, tt;
@ -1089,8 +1170,44 @@ ib_mouse_down(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
/* get he iconbaricon pointer from the data member */
ic = (E_Iconbar_Icon *)data;
/* if we're busy launching something.. dont run anything */
if (ic->launch_id) D_RETURN;
/* run something! */
if (ic->exec) e_exec_run(ic->exec);
if (ic->exec)
{
if (!ic->wait)
{
if (e_exec_run(ic->exec) < 0)
{
/* FIXME: display error */
}
}
else
{
int id_ret = 0;
ic->launch_pid = e_exec_in_dir_with_env(ic->exec, e_util_get_user_home(), &id_ret, NULL, NULL);
if (ic->launch_pid >= 0)
{
ic->launch_id = id_ret;
if (id_ret)
{
char buf[PATH_MAX];
ic->launch_id_cb =
e_exec_broadcast_cb_add(e_iconbar_handle_launch_id, ic);
sprintf(buf, "iconbar_launch_wait:%i", ic->launch_id);
if (ic->wait_timeout > 0.0)
ecore_add_event_timer(buf, ic->wait_timeout, ib_cancel_launch_timeout, ic->launch_id, ic);
else
ecore_add_event_timer(buf, 15, ib_cancel_launch_timeout, ic->launch_id, ic);
evas_set_color(ic->iconbar->view->evas, ic->image, 255, 255, 255, 50);
if (ic->hi.image)
evas_set_color(ic->iconbar->view->evas, ic->hi.image, 255, 255, 255, 0);
}
}
}
}
D_RETURN;
}
@ -1103,3 +1220,43 @@ ib_mouse_up(void *data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
D_RETURN;
}
/* called when child processes exit */
static void
ib_child_handle(Ecore_Event *ev)
{
Ecore_Event_Child *e;
Evas_List l;
D_ENTER;
e = ev->event;
for (l = iconbars; l; l = l->next)
{
E_Iconbar *ib;
Evas_List ll;
ib = l->data;
for (ll = ib->icons; ll; ll = ll->next)
{
E_Iconbar_Icon *ic;
ic = ll->data;
if (ic->launch_pid == e->pid)
{
ic->launch_pid = 0;
ic->launch_id = 0;
if (ic->launch_id_cb)
{
e_exec_broadcast_cb_del(ic->launch_id_cb);
ic->launch_id_cb = NULL;
}
evas_set_color(ic->iconbar->view->evas, ic->image, 255, 255, 255, 128);
ic->iconbar->view->changed = 1;
D_RETURN;
}
}
}
D_RETURN;
}

View File

@ -53,6 +53,13 @@ struct _E_Iconbar_Icon
char *timer;
double start;
} hi;
int wait;
float wait_timeout;
pid_t launch_pid;
int launch_id;
void *launch_id_cb;
};
void e_iconbar_init(void);

View File

@ -189,7 +189,7 @@ e_idle(void *data)
}
}
e_db_flush();
e_db_runtime_flush();
D_RETURN;
UN(data);
@ -957,6 +957,7 @@ e_menu_event_win_hide(void)
/* destroy it */
if (menu_event_win)
{
ecore_ungrab_mouse();
ecore_keyboard_ungrab();
ecore_window_destroy(menu_event_win);
menu_event_win = 0;