Make awesome-{menu,message} Xinerama aware
This commit is contained in:
parent
fa47024714
commit
d10b98c101
|
@ -155,9 +155,10 @@ awesome_message_SOURCES = \
|
|||
common/util.h common/util.c \
|
||||
common/version.h common/version.c \
|
||||
common/configopts.h common/configopts.c \
|
||||
common/xscreen.h common/xscreen.c \
|
||||
awesome-message.c
|
||||
|
||||
awesome_message_LDADD = $(XFT_LIBS) $(X_LIBS) $(CAIRO_LIBS) $(CONFUSE_LIBS)
|
||||
awesome_message_LDADD = $(XFT_LIBS) $(X_LIBS) $(CAIRO_LIBS) $(CONFUSE_LIBS) $(XINERAMA_LIBS)
|
||||
|
||||
bin_PROGRAMS += awesome-menu
|
||||
awesome_menu_SOURCES = \
|
||||
|
|
|
@ -115,11 +115,13 @@ exit_help(int exit_code)
|
|||
}
|
||||
|
||||
static int
|
||||
config_parse(const char *confpatharg, const char *menu_title, Area *geometry)
|
||||
config_parse(int screen, const char *confpatharg,
|
||||
const char *menu_title, Area *geometry)
|
||||
{
|
||||
int ret, i;
|
||||
char *confpath;
|
||||
cfg_t *cfg, *cfg_menu = NULL, *cfg_screen = NULL, *cfg_styles, *cfg_menu_styles = NULL;
|
||||
cfg_t *cfg, *cfg_menu = NULL, *cfg_screen = NULL,
|
||||
*cfg_styles, *cfg_menu_styles = NULL;
|
||||
|
||||
if(!confpatharg)
|
||||
confpath = config_file();
|
||||
|
@ -142,9 +144,11 @@ config_parse(const char *confpatharg, const char *menu_title, Area *geometry)
|
|||
return ret;
|
||||
|
||||
if(menu_title && !(cfg_menu = cfg_gettsec(cfg, "menu", menu_title)))
|
||||
warn("no definition for menu %s in configuration file: using default\n", menu_title);
|
||||
warn("no definition for menu %s in configuration file: using default\n",
|
||||
menu_title);
|
||||
|
||||
/* get global screen section */
|
||||
if(!(cfg_screen = cfg_getnsec(cfg, "screen", screen)))
|
||||
cfg_screen = cfg_getsec(cfg, "screen");
|
||||
|
||||
if(cfg_menu)
|
||||
|
@ -581,7 +585,7 @@ main(int argc, char **argv)
|
|||
{
|
||||
Display *disp;
|
||||
XEvent ev;
|
||||
int opt, ret, x, y, i;
|
||||
int opt, ret, x, y, i, screen = 0;
|
||||
char *configfile = NULL, *cmd;
|
||||
ssize_t len;
|
||||
const char *shell = getenv("SHELL");
|
||||
|
@ -623,35 +627,37 @@ main(int argc, char **argv)
|
|||
if(argc - optind >= 1)
|
||||
globalconf.prompt = a_strdup(argv[optind]);
|
||||
|
||||
if((ret = config_parse(configfile, globalconf.prompt, &geometry)))
|
||||
return ret;
|
||||
|
||||
/* Get the numlock mask */
|
||||
globalconf.numlockmask = get_numlockmask(disp);
|
||||
|
||||
si = screensinfo_new(disp);
|
||||
if(si->xinerama_is_active)
|
||||
{
|
||||
if(XQueryPointer(disp, RootWindow(disp, DefaultScreen(disp)),
|
||||
&dummy, &dummy, &x, &y, &i, &i, &ui))
|
||||
{
|
||||
screen = screen_get_bycoord(si, 0, x, y);
|
||||
|
||||
geometry.x = si->geometry[screen].x;
|
||||
geometry.y = si->geometry[screen].y;
|
||||
geometry.width = si->geometry[screen].width;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
screen = DefaultScreen(disp);
|
||||
if(!geometry.width)
|
||||
geometry.width = DisplayWidth(disp, DefaultScreen(disp));
|
||||
}
|
||||
|
||||
if((ret = config_parse(screen, configfile, globalconf.prompt, &geometry)))
|
||||
return ret;
|
||||
|
||||
/* Init the geometry */
|
||||
if(!geometry.height)
|
||||
geometry.height = 1.5 * MAX(globalconf.styles.normal.font->height,
|
||||
globalconf.styles.focus.font->height);
|
||||
|
||||
si = screensinfo_new(disp);
|
||||
if(si->xinerama_is_active)
|
||||
{
|
||||
XQueryPointer(disp, RootWindow(disp, DefaultScreen(disp)),
|
||||
&dummy, &dummy, &x, &y, &i, &i, &ui);
|
||||
|
||||
i = screen_get_bycoord(si, 0, x, y);
|
||||
|
||||
if(!geometry.x)
|
||||
geometry.x = si->geometry[i].x;
|
||||
if(!geometry.y)
|
||||
geometry.y = si->geometry[i].y;
|
||||
if(!geometry.width)
|
||||
geometry.width = si->geometry[i].width;
|
||||
}
|
||||
else if(!geometry.width)
|
||||
geometry.width = DisplayWidth(disp, DefaultScreen(disp));
|
||||
|
||||
screensinfo_delete(&si);
|
||||
|
||||
/* Create the window */
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "common/util.h"
|
||||
#include "common/version.h"
|
||||
#include "common/configopts.h"
|
||||
#include "common/xscreen.h"
|
||||
|
||||
#define PROGNAME "awesome-message"
|
||||
|
||||
|
@ -63,7 +64,7 @@ exit_help(int exit_code)
|
|||
}
|
||||
|
||||
static int
|
||||
config_parse(const char *confpatharg)
|
||||
config_parse(int screen, const char *confpatharg)
|
||||
{
|
||||
int ret;
|
||||
char *confpath;
|
||||
|
@ -90,10 +91,8 @@ config_parse(const char *confpatharg)
|
|||
return ret;
|
||||
|
||||
/* get global screen section */
|
||||
/* XXX need to get the screen according to coords */
|
||||
cfg_screen = cfg_getsec(cfg, "screen");
|
||||
|
||||
if(!cfg_screen)
|
||||
if(!(cfg_screen = cfg_getnsec(cfg, "screen", screen)))
|
||||
if(!(cfg_screen = cfg_getsec(cfg, "screen")))
|
||||
eprint("parsing configuration file failed, no screen section found\n");
|
||||
|
||||
/* style */
|
||||
|
@ -124,9 +123,11 @@ main(int argc, char **argv)
|
|||
XEvent ev;
|
||||
Area geometry = { 0, 0, 200, 50, NULL, NULL },
|
||||
icon_geometry = { -1, -1, -1, -1, NULL, NULL };
|
||||
int opt, ret;
|
||||
int delay = 0;
|
||||
int opt, i, x, y, ret, screen = 0, delay = 0;
|
||||
unsigned int ui;
|
||||
char *configfile = NULL;
|
||||
ScreensInfo *si;
|
||||
Window dummy;
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"help", 0, NULL, 'h'},
|
||||
|
@ -166,7 +167,17 @@ main(int argc, char **argv)
|
|||
if(argc - optind < 1)
|
||||
exit_help(EXIT_FAILURE);
|
||||
|
||||
if((ret = config_parse(configfile)))
|
||||
si = screensinfo_new(disp);
|
||||
if(si->xinerama_is_active)
|
||||
{
|
||||
if(XQueryPointer(disp, RootWindow(disp, DefaultScreen(disp)),
|
||||
&dummy, &dummy, &x, &y, &i, &i, &ui))
|
||||
screen = screen_get_bycoord(si, 0, x, y);
|
||||
}
|
||||
else
|
||||
screen = DefaultScreen(disp);
|
||||
|
||||
if((ret = config_parse(screen, configfile)))
|
||||
return ret;
|
||||
|
||||
geometry.width = draw_textwidth(disp, globalconf.style.font, argv[optind]);
|
||||
|
|
Loading…
Reference in New Issue