From 2bb9a1b0aba89f3339016ab986f1109dd3530db7 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Fri, 16 Nov 2001 05:39:34 +0000 Subject: [PATCH] hhm - smart placement got borked... fixed click to focus works pretty much swell now.. except for that mass of comments i put in.... err... icccm focus modes handled 100% properly err.. yeah. that. SVN revision: 5697 --- src/border.c | 50 +++++++++++++++++++++++++------------------------- src/border.h | 1 + src/debug.h | 6 +++++- src/desktops.c | 5 +---- src/focus.c | 2 +- src/icccm.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- src/icccm.h | 1 + src/place.c | 30 ++++++++++++++++++------------ 8 files changed, 99 insertions(+), 46 deletions(-) diff --git a/src/border.c b/src/border.c index 8199f6742..83df1aaa8 100644 --- a/src/border.c +++ b/src/border.c @@ -322,11 +322,7 @@ e_unmap(Ecore_Event * ev) border_mouse_x, border_mouse_y); if (e_object_get_usecount(E_OBJECT(b)) == 1) - { - ecore_window_reparent(e->win, 0, 0, 0); - e_icccm_release(e->win); - } - + e_border_release(b); e_object_unref(E_OBJECT(b)); } } @@ -360,11 +356,7 @@ e_destroy(Ecore_Event * ev) border_mouse_x, border_mouse_y); if (e_object_get_usecount(E_OBJECT(b)) == 1) - { - ecore_window_reparent(e->win, 0, 0, 0); - e_icccm_release(e->win); - } - + e_border_release(b); e_object_unref(E_OBJECT(b)); } } @@ -465,8 +457,7 @@ e_focus_in(Ecore_Event * ev) g = b->click_grab; if (g) { - /* find a grab that triggered this */ - ecore_button_ungrab(b->win.main, g->button, g->mods, g->any_mod); + ecore_button_ungrab(b->win.container, g->button, g->mods, g->any_mod); free(g); b->click_grab = NULL; } @@ -518,19 +509,18 @@ e_focus_out(Ecore_Event * ev) if (e->key_grab) b->current.select_lost_from_grab = 1; /* settings - click to focus would affect grabs */ if ((!b->client.internal) && - (focus_mode == 2) && - (e_focus_can_focus(b))) + (focus_mode == 2)) { E_Grab *g; g = NEW(E_Grab, 1); ZERO(g, E_Grab, 1); - g->button = 0; + g->button = 1; g->mods = ECORE_EVENT_KEY_MODIFIER_NONE; g->any_mod = 0; - g->remove_after = 1; - ecore_button_grab(b->win.main, 0, XEV_BUTTON_PRESS, ECORE_EVENT_KEY_MODIFIER_NONE, 0); - ecore_window_button_grab_auto_replay_set(b->win.main, e_border_replay_query); + g->remove_after = 0; + ecore_button_grab(b->win.container, 1, XEV_BUTTON_PRESS, ECORE_EVENT_KEY_MODIFIER_NONE, 0); + ecore_window_button_grab_auto_replay_set(b->win.container, e_border_replay_query); b->click_grab = g; } b->changed = 1; @@ -1428,6 +1418,17 @@ e_border_reshape(E_Border *b) D_RETURN; } +void +e_border_release(E_Border *b) +{ + int pl, pr, pt, pb; + + pl = pr = pt = pb = 0; + if (b->bits.t) ebits_get_insets(b->bits.t, &pl, &pr, &pt, &pb); + ecore_window_reparent(b->win.client, 0, b->current.x + pl, b->current.y + pt); + e_icccm_release(b->win.client); +} + E_Border * e_border_adopt(Window win, int use_client_pos) { @@ -1775,8 +1776,8 @@ e_border_remove_click_grab(E_Border *b) E_Grab *g; g = b->click_grab; - ecore_button_ungrab(b->win.main, g->button, g->mods, g->any_mod); - ecore_window_button_grab_auto_replay_set(b->win.main, NULL); + ecore_button_ungrab(b->win.container, g->button, g->mods, g->any_mod); + ecore_window_button_grab_auto_replay_set(b->win.container, NULL); b->click_grab = NULL; FREE(g); } @@ -1800,19 +1801,18 @@ e_border_attach_mouse_grabs(E_Border *b) grabs_db = e_config_get("grabs"); /* settings - click to focus would affect grabs */ if ((!b->current.selected) && - (e_focus_can_focus(b)) && (focus_mode == 2)) { E_Grab *g; g = NEW(E_Grab, 1); ZERO(g, E_Grab, 1); - g->button = 0; + g->button = 1; g->mods = ECORE_EVENT_KEY_MODIFIER_NONE; g->any_mod = 0; - g->remove_after = 1; - ecore_button_grab(b->win.main, 0, XEV_BUTTON_PRESS, ECORE_EVENT_KEY_MODIFIER_NONE, 0); - ecore_window_button_grab_auto_replay_set(b->win.main, e_border_replay_query); + g->remove_after = 0; + ecore_button_grab(b->win.container, 0, XEV_BUTTON_PRESS, ECORE_EVENT_KEY_MODIFIER_NONE, 0); + ecore_window_button_grab_auto_replay_set(b->win.container, e_border_replay_query); b->click_grab = g; } diff --git a/src/border.h b/src/border.h index 7f5859477..182f6d84f 100644 --- a/src/border.h +++ b/src/border.h @@ -149,6 +149,7 @@ E_Border *e_border_new(void); void e_border_update_borders(void); void e_border_apply_border(E_Border *b); void e_border_reshape(E_Border *b); +void e_border_release(E_Border *b); E_Border *e_border_adopt(Window win, int use_client_pos); void e_border_adopt_children(Window win); void e_border_remove_mouse_grabs(E_Border *b); diff --git a/src/debug.h b/src/debug.h index 455986070..5f0bbf76e 100644 --- a/src/debug.h +++ b/src/debug.h @@ -28,11 +28,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include +/* +#undef DEBUG +*/ + #ifdef DEBUG #define D(fmt, args...) printf(fmt, ## args); #else -#define D(msg) +#define D(msg, args...) #endif #ifdef DEBUG_NEST diff --git a/src/desktops.c b/src/desktops.c index cc623d3b9..b89893931 100644 --- a/src/desktops.c +++ b/src/desktops.c @@ -171,10 +171,7 @@ e_desktops_cleanup(E_Desktop *desk) e_action_stop_by_object(E_OBJECT(b), NULL, 0, 0, 0, 0); if (e_object_get_usecount(E_OBJECT(b)) == 1) - { - ecore_window_reparent(b->win.client, 0, 0, 0); - e_icccm_release(b->win.client); - } + e_border_release(b); e_object_unref(E_OBJECT(b)); } diff --git a/src/focus.c b/src/focus.c index d77c499d5..064c8621a 100644 --- a/src/focus.c +++ b/src/focus.c @@ -10,7 +10,7 @@ e_focus_set_focus(E_Border *b) { D_ENTER; - if (e_focus_can_focus(b)) ecore_focus_to_window(b->win.client); + e_icccm_send_focus_to(b->win.client, e_focus_can_focus(b)); D_RETURN; } diff --git a/src/icccm.c b/src/icccm.c index efadaf1d7..f852b21d2 100644 --- a/src/icccm.c +++ b/src/icccm.c @@ -56,6 +56,46 @@ e_icccm_move_resize(Window win, int x, int y, int w, int h) D_RETURN; } +void +e_icccm_send_focus_to(Window win, int takes_focus) +{ + static Atom a_wm_take_focus = 0; + static Atom a_wm_protocols = 0; + int msg_focus = 0; + int *props; + int size; + + D_ENTER; + + ECORE_ATOM(a_wm_take_focus, "WM_TAKE_FOCUS"); + ECORE_ATOM(a_wm_protocols, "WM_PROTOCOLS"); + + props = ecore_window_property_get(win, a_wm_protocols, XA_ATOM, &size); + if (props) + { + int i, num; + + num = size / sizeof(int); + for (i = 0; i < num; i++) + { + if (props[i] == (int)a_wm_take_focus) msg_focus = 1; + } + FREE(props); + } + if (takes_focus) + ecore_focus_to_window(win); + if (msg_focus) + { + unsigned int data[5]; + + data[0] = a_wm_take_focus; + data[1] = CurrentTime; + ecore_window_send_client_message(win, a_wm_protocols, 32, data); + } + + D_RETURN; +} + void e_icccm_delete(Window win) { @@ -393,9 +433,11 @@ e_icccm_get_hints(Window win, E_Border *b) { D_ENTER; - ecore_window_get_hints(win, &(b->client.takes_focus), - &(b->client.initial_state), NULL, NULL, NULL, - &(b->client.group)); + ecore_window_get_hints(win, + &(b->client.takes_focus), + &(b->client.initial_state), + NULL, NULL, NULL, + &(b->client.group)); D_RETURN; } @@ -443,6 +485,8 @@ e_icccm_get_state(Window win, E_Border *b) D_RETURN; + UN(win); + UN(b); } void diff --git a/src/icccm.h b/src/icccm.h index 26c2a975d..b88a537fc 100644 --- a/src/icccm.h +++ b/src/icccm.h @@ -4,6 +4,7 @@ #include "e.h" void e_icccm_move_resize(Window win, int x, int y, int w, int h); +void e_icccm_send_focus_to(Window win, int takes_focus); void e_icccm_delete(Window win); void e_icccm_state_mapped(Window win); void e_icccm_state_iconified(Window win); diff --git a/src/place.c b/src/place.c index 8426f3746..599619030 100644 --- a/src/place.c +++ b/src/place.c @@ -503,20 +503,26 @@ e_place_border(E_Border *b, E_Desktop *desk, int *x, int *y, E_Placement_Mode mo if (b->client.no_place) D_RETURN_(1); - + switch (mode) { - case E_PLACE_MANUAL: - result = e_place_manual (b, desk, x, y); - case E_PLACE_SMART: - result = e_place_smart (b, desk, x, y); - case E_PLACE_MIDDLE: - result = e_place_middle (b, desk, x, y); - case E_PLACE_CASCADE: - result = e_place_cascade(b, desk, x, y); - case E_PLACE_RANDOM: - result = e_place_random (b, desk, x, y); - default: + case E_PLACE_MANUAL: + result = e_place_manual (b, desk, x, y); + break; + case E_PLACE_SMART: + result = e_place_smart (b, desk, x, y); + break; + case E_PLACE_MIDDLE: + result = e_place_middle (b, desk, x, y); + break; + case E_PLACE_CASCADE: + result = e_place_cascade(b, desk, x, y); + break; + case E_PLACE_RANDOM: + result = e_place_random (b, desk, x, y); + break; + default: + break; } D_RETURN_(result);