X-Git-Url: http://pileus.org/git/?p=wmpus;a=blobdiff_plain;f=wm-wmii.c;h=84250ea85736a24358297b9547b37e3b258392fd;hp=82fc223a4c8e9e6fe5ba7980460f6e3a6ae0ad86;hb=6676472c287a8163d53b2ba14ca8ec39bf7443eb;hpb=e666d231a1035c96788fc148bcc7eda4b8c1b6ec diff --git a/wm-wmii.c b/wm-wmii.c index 82fc223..84250ea 100644 --- a/wm-wmii.c +++ b/wm-wmii.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Andy Spencer + * Copyright (c) 2011-2012, Andy Spencer * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -212,16 +212,6 @@ static void set_focus(win_t *win) return; } - /* - Only grab mouse button on unfocused window, - * this prevents stealing all mouse clicks from client windows, - * - A better way may be to re-send mouse clicks to client windows - * using the return value from wm_handle_key */ - for (int i = EV_MOUSE1; i < EV_MOUSE7; i++) { - if (wm_focus) - sys_watch(wm_focus, i, MOD()); - sys_unwatch(win, i, MOD()); - } - dpy_t *dpy; col_t *col; row_t *row; flt_t *flt; switch (search(wm_tag, win, &dpy, &col, &row, &flt)) { case TILING: @@ -688,6 +678,15 @@ static void wm_update_cols(dpy_t *dpy) *******************************/ void wm_update(void) { + /* Updates window sizes */ + for (list_t *ldpy = wm_tag->dpys; ldpy; ldpy = ldpy->next) + wm_update_cols(ldpy->data); + tag_foreach_flt(wm_tag, ldpy, lflt, win) { + flt_t *flt = lflt->data; + sys_move(win, flt->x, flt->y, flt->w, flt->h); + sys_raise(flt->win); + } + /* Show/hide tags */ tag_foreach_col(wm_tag, dpy, col, row, win) sys_show(win, ROW(row)->state); @@ -701,14 +700,7 @@ void wm_update(void) sys_show(win, ST_HIDE); } - /* Refresh the display */ - for (list_t *ldpy = wm_tag->dpys; ldpy; ldpy = ldpy->next) - wm_update_cols(ldpy->data); - tag_foreach_flt(wm_tag, ldpy, lflt, win) { - flt_t *flt = lflt->data; - sys_move(win, flt->x, flt->y, flt->w, flt->h); - sys_raise(flt->win); - } + /* Set focused window */ if (wm_focus) set_focus(wm_focus); } @@ -723,10 +715,10 @@ int wm_handle_event(win_t *win, event_t ev, mod_t mod, ptr_t ptr) // mod.shift ? 's' : '-', // mod.win ? 'w' : '-'); - /* Mouse movement */ - if (ev == EV_MOUSE1) - raise_float(win); + /* Mouse events */ if (EV_MOUSE0 <= ev && ev <= EV_MOUSE7) { + if (ev == EV_MOUSE1 && !mod.MODKEY && !mod.up) + return raise_float(win), 0; if (ev == EV_MOUSE1 && mod.MODKEY && !mod.up) return set_move(win,ptr,MOVE), 1; if (ev == EV_MOUSE3 && mod.MODKEY && !mod.up) @@ -812,9 +804,6 @@ int wm_handle_event(win_t *win, event_t ev, mod_t mod, ptr_t ptr) if (ev == EV_ENTER && win->state != ST_SHADE) return set_focus(win), 1; - if (EV_MOUSE0 <= ev && ev <= EV_MOUSE7) - return set_focus(win), 0; - /* Reset focus after after focus change, * not sure what is causing the focus change in the first place * but preventing that would be a better solution */ @@ -883,7 +872,7 @@ void wm_insert(win_t *win) /* Arrange */ wm_update(); - set_focus(wm_focus); + set_focus(win); print_txt(); } @@ -913,7 +902,7 @@ void wm_init(win_t *root) wm->tag = tag_new(wm->screens, 1); wm->tags = list_insert(NULL, wm->tag); - event_t ev_e[] = {EV_ENTER, EV_FOCUS}; + event_t ev_e[] = {EV_ENTER, EV_FOCUS, EV_MOUSE1}; event_t ev_s[] = {'h', 'j', 'k', 'l', 'c', 'q', ' ', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'}; event_t ev_m[] = {'h', 'j', 'k', 'l', 'd', 's', 'm', 't', ' ',