add Xinerama support for tile layout
This commit is contained in:
parent
2535e92ff6
commit
c50480205c
|
@ -15,7 +15,7 @@ X11LIB = /usr/lib/X11
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
INCS = -I. -I/usr/include -I${X11INC} `pkg-config --cflags libconfig`
|
INCS = -I. -I/usr/include -I${X11INC} `pkg-config --cflags libconfig`
|
||||||
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 `pkg-config --libs libconfig` -lXext -lXrandr
|
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 `pkg-config --libs libconfig` -lXext -lXrandr -lXinerama
|
||||||
|
|
||||||
# flags
|
# flags
|
||||||
CFLAGS = -fgnu89-inline -std=gnu99 -ggdb3 -pipe -Wall -Wextra -W -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wsign-compare -Wunused -Wuninitialized -Winit-self -Wpointer-arith -Wredundant-decls -Wno-format-zero-length -Wmissing-prototypes -Wmissing-format-attribute -Wmissing-noreturn -O2 ${INCS} -DVERSION=\"${VERSION}\"
|
CFLAGS = -fgnu89-inline -std=gnu99 -ggdb3 -pipe -Wall -Wextra -W -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wsign-compare -Wunused -Wuninitialized -Winit-self -Wpointer-arith -Wredundant-decls -Wno-format-zero-length -Wmissing-prototypes -Wmissing-format-attribute -Wmissing-noreturn -O2 ${INCS} -DVERSION=\"${VERSION}\"
|
||||||
|
|
115
layouts/tile.c
115
layouts/tile.c
|
@ -21,6 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <X11/extensions/Xinerama.h>
|
||||||
|
|
||||||
#include "awesome.h"
|
#include "awesome.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
|
@ -95,65 +96,107 @@ uicb_setmwfact(Display *disp,
|
||||||
static void
|
static void
|
||||||
_tile(Display *disp, awesome_config *awesomeconf, const Bool right)
|
_tile(Display *disp, awesome_config *awesomeconf, const Bool right)
|
||||||
{
|
{
|
||||||
int wah = get_windows_area_height(disp, awesomeconf->statusbar);
|
/* windows area geometry */
|
||||||
int waw = get_windows_area_width(disp, awesomeconf->statusbar);
|
int wah = 0, waw = 0, wax = 0, way = 0;
|
||||||
int wax = get_windows_area_x(awesomeconf->statusbar);
|
/* new coordinates */
|
||||||
int way = get_windows_area_y(awesomeconf->statusbar);
|
unsigned int nx, ny, nw, nh;
|
||||||
unsigned int nx, ny, nw, nh, mw;
|
/* master size */
|
||||||
int n, th, i, mh;
|
unsigned int mw = 0, mh = 0;
|
||||||
|
int n, i, li, last_i = 0, nmaster_screen = 0, otherwin_screen = 0;
|
||||||
|
int screen_numbers = 1, use_screen = -1;
|
||||||
|
XineramaScreenInfo *screens_info = NULL;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
|
if(XineramaIsActive(disp))
|
||||||
|
{
|
||||||
|
screens_info = XineramaQueryScreens(disp, &screen_numbers);
|
||||||
|
for(i = 0; i < screen_numbers; i++)
|
||||||
|
{
|
||||||
|
if(awesomeconf->statusbar.position == BarTop
|
||||||
|
|| awesomeconf->statusbar.position == BarBot)
|
||||||
|
screens_info[i].height -= awesomeconf->statusbar.height;
|
||||||
|
if(awesomeconf->statusbar.position == BarTop)
|
||||||
|
screens_info[i].y_org += awesomeconf->statusbar.height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* emulate Xinerama info */
|
||||||
|
screens_info = p_new(XineramaScreenInfo, 1);
|
||||||
|
screens_info->width = get_windows_area_width(disp, awesomeconf->statusbar);
|
||||||
|
screens_info->height = get_windows_area_height(disp, awesomeconf->statusbar);
|
||||||
|
screens_info->x_org = get_windows_area_x(awesomeconf->statusbar);
|
||||||
|
screens_info->y_org = get_windows_area_y(awesomeconf->statusbar);
|
||||||
|
}
|
||||||
|
|
||||||
for(n = 0, c = clients; c; c = c->next)
|
for(n = 0, c = clients; c; c = c->next)
|
||||||
if(IS_TILED(c, awesomeconf->selected_tags, awesomeconf->ntags))
|
if(IS_TILED(c, awesomeconf->selected_tags, awesomeconf->ntags))
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
/* window geoms */
|
|
||||||
mh = (n <= nmaster) ? wah / (n > 0 ? n : 1) : wah / nmaster;
|
|
||||||
mw = (n <= nmaster) ? waw : mwfact * waw;
|
|
||||||
th = (n > nmaster) ? wah / (n - nmaster) : 0;
|
|
||||||
if(n > nmaster && th < awesomeconf->statusbar.height)
|
|
||||||
th = wah;
|
|
||||||
|
|
||||||
nx = wax;
|
|
||||||
ny = way;
|
|
||||||
for(i = 0, c = clients; c; c = c->next)
|
for(i = 0, c = clients; c; c = c->next)
|
||||||
{
|
{
|
||||||
if(!IS_TILED(c, awesomeconf->selected_tags, awesomeconf->ntags))
|
if(!IS_TILED(c, awesomeconf->selected_tags, awesomeconf->ntags))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if(use_screen == -1 || (screen_numbers > 1 && i && ((i - last_i) >= nmaster_screen + otherwin_screen || n == screen_numbers)))
|
||||||
|
{
|
||||||
|
use_screen++;
|
||||||
|
last_i = i;
|
||||||
|
|
||||||
|
wah = screens_info[use_screen].height;
|
||||||
|
waw = screens_info[use_screen].width;
|
||||||
|
wax = screens_info[use_screen].x_org;
|
||||||
|
way = screens_info[use_screen].y_org;
|
||||||
|
|
||||||
|
if(n >= nmaster * screen_numbers)
|
||||||
|
{
|
||||||
|
nmaster_screen = nmaster;
|
||||||
|
otherwin_screen = (n - (nmaster * screen_numbers)) / screen_numbers;
|
||||||
|
if(use_screen == 0)
|
||||||
|
otherwin_screen += (n - (nmaster * screen_numbers)) % screen_numbers;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nmaster_screen = n / screen_numbers;
|
||||||
|
/* first screen takes more master */
|
||||||
|
if(use_screen == 0)
|
||||||
|
nmaster_screen += n % screen_numbers;
|
||||||
|
otherwin_screen = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
mh = nmaster_screen ? wah / nmaster_screen : waw;
|
||||||
|
mw = otherwin_screen ? waw * mwfact : waw;
|
||||||
|
}
|
||||||
|
|
||||||
c->ismax = False;
|
c->ismax = False;
|
||||||
if(i < nmaster)
|
li = last_i ? i - last_i : i;
|
||||||
|
if(li < nmaster)
|
||||||
{ /* master */
|
{ /* master */
|
||||||
ny = way + i * mh;
|
ny = way + li * mh;
|
||||||
if(!right && i == 0)
|
if(right)
|
||||||
nx += (waw - mw);
|
nx = wax;
|
||||||
|
else
|
||||||
|
nx = wax + (waw - mw);
|
||||||
nw = mw - 2 * c->border;
|
nw = mw - 2 * c->border;
|
||||||
nh = mh;
|
nh = mh - 2 * c->border;
|
||||||
if(i + 1 == (n < nmaster ? n : nmaster)) /* remainder */
|
|
||||||
nh = wah - mh * i;
|
|
||||||
nh -= 2 * c->border;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* tile window */
|
{ /* tile window */
|
||||||
if(i == nmaster)
|
nh = wah / otherwin_screen - 2 * c->border;
|
||||||
{
|
|
||||||
ny = way;
|
|
||||||
if(right)
|
|
||||||
nx += mw;
|
|
||||||
else
|
|
||||||
nx = 0;
|
|
||||||
}
|
|
||||||
nw = waw - mw - 2 * c->border;
|
nw = waw - mw - 2 * c->border;
|
||||||
if(i + 1 == n) /* remainder */
|
if(li == nmaster)
|
||||||
nh = (way + wah) - ny - 2 * c->border;
|
ny = way;
|
||||||
else
|
else
|
||||||
nh = th - 2 * c->border;
|
ny = way + (wah / otherwin_screen) * (li - nmaster_screen);
|
||||||
|
if(right)
|
||||||
|
nx = mw + wax;
|
||||||
|
else
|
||||||
|
nx = wax;
|
||||||
}
|
}
|
||||||
resize(c, nx, ny, nw, nh, awesomeconf->resize_hints);
|
resize(c, nx, ny, nw, nh, awesomeconf->resize_hints);
|
||||||
if(n > nmaster && th != wah)
|
|
||||||
ny += nh + 2 * c->border;
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
XFree(screens_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue