keybindings work... yayayayayya :)

SVN revision: 4390
This commit is contained in:
Carsten Haitzler 2001-03-18 01:16:47 +00:00
parent 86e401ab9d
commit 7f37672226
11 changed files with 184 additions and 6 deletions

View File

@ -16,6 +16,7 @@ MOD_SHIFT=1
MOD_CTRL=2
MOD_ALT=4
MOD_WIN=8
MOD_CTRL_ALT=$[ $MOD_CTRL + $MOD_ALT ];
FOCUS_POINTER=0
FOCUS_SLOPPY=1
@ -152,6 +153,30 @@ edb_ed $DB add "/actions/"$NUM"/button" int 1
edb_ed $DB add "/actions/"$NUM"/key" str ""
edb_ed $DB add "/actions/"$NUM"/modifiers" int $MOD_NONE
NUM=$[ $NUM + 1 ];
edb_ed $DB add "/actions/"$NUM"/name" str "Key_Binding"
edb_ed $DB add "/actions/"$NUM"/action" str "Restart"
edb_ed $DB add "/actions/"$NUM"/params" str ""
edb_ed $DB add "/actions/"$NUM"/event" int $ACT_KEY_DOWN
edb_ed $DB add "/actions/"$NUM"/button" int 0
edb_ed $DB add "/actions/"$NUM"/key" str "End"
edb_ed $DB add "/actions/"$NUM"/modifiers" int $MOD_CTRL_ALT
NUM=$[ $NUM + 1 ];
edb_ed $DB add "/actions/"$NUM"/name" str "Key_Binding"
edb_ed $DB add "/actions/"$NUM"/action" str "Exit"
edb_ed $DB add "/actions/"$NUM"/params" str ""
edb_ed $DB add "/actions/"$NUM"/event" int $ACT_KEY_DOWN
edb_ed $DB add "/actions/"$NUM"/button" int 0
edb_ed $DB add "/actions/"$NUM"/key" str "Delete"
edb_ed $DB add "/actions/"$NUM"/modifiers" int $MOD_CTRL_ALT
NUM=$[ $NUM + 1 ];
edb_ed $DB add "/actions/"$NUM"/name" str "Key_Binding"
edb_ed $DB add "/actions/"$NUM"/action" str "Window_Max_Size"
edb_ed $DB add "/actions/"$NUM"/params" str ""
edb_ed $DB add "/actions/"$NUM"/event" int $ACT_KEY_DOWN
edb_ed $DB add "/actions/"$NUM"/button" int 0
edb_ed $DB add "/actions/"$NUM"/key" str "m"
edb_ed $DB add "/actions/"$NUM"/modifiers" int $MOD_CTRL_ALT
NUM=$[ $NUM + 1 ];
edb_ed $DB add "/actions/count" int $NUM
# basic settings

View File

@ -18,6 +18,7 @@ fs.c \
icccm.c \
icons.c \
ipc.c \
keys.c \
main.c \
menu.c \
menudb.c \
@ -28,5 +29,5 @@ util.c \
view.c \
e.h
enlightenment_LDADD = @evas_libs@ @edb_libs@ @ebits_libs@ @ecore_libs@ @efsd_libs@ -lm $(INTLLIBS) $(LDADD_FLAGS)
enlightenment_LDADD = @evas_libs@ @edb_libs@ @ebits_libs@ @ecore_libs@ @efsd_libs@ -lm $(INTLLIBS)

View File

@ -124,6 +124,16 @@ _e_action_find(char *action, int act, int button, char *key, Ev_Key_Modifiers mo
a->object = NULL;
a->started = 0;
actions = evas_list_append(actions, a);
/* it's a key? lets grab it! */
if ((a->key) && (strlen(a->key) > 0))
{
printf("grab it! (%s %i)\n", a->key, a->modifiers);
if (a->modifiers == -1)
e_keys_grab(a->key, EV_KEY_MODIFIER_NONE, 1);
else
e_keys_grab(a->key, (Ev_Key_Modifiers)a->modifiers, 0);
a->grabbed = 1;
}
}
error:
e_db_close(db);
@ -185,6 +195,15 @@ _e_action_find(char *action, int act, int button, char *key, Ev_Key_Modifiers mo
static void
_e_action_free(E_Action *a)
{
/* it's a key? lets ungrab it! */
if ((a->key) && (strlen(a->key) > 0) && (a->grabbed))
{
printf("ungrab it! (%s %i)\n", a->key, a->modifiers);
if (a->modifiers == -1)
e_keys_ungrab(a->key, EV_KEY_MODIFIER_NONE, 1);
else
e_keys_ungrab(a->key, (Ev_Key_Modifiers)a->modifiers, 0);
}
IF_FREE(a->name);
IF_FREE(a->action);
IF_FREE(a->params);
@ -466,6 +485,8 @@ e_act_move_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
b->mode.move = 1;
b->current.requested.dx = 0;
b->current.requested.dy = 0;
@ -486,6 +507,8 @@ e_act_move_stop (void *o, E_Action *a, void *data, int x, int y, int rx, int ry
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
b->current.requested.x = b->current.x;
b->current.requested.y = b->current.y;
b->changed = 1;
@ -510,6 +533,8 @@ e_act_move_go (void *o, E_Action *a, void *data, int x, int y, int rx, int ry
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
b->current.requested.x += dx;
b->current.requested.y += dy;
if (dx != 0) b->current.requested.dx = dx;
@ -532,6 +557,8 @@ e_act_resize_start (void *o, E_Action *a, void *data, int x, int y, int rx, int
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
if (b->current.shaded != 0) return;
/* 0 | 1 */
/* --+-- */
@ -575,6 +602,8 @@ e_act_resize_stop (void *o, E_Action *a, void *data, int x, int y, int rx, int
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
if (b->current.shaded != 0) return;
b->current.requested.x = b->current.x;
b->current.requested.y = b->current.y;
@ -598,6 +627,8 @@ e_act_resize_go (void *o, E_Action *a, void *data, int x, int y, int rx, int
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
if (b->current.shaded != 0) return;
if (b->mode.resize == 0)
{
@ -641,6 +672,8 @@ e_act_resize_h_start (void *o, E_Action *a, void *data, int x, int y, int rx, in
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
if (b->current.shaded != 0) return;
/* 4 | 5 */
if (x > (b->current.w / 2))
@ -667,6 +700,8 @@ e_act_resize_h_stop (void *o, E_Action *a, void *data, int x, int y, int rx, in
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
if (b->current.shaded != 0) return;
b->current.requested.x = b->current.x;
b->current.requested.y = b->current.y;
@ -690,6 +725,8 @@ e_act_resize_h_go (void *o, E_Action *a, void *data, int x, int y, int rx, in
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
if (b->current.shaded != 0) return;
if (b->mode.resize == 4)
{
@ -719,6 +756,8 @@ e_act_resize_v_start (void *o, E_Action *a, void *data, int x, int y, int rx, in
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
if (b->current.shaded != 0) return;
/* 6 */
/* - */
@ -747,6 +786,8 @@ e_act_resize_v_stop (void *o, E_Action *a, void *data, int x, int y, int rx, in
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
if (b->current.shaded != 0) return;
b->current.requested.x = b->current.x;
b->current.requested.y = b->current.y;
@ -770,6 +811,8 @@ e_act_resize_v_go (void *o, E_Action *a, void *data, int x, int y, int rx, in
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
if (b->current.shaded != 0) return;
if (b->mode.resize == 6)
{
@ -799,6 +842,8 @@ e_act_close_start (void *o, E_Action *a, void *data, int x, int y, int rx, int r
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
if (b->win.client) e_icccm_delete(b->win.client);
return;
UN(a);
@ -816,6 +861,8 @@ e_act_kill_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
if (b->win.client) e_window_kill_client(b->win.client);
return;
UN(a);
@ -837,6 +884,8 @@ e_act_cb_shade(int val, void *data)
int pix_per_sec = 3200;
b = data;
if (!b) b = e_border_current_focused();
if (!b) return;
if (val == 0)
{
OBJ_REF(b);
@ -875,6 +924,8 @@ e_act_cb_unshade(int val, void *data)
int pix_per_sec = 3200;
b = data;
if (!b) b = e_border_current_focused();
if (!b) return;
if (val == 0)
{
OBJ_REF(b);
@ -909,6 +960,8 @@ e_act_shade_start (void *o, E_Action *a, void *data, int x, int y, int rx, int r
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
if (b->current.shaded == 0) e_act_cb_shade(0, b);
else e_act_cb_unshade(0, b);
return;
@ -927,6 +980,8 @@ e_act_raise_start (void *o, E_Action *a, void *data, int x, int y, int rx, int r
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
e_border_raise(b);
return;
UN(a);
@ -944,6 +999,8 @@ e_act_lower_start (void *o, E_Action *a, void *data, int x, int y, int rx, int r
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
e_border_lower(b);
return;
UN(a);
@ -961,6 +1018,8 @@ e_act_raise_lower_start (void *o, E_Action *a, void *data, int x, int y, int rx,
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
return;
UN(a);
UN(data);
@ -993,6 +1052,8 @@ e_act_menu_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
return;
UN(a);
UN(data);
@ -1043,6 +1104,8 @@ e_act_stick_start (void *o, E_Action *a, void *data, int x, int y, int rx, int r
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
if (b->client.sticky) b->client.sticky = 0;
else b->client.sticky = 1;
b->changed = 1;
@ -1078,6 +1141,8 @@ e_act_iconify_start (void *o, E_Action *a, void *data, int x, int y, int rx, int
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
return;
UN(a);
UN(data);
@ -1094,6 +1159,9 @@ e_act_max_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry)
E_Border *b;
b = o;
printf("e_act_max_start\n");
if (!b) b = e_border_current_focused();
if (!b) return;
if (b->current.shaded > 0) return;
if ((b->mode.move) || (b->mode.resize)) return;
b->mode.move = 0;
@ -1146,6 +1214,8 @@ e_act_snap_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
return;
UN(a);
UN(data);
@ -1162,6 +1232,8 @@ e_act_zoom_start (void *o, E_Action *a, void *data, int x, int y, int rx, int ry
E_Border *b;
b = o;
if (!b) b = e_border_current_focused();
if (!b) return;
return;
UN(a);
UN(data);

View File

@ -385,6 +385,7 @@ e_focus_in(Eevent * ev)
if (b)
{
b->current.selected = 1;
if (e->key_grab) b->current.select_lost_from_grab = 0;
b->changed = 1;
}
}
@ -413,6 +414,7 @@ e_focus_out(Eevent * ev)
E_CONFIG_INT_GET(cfg_focus_mode, focus_mode);
b->current.selected = 0;
if (e->key_grab) b->current.select_lost_from_grab = 1;
/* settings - click to focus would affect grabs */
if (!b->current.selected)
{
@ -2105,3 +2107,25 @@ e_border_adopt_children(Window win)
free(wins);
}
}
E_Border *
e_border_current_focused(void)
{
Evas_List l;
for (l = borders; l; l = l->next)
{
E_Border *b;
b = l->data;
if (b->current.selected) return b;
}
for (l = borders; l; l = l->next)
{
E_Border *b;
b = l->data;
if (b->current.select_lost_from_grab) return b;
}
return NULL;
}

View File

@ -191,6 +191,7 @@ struct _E_Border
int x, y, w, h;
int visible;
int selected;
int select_lost_from_grab;
int shaded;
int has_shape;
int shape_changes;
@ -267,6 +268,7 @@ struct _E_Action
E_Action_Proto *action_proto;
void *object;
int started;
int grabbed;
};
struct _E_Action_Proto
@ -713,6 +715,7 @@ void e_border_raise_above(E_Border *b, E_Border *above);
void e_border_lower_below(E_Border *b, E_Border *below);
void e_border_init(void);
void e_border_adopt_children(Window win);
E_Border *e_border_current_focused(void);
void e_icccm_move_resize(Window win, int x, int y, int w, int h);
void e_icccm_delete(Window win);

View File

@ -99,7 +99,6 @@ e_icon_place_grid(E_Icon *icon)
x += (icon->view->options.arrange.grid.w - icon->current.w) / 2;
y += (icon->view->options.arrange.grid.h - icon->current.h);
e_icon_set_xy(icon, x, y);
printf("GRID PLACE at %i %i\n", x, y);
icon->view->options.arrange.grid.next_pos++;
}
else /* v */
@ -113,7 +112,6 @@ e_icon_pre_show(E_Icon *icon)
int x, y;
if (icon->info.ready) return;
printf("*********!!!!!!!!!!!!!!!********* update from e_icon_pre_show()\n");
e_icon_update(icon);
icon->info.ready = 1;
if (icon->info.coord.have)
@ -291,7 +289,6 @@ e_icon_update(E_Icon *icon)
int obj_new = 0;
if (!icon->changed) return;
printf("icon (%s).. update\n", icon->file);
if (icon->current.state.clicked)
{
if (icon->info.icon.clicked)
@ -417,5 +414,4 @@ e_icon_update(E_Icon *icon)
icon->previous = icon->current;
icon->previous.icon = strdup(icon->current.icon);
icon->changed = 0;
printf("... done\n");
}

56
src/keys.c Normal file
View File

@ -0,0 +1,56 @@
#include "e.h"
static void e_key_down(Eevent * ev);
static void e_key_up(Eevent * ev);
static void
e_key_down(Eevent * ev)
{
Ev_Key_Down *e;
e = ev->event;
if (e->win == e_get_key_grab_win())
{
e_action_stop("Key_Binding", ACT_KEY_DOWN, 0, e->key, e->mods,
NULL, NULL, 0, 0, 0, 0);
e_action_start("Key_Binding", ACT_KEY_DOWN, 0, e->key, e->mods,
NULL, NULL, 0, 0, 0, 0);
}
}
static void
e_key_up(Eevent * ev)
{
Ev_Key_Up *e;
e = ev->event;
if (e->win == e_get_key_grab_win())
{
e_action_stop("Key_Binding", ACT_KEY_UP, 0, e->key, e->mods,
NULL, NULL, 0, 0, 0, 0);
e_action_start("Key_Binding", ACT_KEY_UP, 0, e->key, e->mods,
NULL, NULL, 0, 0, 0, 0);
}
}
void
e_keys_init(void)
{
/* load up our actions .... once to get some grabbed keys */
e_action_start("", ACT_KEY_DOWN, 0, NULL, EV_KEY_MODIFIER_NONE,
NULL, NULL, 0, 0, 0, 0);
e_event_filter_handler_add(EV_KEY_DOWN, e_key_down);
e_event_filter_handler_add(EV_KEY_UP, e_key_up);
}
void
e_keys_grab(char *key, Ev_Key_Modifiers mods, int anymod)
{
e_key_grab(key, mods, anymod, 0);
}
void
e_keys_ungrab(char *key, Ev_Key_Modifiers mods, int anymod)
{
e_key_ungrab(key, mods, anymod);
}

View File

@ -56,6 +56,7 @@ main(int argc, char **argv)
e_view_init();
e_entry_init();
e_ipc_init();
e_keys_init();
setup();