restructuring/reordering of various functions

This commit is contained in:
garbeam 2005-12-05 02:36:39 +02:00
parent 7a8fe69742
commit 6637f664be
5 changed files with 66 additions and 68 deletions

View File

@ -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];

View File

@ -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)

View File

@ -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)

View File

@ -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;

View File

@ -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();