Improve the call signature of get_current_tag and get_current_layout.

This commit is contained in:
Aldo Cortesi 2007-12-14 12:27:10 +11:00 committed by Julien Danjou
parent 8264f15fc6
commit 2b5ba1f16f
9 changed files with 48 additions and 52 deletions

View File

@ -177,7 +177,7 @@ void
focus(Client *c, Bool selscreen, awesome_config *awesomeconf, int screen)
{
int i;
Tag *tag = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags);
Tag *tag = get_current_tag(awesomeconf->screens[screen]);
/* if c is NULL or invisible, take next client in the stack */
if((!c && selscreen) || (c && !isvisible(c, screen, awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)))
@ -436,7 +436,7 @@ client_resize(Client *c, int x, int y, int w, int h, awesome_config *awesomeconf
c->h = wc.height = h;
if(!volatile_coords
&& (c->isfloating
|| get_current_layout(awesomeconf->screens[c->screen].tags, awesomeconf->screens[c->screen].ntags)->arrange == layout_floating))
|| get_current_layout(awesomeconf->screens[c->screen])->arrange == layout_floating))
{
c->rx = c->x;
c->ry = c->y;
@ -496,7 +496,7 @@ client_unmanage(Client *c, long state, awesome_config *awesomeconf)
XGrabServer(c->display);
XConfigureWindow(c->display, c->win, CWBorderWidth, &wc); /* restore border */
client_detach(&awesomeconf->clients, c);
if(get_current_tag(awesomeconf->screens[c->screen].tags, awesomeconf->screens[c->screen].ntags)->client_sel == c)
if(get_current_tag(awesomeconf->screens[c->screen])->client_sel == c)
focus(NULL, True, awesomeconf, c->screen);
for(tag = 0; tag < awesomeconf->screens[c->screen].ntags; tag++)
if(awesomeconf->screens[c->screen].tags[tag].client_sel == c)
@ -623,7 +623,7 @@ uicb_client_settrans(awesome_config *awesomeconf,
unsigned long n, left;
unsigned int current_opacity_raw = 0;
int set_prop = 0;
Client *sel = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
if(!sel)
return;
@ -680,7 +680,7 @@ uicb_client_swapnext(awesome_config *awesomeconf,
int screen,
const char *arg __attribute__ ((unused)))
{
Client *next, *sel = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *next, *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
if(!sel)
return;
@ -700,7 +700,7 @@ uicb_client_swapprev(awesome_config *awesomeconf,
int screen,
const char *arg __attribute__ ((unused)))
{
Client *prev, *sel = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *prev, *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
if(!sel)
return;
@ -725,9 +725,9 @@ uicb_client_moveresize(awesome_config *awesomeconf,
int mx, my, dx, dy, nmx, nmy;
unsigned int dui;
Window dummy;
Client *sel = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
if(get_current_layout(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->arrange != layout_floating)
if(get_current_layout(awesomeconf->screens[screen])->arrange != layout_floating)
if(!sel || !sel->isfloating || sel->isfixed || !arg)
return;
if(sscanf(arg, "%s %s %s %s", x, y, w, h) != 4)
@ -763,7 +763,7 @@ uicb_client_kill(awesome_config *awesomeconf,
const char *arg __attribute__ ((unused)))
{
XEvent ev;
Client *sel = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
if(!sel)
return;

View File

@ -141,8 +141,7 @@ handle_event_configurerequest(XEvent * e, awesome_config *awesomeconf)
if(ev->value_mask & CWBorderWidth)
c->border = ev->border_width;
if(c->isfixed || c->isfloating
|| get_current_layout(awesomeconf->screens[c->screen].tags,
awesomeconf->screens[c->screen].ntags)->arrange == layout_floating)
|| get_current_layout(awesomeconf->screens[c->screen])->arrange == layout_floating)
{
if(ev->value_mask & CWX)
c->rx = c->x = ev->x;
@ -237,8 +236,7 @@ handle_event_enternotify(XEvent * e, awesome_config *awesomeconf)
{
focus(c, ev->same_screen, awesomeconf, c->screen);
if (c->isfloating
|| get_current_layout(awesomeconf->screens[c->screen].tags,
awesomeconf->screens[c->screen].ntags)->arrange == layout_floating)
|| get_current_layout(awesomeconf->screens[c->screen])->arrange == layout_floating)
window_grabbuttons(c->display, c->phys_screen, c->win,
True, False, awesomeconf->buttons.root,
awesomeconf->buttons.client, awesomeconf->numlockmask);
@ -366,7 +364,7 @@ handle_event_propertynotify(XEvent * e, awesome_config *awesomeconf)
if(ev->atom == XA_WM_NAME || ev->atom == XInternAtom(c->display, "_NET_WM_NAME", False))
{
updatetitle(c);
if(c == get_current_tag(awesomeconf->screens[c->screen].tags, awesomeconf->screens[c->screen].ntags)->client_sel)
if(c == get_current_tag(awesomeconf->screens[c->screen])->client_sel)
drawstatusbar(awesomeconf, c->screen);
}
}

View File

@ -30,18 +30,17 @@
#include "layouts/floating.h"
/** Find the index of the first currently selected tag
* \param tags the array of tags to search
* \param ntags number of elements in above array
* \param screen the screen to search
* \return tag
*/
Tag *
get_current_tag(Tag *tags, int ntags)
get_current_tag(VirtScreen screen)
{
int i;
for(i = 0; i < ntags; i++)
if(tags[i].selected == True)
return &tags[i];
for(i = 0; i < screen.ntags; i++)
if(screen.tags[i].selected == True)
return &screen.tags[i];
return NULL;
}
@ -54,7 +53,7 @@ void
arrange(awesome_config *awesomeconf, int screen)
{
Client *c;
Tag *curtag = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags);
Tag *curtag = get_current_tag(awesomeconf->screens[screen]);
for(c = awesomeconf->clients; c; c = c->next)
{
@ -71,11 +70,11 @@ arrange(awesome_config *awesomeconf, int screen)
}
Layout *
get_current_layout(Tag *tags, int ntags)
get_current_layout(VirtScreen screen)
{
Tag *curtag;
if ((curtag = get_current_tag(tags, ntags)))
if ((curtag = get_current_tag(screen)))
return curtag->layout;
return NULL;
@ -86,7 +85,7 @@ uicb_client_focusnext(awesome_config * awesomeconf,
int screen,
const char *arg __attribute__ ((unused)))
{
Client *c, *sel = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *c, *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
if(!sel)
return;
@ -105,7 +104,7 @@ uicb_client_focusprev(awesome_config *awesomeconf,
int screen,
const char *arg __attribute__ ((unused)))
{
Client *c, *sel = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *c, *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
if(!sel)
return;
@ -144,7 +143,7 @@ loadawesomeprops(awesome_config * awesomeconf, int screen)
void
restack(awesome_config *awesomeconf, int screen)
{
Client *c, *sel = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *c, *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
XEvent ev;
XWindowChanges wc;
@ -156,9 +155,9 @@ restack(awesome_config *awesomeconf, int screen)
else
{
if(sel->isfloating ||
get_current_layout(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->arrange == layout_floating)
get_current_layout(awesomeconf->screens[screen])->arrange == layout_floating)
XRaiseWindow(sel->display, sel->win);
if(!(get_current_layout(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->arrange == layout_floating))
if(!(get_current_layout(awesomeconf->screens[screen])->arrange == layout_floating))
{
wc.stack_mode = Below;
wc.sibling = awesomeconf->screens[screen].statusbar.window;
@ -209,7 +208,7 @@ uicb_tag_setlayout(awesome_config * awesomeconf,
{
/* compute current index */
for(i = 0; i < awesomeconf->screens[screen].nlayouts &&
&awesomeconf->screens[screen].layouts[i] != get_current_layout(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags); i++);
&awesomeconf->screens[screen].layouts[i] != get_current_layout(awesomeconf->screens[screen]); i++);
i = compute_new_value_from_arg(arg, (double) i);
if(i >= awesomeconf->screens[screen].nlayouts)
i = 0;
@ -223,7 +222,7 @@ uicb_tag_setlayout(awesome_config * awesomeconf,
if (awesomeconf->screens[screen].tags[j].selected)
awesomeconf->screens[screen].tags[j].layout = &awesomeconf->screens[screen].layouts[i];
if(get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel)
if(get_current_tag(awesomeconf->screens[screen])->client_sel)
arrange(awesomeconf, screen);
else
drawstatusbar(awesomeconf, screen);
@ -234,7 +233,7 @@ uicb_tag_setlayout(awesome_config * awesomeconf,
static void
maximize(int x, int y, int w, int h, awesome_config *awesomeconf, int screen)
{
Client *sel = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
if(!sel)
return;
@ -272,7 +271,7 @@ uicb_client_toggleverticalmax(awesome_config *awesomeconf,
int screen,
const char *arg __attribute__ ((unused)))
{
Client *sel = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
ScreenInfo *si = get_screen_info(awesomeconf->display, screen, &awesomeconf->screens[screen].statusbar, &awesomeconf->screens[screen].padding);
if(sel)
@ -290,7 +289,7 @@ uicb_client_togglehorizontalmax(awesome_config *awesomeconf,
int screen,
const char *arg __attribute__ ((unused)))
{
Client *sel = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
ScreenInfo *si = get_screen_info(awesomeconf->display, screen, &awesomeconf->screens[screen].statusbar, &awesomeconf->screens[screen].padding);
if(sel)
@ -307,7 +306,7 @@ uicb_client_zoom(awesome_config *awesomeconf,
int screen,
const char *arg __attribute__ ((unused)))
{
Client *sel = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
if(awesomeconf->clients == sel)
for(sel = sel->next; sel && !isvisible(sel, screen, awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags); sel = sel->next);

View File

@ -27,8 +27,8 @@
#define AWESOMEPROPS_ATOM(disp) XInternAtom(disp, "_AWESOME_PROPERTIES", False)
void arrange(awesome_config *, int);
Layout * get_current_layout(Tag *, int);
Tag * get_current_tag(Tag *, int);
Layout * get_current_layout(VirtScreen);
Tag * get_current_tag(VirtScreen);
void restack(awesome_config *, int);
void loadawesomeprops(awesome_config *, int);
void saveawesomeprops(awesome_config *, int);

View File

@ -33,7 +33,7 @@ uicb_tag_setnmaster(awesome_config *awesomeconf,
int screen,
const char * arg)
{
Tag *curtag = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags);
Tag *curtag = get_current_tag(awesomeconf->screens[screen]);
Layout *curlay = curtag->layout;
if(!arg || (curlay->arrange != layout_tile && curlay->arrange != layout_tileleft))
@ -50,7 +50,7 @@ uicb_tag_setncol(awesome_config *awesomeconf,
int screen,
const char * arg)
{
Tag *curtag = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags);
Tag *curtag = get_current_tag(awesomeconf->screens[screen]);
Layout *curlay = curtag->layout;
if(!arg || (curlay->arrange != layout_tile && curlay->arrange != layout_tileleft))
@ -68,7 +68,7 @@ uicb_tag_setmwfact(awesome_config * awesomeconf,
const char *arg)
{
char *newarg;
Tag *curtag = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags);
Tag *curtag = get_current_tag(awesomeconf->screens[screen]);
Layout *curlay = curtag->layout;
if(!arg || (curlay->arrange != layout_tile && curlay->arrange != layout_tileleft))
@ -105,7 +105,7 @@ _tile(awesome_config *awesomeconf, int screen, const Bool right)
int real_ncol = 1, win_by_col = 1, current_col = 0;
ScreenInfo *screens_info = NULL;
Client *c;
Tag *curtag = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags);
Tag *curtag = get_current_tag(awesomeconf->screens[screen]);
screens_info = get_screen_info(awesomeconf->display, screen, &awesomeconf->screens[screen].statusbar, &awesomeconf->screens[screen].padding);

View File

@ -36,12 +36,12 @@ uicb_client_movemouse(awesome_config *awesomeconf, int screen, const char *arg _
Window dummy;
XEvent ev;
ScreenInfo *si;
Client *c = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *c = get_current_tag(awesomeconf->screens[screen])->client_sel;
if(!c)
return;
if((get_current_layout(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->arrange != layout_floating)
if((get_current_layout(awesomeconf->screens[screen])->arrange != layout_floating)
&& !c->isfloating)
uicb_client_togglefloating(awesomeconf, screen, "DUMMY");
else
@ -96,12 +96,12 @@ uicb_client_resizemouse(awesome_config *awesomeconf, int screen, const char *arg
{
int ocx, ocy, nw, nh;
XEvent ev;
Client *c = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *c = get_current_tag(awesomeconf->screens[screen])->client_sel;
if(!c)
return;
if((get_current_layout(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->arrange != layout_floating)
if((get_current_layout(awesomeconf->screens[screen])->arrange != layout_floating)
&& !c->isfloating)
uicb_client_togglefloating(awesomeconf, screen, "DUMMY");
else

View File

@ -262,8 +262,7 @@ uicb_screen_focus(awesome_config *awesomeconf, int screen, const char *arg)
if (new_screen > (numscreens - 1))
new_screen = 0;
focus(get_current_tag(awesomeconf->screens[new_screen].tags,
awesomeconf->screens[new_screen].ntags)->client_sel,
focus(get_current_tag(awesomeconf->screens[new_screen])->client_sel,
True, awesomeconf, new_screen);
move_mouse_pointer_to_screen(awesomeconf->display, new_screen);
@ -280,7 +279,7 @@ uicb_client_movetoscreen(awesome_config * awesomeconf,
const char *arg)
{
int new_screen, prev_screen;
Client *sel = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
if(!sel || !XineramaIsActive(awesomeconf->display))
return;

View File

@ -50,7 +50,7 @@ void
drawstatusbar(awesome_config *awesomeconf, int screen)
{
int z, i, x = 0, y = 0, w;
Client *sel = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
Drawable drawable;
int phys_screen = get_phys_screen(awesomeconf->display, screen);
@ -119,7 +119,7 @@ drawstatusbar(awesome_config *awesomeconf, int screen)
awesomeconf->screens[screen].statusbar.width,
awesomeconf->screens[screen].statusbar.height,
awesomeconf->screens[screen].font,
get_current_layout(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->symbol,
get_current_layout(awesomeconf->screens[screen])->symbol,
awesomeconf->screens[screen].colors_normal);
z = x + awesomeconf->screens[screen].statusbar.txtlayoutwidth;
w = textwidth(awesomeconf->display, awesomeconf->screens[screen].font, awesomeconf->screens[screen].statustext);

6
tag.c
View File

@ -69,7 +69,7 @@ uicb_client_tag(awesome_config *awesomeconf,
const char *arg)
{
int i, tag_id = -1;
Client *sel = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
if(!sel)
return;
@ -100,7 +100,7 @@ uicb_client_togglefloating(awesome_config * awesomeconf,
int screen,
const char *arg __attribute__ ((unused)))
{
Client *sel = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
if(!sel)
return;
@ -125,7 +125,7 @@ uicb_client_toggletag(awesome_config *awesomeconf,
int screen,
const char *arg)
{
Client *sel = get_current_tag(awesomeconf->screens[screen].tags, awesomeconf->screens[screen].ntags)->client_sel;
Client *sel = get_current_tag(awesomeconf->screens[screen])->client_sel;
int i, j;
if(!sel)