add multimonitor patch (https://patch-diff.githubusercontent.com/raw/dylanaraps/sowm/pull/70.patch) with support for the borders patch
This commit is contained in:
parent
e57182299a
commit
c6cd35fc56
2
Makefile
2
Makefile
|
@ -10,7 +10,7 @@ config.h:
|
|||
cp config.def.h config.h
|
||||
|
||||
sowm: sowm.c sowm.h config.h Makefile
|
||||
$(CC) -O3 $(CFLAGS) -o $@ $< -lX11 $(LDFLAGS)
|
||||
$(CC) -O3 $(CFLAGS) -o $@ $< -lX11 -lXinerama $(LDFLAGS)
|
||||
|
||||
install: all
|
||||
install -Dm755 sowm $(DESTDIR)$(BINDIR)/sowm
|
||||
|
|
33
sowm.c
33
sowm.c
|
@ -4,6 +4,7 @@
|
|||
#include <X11/XF86keysym.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include <X11/extensions/Xinerama.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
@ -12,7 +13,7 @@
|
|||
#include "sowm.h"
|
||||
|
||||
static client *list = {0}, *ws_list[NUM_WS] = {0}, *cur;
|
||||
static int ws = 1, sw, sh, wx, wy, numlock = 0;
|
||||
static int ws = 1, sw, sh, wx, wy, numlock = 0, monitors;
|
||||
static unsigned int ww, wh;
|
||||
|
||||
static int s;
|
||||
|
@ -100,6 +101,7 @@ void notify_motion(XEvent *e) {
|
|||
wy + (mouse.button == 1 ? yd : 0),
|
||||
MAX(1, ww + (mouse.button == 3 ? xd : 0)),
|
||||
MAX(1, wh + (mouse.button == 3 ? yd : 0)));
|
||||
win_size(cur->w, &cur->wx, &cur->wx, &cur->ww, &cur->wh);
|
||||
}
|
||||
|
||||
void key_press(XEvent *e) {
|
||||
|
@ -164,20 +166,47 @@ void win_kill(const Arg arg) {
|
|||
if (cur) XKillClient(d, cur->w);
|
||||
}
|
||||
|
||||
int multimonitor_action (int action) { // action = 0 -> center; action = 1 -> fs
|
||||
if (!XineramaIsActive(d)) return 1;
|
||||
XineramaScreenInfo *si = XineramaQueryScreens(d, &monitors);
|
||||
for (int i = 0; i < monitors; i++) {
|
||||
if ((cur->wx + (cur->ww/2) >= (unsigned int)si[i].x_org
|
||||
&& cur->wx + (cur->ww/2) < (unsigned int)si[i].x_org + si[i].width)
|
||||
&& ( cur->wy + (cur->wh/2) >= (unsigned int)si[i].y_org
|
||||
&& cur->wy + (cur->wh/2) < (unsigned int)si[i].y_org + si[i].height)) {
|
||||
if (action)
|
||||
XMoveResizeWindow(d, cur->w,
|
||||
si[i].x_org, si[i].y_org,
|
||||
si[i].width - 2*BORDER_WIDTH,
|
||||
si[i].height - 2*BORDER_WIDTH);
|
||||
else
|
||||
XMoveWindow(d, cur->w,
|
||||
si[i].x_org + ((si[i].width - ww)/2),
|
||||
si[i].y_org + ((si[i].height -wh)/2));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void win_center(const Arg arg) {
|
||||
if (!cur) return;
|
||||
|
||||
win_size(cur->w, &(int){0}, &(int){0}, &ww, &wh);
|
||||
if (multimonitor_action(0)) {
|
||||
XMoveWindow(d, cur->w, (sw - ww) / 2, (sh - wh) / 2);
|
||||
}
|
||||
|
||||
win_size(cur->w, &cur->wx, &cur->wy, &cur->ww, &cur->wh);
|
||||
}
|
||||
|
||||
void win_fs(const Arg arg) {
|
||||
if (!cur) return;
|
||||
|
||||
if ((cur->f = cur->f ? 0 : 1)) {
|
||||
win_size(cur->w, &cur->wx, &cur->wy, &cur->ww, &cur->wh);
|
||||
if(multimonitor_action(1))
|
||||
XMoveResizeWindow(d, cur->w, 0, 0, sw, sh);
|
||||
|
||||
} else {
|
||||
XMoveResizeWindow(d, cur->w, cur->wx, cur->wy, cur->ww, cur->wh);
|
||||
}
|
||||
|
|
Reference in New Issue