diff --git a/cmd/wm/client.c b/cmd/wm/client.c index 5706b08b..cce45135 100644 --- a/cmd/wm/client.c +++ b/cmd/wm/client.c @@ -48,6 +48,24 @@ Client *alloc_client(Window w) return c; } +void focus_client(Client * c, int raise, int up) +{ + Frame *f = 0; + /* focus client */ + if (c) { + f = c->frame; + for (f->sel = 0; f->clients && f->clients[f->sel] != c; f->sel++); + f->files[F_SEL_CLIENT]->content = c->files[C_PREFIX]->content; + if (raise) + XRaiseWindow(dpy, c->win); + XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); + } else + XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); + invoke_core_event(defaults[WM_EVENT_CLIENT_UPDATE]); + if (up && f) + focus_frame(f, raise, up, 0); +} + void set_client_state(Client * c, int state) { long data[2]; diff --git a/cmd/wm/core.c b/cmd/wm/core.c index 333fbeb0..edc768bb 100644 --- a/cmd/wm/core.c +++ b/cmd/wm/core.c @@ -70,35 +70,6 @@ void invoke_core_event(File * f) spawn(dpy, f->content); } -void focus_page(Page * p, int raise, int down) -{ - if (!pages) - return; - if (p != pages[sel]) { - hide_page(pages[sel]); - sel = index_item((void **) pages, p); - show_page(pages[sel]); - defaults[WM_SEL_PAGE]->content = p->files[P_PREFIX]->content; - invoke_core_event(defaults[WM_EVENT_PAGE_UPDATE]); - } - if (down) - focus_area(p->areas[p->sel], raise, 0, down); -} - -unsigned int tab_height(Frame * f) -{ - if (_strtonum(f->files[F_TAB]->content, 0, 1)) - return font->ascent + font->descent + 4; - return 0; -} - -unsigned int border_width(Frame * f) -{ - if (_strtonum(f->files[F_BORDER]->content, 0, 1)) - return BORDER_WIDTH; - return 0; -} - static void scale_rect(XRectangle * from_dim, XRectangle * to_dim, XRectangle * src, XRectangle * tgt) @@ -451,21 +422,6 @@ static void _select_page(void *obj, char *cmd) focus_page(pages[sel], 0, 1); } -void destroy_page(Page * p) -{ - unsigned int i; - for (i = 0; p->areas[i]; i++) - destroy_area(p->areas[i]); - free_page(p); - if (pages) { - show_page(pages[sel]); - defaults[WM_SEL_PAGE]->content = - pages[sel]->files[P_PREFIX]->content; - focus_page(pages[sel], 0, 1); - invoke_core_event(defaults[WM_EVENT_PAGE_UPDATE]); - } -} - static void _destroy_page(void *obj, char *cmd) { if (!pages) diff --git a/cmd/wm/frame.c b/cmd/wm/frame.c index cf11be28..858e2742 100644 --- a/cmd/wm/frame.c +++ b/cmd/wm/frame.c @@ -166,22 +166,18 @@ void destroy_frame(Frame * f) free(f); } -void focus_client(Client * c, int raise, int up) +unsigned int tab_height(Frame * f) { - Frame *f = 0; - /* focus client */ - if (c) { - f = c->frame; - for (f->sel = 0; f->clients && f->clients[f->sel] != c; f->sel++); - f->files[F_SEL_CLIENT]->content = c->files[C_PREFIX]->content; - if (raise) - XRaiseWindow(dpy, c->win); - XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); - } else - XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); - invoke_core_event(defaults[WM_EVENT_CLIENT_UPDATE]); - if (up && f) - focus_frame(f, raise, up, 0); + if (_strtonum(f->files[F_TAB]->content, 0, 1)) + return font->ascent + font->descent + 4; + return 0; +} + +unsigned int border_width(Frame * f) +{ + if (_strtonum(f->files[F_BORDER]->content, 0, 1)) + return BORDER_WIDTH; + return 0; } static void resize_clients(Frame * f, int tabh, int bw) diff --git a/cmd/wm/page.c b/cmd/wm/page.c index 1d9ae83a..015cf1f1 100644 --- a/cmd/wm/page.c +++ b/cmd/wm/page.c @@ -48,6 +48,21 @@ Page *alloc_page(char *autodestroy) return p; } +void destroy_page(Page * p) +{ + unsigned int i; + for (i = 0; p->areas[i]; i++) + destroy_area(p->areas[i]); + free_page(p); + if (pages) { + show_page(pages[sel]); + defaults[WM_SEL_PAGE]->content = + pages[sel]->files[P_PREFIX]->content; + focus_page(pages[sel], 0, 1); + invoke_core_event(defaults[WM_EVENT_PAGE_UPDATE]); + } +} + void free_page(Page * p) { pages = (Page **) detach_item((void **) pages, p, sizeof(Page *)); @@ -64,6 +79,21 @@ void free_page(Page * p) free(p); } +void focus_page(Page * p, int raise, int down) +{ + if (!pages) + return; + if (p != pages[sel]) { + hide_page(pages[sel]); + sel = index_item((void **) pages, p); + show_page(pages[sel]); + defaults[WM_SEL_PAGE]->content = p->files[P_PREFIX]->content; + invoke_core_event(defaults[WM_EVENT_PAGE_UPDATE]); + } + if (down) + focus_area(p->areas[p->sel], raise, 0, down); +} + void draw_page(Page * p) { int i; diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h index 0770ce02..d70bf66f 100644 --- a/cmd/wm/wm.h +++ b/cmd/wm/wm.h @@ -211,6 +211,7 @@ unsigned int valid_mask, num_lock_mask; Area *alloc_area(Page *p, XRectangle * r); void destroy_area(Area * a); void free_area(Area * a); +void focus_area(Area * a, int raise, int up, int down); void attach_frame_to_area(Area * a, Frame * f); void detach_frame_from_area(Frame * f, int ignore_focus_and_destroy); void draw_area(Area * a); @@ -233,10 +234,9 @@ void ungrab_client(Client * c, unsigned long mod, unsigned int button); void hide_client(Client * c); void show_client(Client * c); void reparent_client(Client * c, Window w, int x, int y); +void focus_client(Client * c, int raise, int up); /* core.c */ -unsigned int tab_height(Frame * f); -unsigned int border_width(Frame * f); void invoke_core_event(File * f); void run_action(File * f, void *obj, Action * acttbl); void scan_wins(); @@ -244,9 +244,7 @@ Client *win_to_client(Window w); int win_proto(Window w); int win_state(Window w); void handle_after_write(IXPServer * s, File * f); -void focus_page(Page * p, int raise, int down); void detach(Frame * f, int client_destroyed); -void destroy_page(Page * p); void set_client_state(Client * c, int state); /* frame.c */ @@ -254,15 +252,15 @@ void focus_frame(Frame * f, int raise, int up, int down); Frame *win_to_frame(Window w); Frame *alloc_frame(XRectangle * r, int add_frame_border, int floating); void destroy_frame(Frame * f); -void resize_frame(Frame * f, XRectangle * r, XPoint * pt, - int ignore_layout); +void resize_frame(Frame * f, XRectangle * r, XPoint * pt, int ignore_layout); void draw_frame(Frame * f); void handle_frame_buttonpress(XButtonEvent * e, Frame * f); void attach_client(Client * c); void attach_client_to_frame(Frame * f, Client * c); void detach_client_from_frame(Client * c, int unmapped, int destroyed); void draw_tab(Frame * f, char *text, int x, int y, int w, int h, int sel); -void focus_client(Client * c, int raise, int up); +unsigned int tab_height(Frame * f); +unsigned int border_width(Frame * f); /* event.c */ void init_event_hander(); @@ -279,13 +277,13 @@ void drop_move(Frame * f, XRectangle * new, XPoint * pt); /* page.c */ Page *alloc_page(char *autodestroy); void free_page(Page * p); -void focus_area(Area * a, int raise, int up, int down); +void destroy_page(Page * p); +void focus_page(Page * p, int raise, int down); XRectangle *rectangles(unsigned int *num); void hide_page(Page * p); void show_page(Page * p); void draw_page(Page * p); Layout *get_layout(char *name); -Frame *select_floating(Page * p, Frame * f, char *what); /* layout.c */ void init_layouts();