add nscreen var to store screen count
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
72338dc74f
commit
956ce4ab8e
|
@ -206,7 +206,7 @@ main(int argc, char *argv[])
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
Display * dpy;
|
Display * dpy;
|
||||||
int shape_event, randr_event_base;
|
int shape_event, randr_event_base;
|
||||||
int screen;
|
int screen, screen_count;
|
||||||
event_handler **handler;
|
event_handler **handler;
|
||||||
struct sockaddr_un *addr;
|
struct sockaddr_un *addr;
|
||||||
|
|
||||||
|
@ -255,7 +255,9 @@ main(int argc, char *argv[])
|
||||||
ewmh_init_atoms();
|
ewmh_init_atoms();
|
||||||
|
|
||||||
/* init screens struct */
|
/* init screens struct */
|
||||||
globalconf.screens = p_new(VirtScreen, get_screen_count());
|
screen_count = get_screen_count();
|
||||||
|
globalconf.screens = p_new(VirtScreen, screen_count);
|
||||||
|
globalconf.nscreens = screen_count;
|
||||||
focus_add_client(NULL);
|
focus_add_client(NULL);
|
||||||
|
|
||||||
/* parse config */
|
/* parse config */
|
||||||
|
|
4
config.c
4
config.c
|
@ -769,7 +769,7 @@ config_parse(const char *confpatharg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the right screen section */
|
/* get the right screen section */
|
||||||
for(screen = 0; screen < get_screen_count(); screen++)
|
for(screen = 0; screen < globalconf.nscreens; screen++)
|
||||||
config_parse_screen(cfg, screen);
|
config_parse_screen(cfg, screen);
|
||||||
|
|
||||||
/* get general sections */
|
/* get general sections */
|
||||||
|
@ -792,7 +792,7 @@ config_parse(const char *confpatharg)
|
||||||
rule->isfloating = rules_get_float_from_str(cfg_getstr(cfgsectmp, "float"));
|
rule->isfloating = rules_get_float_from_str(cfg_getstr(cfgsectmp, "float"));
|
||||||
rule->screen = cfg_getint(cfgsectmp, "screen");
|
rule->screen = cfg_getint(cfgsectmp, "screen");
|
||||||
rule->not_master = cfg_getbool(cfgsectmp, "not_master");
|
rule->not_master = cfg_getbool(cfgsectmp, "not_master");
|
||||||
if(rule->screen >= get_screen_count())
|
if(rule->screen >= globalconf.nscreens)
|
||||||
rule->screen = 0;
|
rule->screen = 0;
|
||||||
|
|
||||||
if(i < cfg_size(cfg_rules, "rule") - 1)
|
if(i < cfg_size(cfg_rules, "rule") - 1)
|
||||||
|
|
2
config.h
2
config.h
|
@ -285,6 +285,8 @@ struct AwesomeConf
|
||||||
Display *display;
|
Display *display;
|
||||||
/** Logical screens */
|
/** Logical screens */
|
||||||
VirtScreen *screens;
|
VirtScreen *screens;
|
||||||
|
/** Number of logical screens */
|
||||||
|
int nscreens;
|
||||||
/** Rules list */
|
/** Rules list */
|
||||||
Rule *rules;
|
Rule *rules;
|
||||||
/** Keys bindings list */
|
/** Keys bindings list */
|
||||||
|
|
4
event.c
4
event.c
|
@ -69,7 +69,7 @@ handle_event_buttonpress(XEvent *e)
|
||||||
Statusbar *statusbar;
|
Statusbar *statusbar;
|
||||||
XButtonPressedEvent *ev = &e->xbutton;
|
XButtonPressedEvent *ev = &e->xbutton;
|
||||||
|
|
||||||
for(screen = 0; screen < get_screen_count(); screen++)
|
for(screen = 0; screen < globalconf.nscreens; screen++)
|
||||||
for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next)
|
for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next)
|
||||||
if(statusbar->window == ev->window)
|
if(statusbar->window == ev->window)
|
||||||
switch(statusbar->position)
|
switch(statusbar->position)
|
||||||
|
@ -265,7 +265,7 @@ handle_event_expose(XEvent *e)
|
||||||
Statusbar *statusbar;
|
Statusbar *statusbar;
|
||||||
|
|
||||||
if(!ev->count)
|
if(!ev->count)
|
||||||
for(screen = 0; screen < get_screen_count(); screen++)
|
for(screen = 0; screen < globalconf.nscreens; screen++)
|
||||||
for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next)
|
for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next)
|
||||||
if(statusbar->window == ev->window)
|
if(statusbar->window == ev->window)
|
||||||
{
|
{
|
||||||
|
|
14
screen.c
14
screen.c
|
@ -142,7 +142,7 @@ get_screen_bycoord(int x, int y)
|
||||||
if(!XineramaIsActive(globalconf.display))
|
if(!XineramaIsActive(globalconf.display))
|
||||||
return DefaultScreen(globalconf.display);
|
return DefaultScreen(globalconf.display);
|
||||||
|
|
||||||
for(i = 0; i < get_screen_count(); i++)
|
for(i = 0; i < globalconf.nscreens; i++)
|
||||||
{
|
{
|
||||||
area = get_screen_area(i, NULL, NULL);
|
area = get_screen_area(i, NULL, NULL);
|
||||||
if((x < 0 || (x >= area.x && x < area.x + area.width))
|
if((x < 0 || (x >= area.x && x < area.x + area.width))
|
||||||
|
@ -163,7 +163,7 @@ get_screen_count(void)
|
||||||
if(XineramaIsActive(globalconf.display))
|
if(XineramaIsActive(globalconf.display))
|
||||||
XineramaQueryScreens(globalconf.display, &screen_number);
|
XineramaQueryScreens(globalconf.display, &screen_number);
|
||||||
else
|
else
|
||||||
return ScreenCount(globalconf.display);
|
screen_number = ScreenCount(globalconf.display);
|
||||||
|
|
||||||
return screen_number;
|
return screen_number;
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ move_mouse_pointer_to_screen(int screen)
|
||||||
void
|
void
|
||||||
uicb_screen_focus(int screen, char *arg)
|
uicb_screen_focus(int screen, char *arg)
|
||||||
{
|
{
|
||||||
int new_screen, numscreens = get_screen_count();
|
int new_screen;
|
||||||
|
|
||||||
if(arg)
|
if(arg)
|
||||||
new_screen = compute_new_value_from_arg(arg, screen);
|
new_screen = compute_new_value_from_arg(arg, screen);
|
||||||
|
@ -309,8 +309,8 @@ uicb_screen_focus(int screen, char *arg)
|
||||||
new_screen = screen + 1;
|
new_screen = screen + 1;
|
||||||
|
|
||||||
if (new_screen < 0)
|
if (new_screen < 0)
|
||||||
new_screen = numscreens - 1;
|
new_screen = globalconf.nscreens - 1;
|
||||||
if (new_screen > (numscreens - 1))
|
if (new_screen > (globalconf.nscreens - 1))
|
||||||
new_screen = 0;
|
new_screen = 0;
|
||||||
|
|
||||||
focus(focus_get_current_client(new_screen), True, new_screen);
|
focus(focus_get_current_client(new_screen), True, new_screen);
|
||||||
|
@ -337,10 +337,10 @@ uicb_client_movetoscreen(int screen __attribute__ ((unused)), char *arg)
|
||||||
else
|
else
|
||||||
new_screen = sel->screen + 1;
|
new_screen = sel->screen + 1;
|
||||||
|
|
||||||
if(new_screen >= get_screen_count())
|
if(new_screen >= globalconf.nscreens)
|
||||||
new_screen = 0;
|
new_screen = 0;
|
||||||
else if(new_screen < 0)
|
else if(new_screen < 0)
|
||||||
new_screen = get_screen_count() - 1;
|
new_screen = globalconf.nscreens - 1;
|
||||||
|
|
||||||
prev_screen = sel->screen;
|
prev_screen = sel->screen;
|
||||||
move_client_to_screen(sel, new_screen, True);
|
move_client_to_screen(sel, new_screen, True);
|
||||||
|
|
|
@ -246,7 +246,7 @@ statusbar_refresh()
|
||||||
Statusbar *statusbar;
|
Statusbar *statusbar;
|
||||||
Widget *widget;
|
Widget *widget;
|
||||||
|
|
||||||
for(screen = 0; screen < get_screen_count(); screen++)
|
for(screen = 0; screen < globalconf.nscreens; screen++)
|
||||||
for(statusbar = globalconf.screens[screen].statusbar;
|
for(statusbar = globalconf.screens[screen].statusbar;
|
||||||
statusbar;
|
statusbar;
|
||||||
statusbar = statusbar->next)
|
statusbar = statusbar->next)
|
||||||
|
|
2
uicb.c
2
uicb.c
|
@ -101,7 +101,7 @@ run_uicb(char *cmd)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
screen = atoi(cmd);
|
screen = atoi(cmd);
|
||||||
if(screen >= get_screen_count() || screen < 0)
|
if(screen >= globalconf.nscreens || screen < 0)
|
||||||
{
|
{
|
||||||
warn("Invalid screen specified: %i\n", screen);
|
warn("Invalid screen specified: %i\n", screen);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue