stop using applyrules() and do some stuff ourselves

This commit is contained in:
Julien Danjou 2007-11-13 22:41:56 +01:00
parent 0a5d929801
commit 0acaae11d9
1 changed files with 62 additions and 29 deletions

View File

@ -259,12 +259,13 @@ loadprops(Client * c, int ntags)
void void
client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf) client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf)
{ {
int i, newscreen = -1; int i;
Client *c, *t = NULL; Client *c, *t = NULL;
Window trans; Window trans;
Status rettrans; Status rettrans;
XWindowChanges wc; XWindowChanges wc;
ScreenInfo *screen_info = get_screen_info(awesomeconf->display, awesomeconf->screen, NULL); ScreenInfo *screen_info = get_screen_info(awesomeconf->display, awesomeconf->screen, NULL);
awesome_config *current_acf = awesomeconf;
c = p_new(Client, 1); c = p_new(Client, 1);
@ -277,18 +278,63 @@ client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf)
c->display = awesomeconf->display; c->display = awesomeconf->display;
c->phys_screen = awesomeconf->phys_screen; c->phys_screen = awesomeconf->phys_screen;
c->tags = p_new(Bool, awesomeconf->ntags);
/* update window title */
updatetitle(c);
c->screen = get_screen_bycoord(c->display, c->x, c->y);
printf("win coords %d %d so screen %d\n", c->x, c->y, c->screen);
/* loadprops or apply rules if no props */
if(!loadprops(c, awesomeconf->ntags))
{
Rule *r;
Bool matched, has_rule = False;
printf("loadprops failed for %s, watching rules\n", c->name);
for(r = awesomeconf->rules; r; r = r->next)
if(client_match_rule(c, r))
{
has_rule = True;
c->isfloating = r->isfloating;
if(r->screen != RULE_NOSCREEN && r->screen != c->screen)
{
printf("Changing screen, was %d now %d\n", awesomeconf->screen, r->screen);
current_acf = &awesomeconf[r->screen - awesomeconf->screen];
move_client_to_screen(c, current_acf, True);
}
for(i = 0; i < current_acf->ntags; i++)
if(is_tag_match_rules(&current_acf->tags[i], r))
{
printf("tagged with: %s\n", current_acf->tags[i].name);
matched = True;
c->tags[i] = True;
}
else
c->tags[i] = False;
if(!matched)
for(i = 0; i < current_acf->ntags; i++)
c->tags[i] = current_acf->tags[i].selected;
break;
}
if(!has_rule)
move_client_to_screen(c, current_acf, True);
}
/* if window request fullscreen mode */ /* if window request fullscreen mode */
if(c->w == screen_info[awesomeconf->screen].width && c->h == screen_info[awesomeconf->screen].height) if(c->w == screen_info[current_acf->screen].width && c->h == screen_info[current_acf->screen].height)
{ {
c->x = screen_info[awesomeconf->screen].x_org; c->x = screen_info[current_acf->screen].x_org;
c->y = screen_info[awesomeconf->screen].y_org; c->y = screen_info[current_acf->screen].y_org;
c->border = wa->border_width; c->border = wa->border_width;
} }
else else
{ {
ScreenInfo *display_info = get_display_info(c->display, c->phys_screen, &awesomeconf->statusbar); ScreenInfo *display_info = get_display_info(c->display, c->phys_screen, &current_acf->statusbar);
if(c->x + c->w + 2 * c->border > display_info->x_org + display_info->width) if(c->x + c->w + 2 * c->border > display_info->x_org + display_info->width)
c->x = c->rx = display_info->x_org + display_info->width - c->w - 2 * c->border; c->x = c->rx = display_info->x_org + display_info->width - c->w - 2 * c->border;
@ -299,7 +345,7 @@ client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf)
if(c->y < display_info->y_org) if(c->y < display_info->y_org)
c->y = c->ry = display_info->y_org; c->y = c->ry = display_info->y_org;
c->border = awesomeconf->borderpx; c->border = current_acf->borderpx;
p_delete(&display_info); p_delete(&display_info);
} }
@ -308,7 +354,7 @@ client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf)
/* set borders */ /* set borders */
wc.border_width = c->border; wc.border_width = c->border;
XConfigureWindow(c->display, w, CWBorderWidth, &wc); XConfigureWindow(c->display, w, CWBorderWidth, &wc);
XSetWindowBorder(c->display, w, awesomeconf->colors_normal[ColBorder].pixel); XSetWindowBorder(c->display, w, current_acf->colors_normal[ColBorder].pixel);
/* propagates border_width, if size doesn't change */ /* propagates border_width, if size doesn't change */
window_configure(c->display, c->win, c->x, c->y, c->w, c->h, c->border); window_configure(c->display, c->win, c->x, c->y, c->w, c->h, c->border);
@ -319,7 +365,7 @@ client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf)
XSelectInput(c->display, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask); XSelectInput(c->display, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
/* handle xshape */ /* handle xshape */
if(awesomeconf->have_shape) if(current_acf->have_shape)
{ {
XShapeSelectInput(c->display, w, ShapeNotifyMask); XShapeSelectInput(c->display, w, ShapeNotifyMask);
window_setshape(c->display, c->phys_screen, c->win); window_setshape(c->display, c->phys_screen, c->win);
@ -327,45 +373,32 @@ client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf)
/* grab buttons */ /* grab buttons */
window_grabbuttons(c->display, c->phys_screen, c->win, window_grabbuttons(c->display, c->phys_screen, c->win,
False, True, awesomeconf->buttons.root, False, True, current_acf->buttons.root,
awesomeconf->modkey, awesomeconf->numlockmask); current_acf->modkey, current_acf->numlockmask);
/* update window title */
updatetitle(c);
/* move client to screen: this will set screen and create tags array */
c->screen = get_screen_bycoord(c->display, c->x, c->y);
move_client_to_screen(c, awesomeconf, True);
/* check for transient and set tags like its parent */ /* check for transient and set tags like its parent */
if((rettrans = XGetTransientForHint(c->display, w, &trans) == Success) if((rettrans = XGetTransientForHint(c->display, w, &trans) == Success)
&& (t = get_client_bywin(*awesomeconf->clients, trans))) && (t = get_client_bywin(*current_acf->clients, trans)))
for(i = 0; i < awesomeconf->ntags; i++) for(i = 0; i < current_acf->ntags; i++)
c->tags[i] = t->tags[i]; c->tags[i] = t->tags[i];
/* loadprops or apply rules if no props */
if(!loadprops(c, awesomeconf->ntags))
newscreen = applyrules(c, awesomeconf);
/* should be floating if transsient or fixed) */ /* should be floating if transsient or fixed) */
if(!c->isfloating) if(!c->isfloating)
c->isfloating = (rettrans == Success) || c->isfixed; c->isfloating = (rettrans == Success) || c->isfixed;
/* save new props */ /* save new props */
saveprops(c, awesomeconf->ntags); saveprops(c, current_acf->ntags);
/* attach to the stack */ /* attach to the stack */
client_attach(awesomeconf->clients, c); client_attach(current_acf->clients, c);
/* some windows require this */ /* some windows require this */
XMoveResizeWindow(c->display, c->win, c->x, c->y, c->w, c->h); XMoveResizeWindow(c->display, c->win, c->x, c->y, c->w, c->h);
focus(c, True, awesomeconf); focus(c, True, current_acf);
/* rearrange to display new window */ /* rearrange to display new window */
arrange(awesomeconf); arrange(current_acf);
if(newscreen != RULE_NOSCREEN)
arrange(&awesomeconf[newscreen - awesomeconf->screen]);
} }
void void