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