support more complex monitor layouts with move/focus actions using left|right|up|down
Conflicts: config.h
This commit is contained in:
4
action.c
4
action.c
@@ -100,7 +100,7 @@ void action_find_or_start(void *data, int num, Client *cli)
|
|||||||
void action_move_monitor(void *data, int num, Client *cli)
|
void action_move_monitor(void *data, int num, Client *cli)
|
||||||
{
|
{
|
||||||
if (!cli) return;
|
if (!cli) return;
|
||||||
cli->monitor = MAX(0, MIN(current_mon+num, nmonitors-1));
|
cli->monitor = monitor_choose_by_direction(current_mon, num);
|
||||||
client_place_spot(cli, cli->spot, cli->monitor, 1);
|
client_place_spot(cli, cli->spot, cli->monitor, 1);
|
||||||
client_raise_family(cli);
|
client_raise_family(cli);
|
||||||
current_mon = cli->monitor;
|
current_mon = cli->monitor;
|
||||||
@@ -109,7 +109,7 @@ void action_move_monitor(void *data, int num, Client *cli)
|
|||||||
|
|
||||||
void action_focus_monitor(void *data, int num, Client *cli)
|
void action_focus_monitor(void *data, int num, Client *cli)
|
||||||
{
|
{
|
||||||
int i, mon = MAX(0, MIN(current_mon+num, nmonitors-1));
|
int i, mon = monitor_choose_by_direction(current_mon, num);
|
||||||
if (!spot_focus_top_window(current_spot, mon, None))
|
if (!spot_focus_top_window(current_spot, mon, None))
|
||||||
for_spots(i) if (spot_focus_top_window(i, mon, None)) break;
|
for_spots(i) if (spot_focus_top_window(i, mon, None)) break;
|
||||||
spot_warp_pointer(current_spot, current_mon);
|
spot_warp_pointer(current_spot, current_mon);
|
||||||
|
|||||||
4
config.c
4
config.c
@@ -411,7 +411,7 @@ configure()
|
|||||||
if (strcmp(regex_matches[3], "spot3") == 0) num = SPOT3;
|
if (strcmp(regex_matches[3], "spot3") == 0) num = SPOT3;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (0 == strcmp(regex_matches[2], "action_move_direction") || 0 == strcmp(regex_matches[2], "action_focus_direction"))
|
if (0 == strcmp(regex_matches[2], "action_move_direction") || 0 == strcmp(regex_matches[2], "action_focus_direction") || 0 == strcmp(regex_matches[2], "action_move_monitor") || 0 == strcmp(regex_matches[2], "action_focus_monitor"))
|
||||||
{
|
{
|
||||||
if (strcmp(regex_matches[3], "left" ) == 0) num = LEFT;
|
if (strcmp(regex_matches[3], "left" ) == 0) num = LEFT;
|
||||||
if (strcmp(regex_matches[3], "right") == 0) num = RIGHT;
|
if (strcmp(regex_matches[3], "right") == 0) num = RIGHT;
|
||||||
@@ -424,7 +424,7 @@ configure()
|
|||||||
data = regex_matches[3];
|
data = regex_matches[3];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (0 == strcmp(regex_matches[2], "action_raise_nth") || 0 == strcmp(regex_matches[2], "action_move_monitor") || 0 == strcmp(regex_matches[2], "action_focus_monitor"))
|
if (0 == strcmp(regex_matches[2], "action_raise_nth"))
|
||||||
{
|
{
|
||||||
num = strtol(regex_matches[3], NULL, 10);
|
num = strtol(regex_matches[3], NULL, 10);
|
||||||
}
|
}
|
||||||
|
|||||||
9
config.h
9
config.h
@@ -49,8 +49,9 @@
|
|||||||
|
|
||||||
Layout layouts[] = {
|
Layout layouts[] = {
|
||||||
// Look at xrandr output to determine your monitor order.
|
// Look at xrandr output to determine your monitor order.
|
||||||
{ .spot_start = SMART, .spot1_align = LEFT, .spot1_width_pct = 60, .spot2_height_pct = 60 }, // primary monitor
|
{ .spot_start = SMART, .spot1_align = LEFT, .spot1_width_pct = 60, .spot2_height_pct = 50 }, // primary monitor
|
||||||
{ .spot_start = SMART, .spot1_align = RIGHT, .spot1_width_pct = 60, .spot2_height_pct = 60 }, // secondary monitor, etc...
|
{ .spot_start = SMART, .spot1_align = LEFT, .spot1_width_pct = 60, .spot2_height_pct = 60 }, // secondary monitor, etc...
|
||||||
|
{ .spot_start = SMART, .spot1_align = LEFT, .spot1_width_pct = 60, .spot2_height_pct = 60 }, // secondary monitor, etc...
|
||||||
};
|
};
|
||||||
|
|
||||||
// Available actions...
|
// Available actions...
|
||||||
@@ -62,8 +63,8 @@ Layout layouts[] = {
|
|||||||
// action_cycle
|
// action_cycle
|
||||||
// action_command
|
// action_command
|
||||||
// action_find_or_start
|
// action_find_or_start
|
||||||
// action_move_monitor
|
// action_move_monitor .num = UP/DOWN/LEFT/RIGHT
|
||||||
// action_focus_monitor
|
// action_focus_monitor .num = UP/DOWN/LEFT/RIGHT
|
||||||
// action_fullscreen
|
// action_fullscreen
|
||||||
// action_maximize_vert
|
// action_maximize_vert
|
||||||
// action_maximize_horz
|
// action_maximize_horz
|
||||||
|
|||||||
71
monitor.c
Normal file
71
monitor.c
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
MIT/X11 License
|
||||||
|
Copyright (c) 2016 Sean Pringle <sean.pringle@gmail.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
int monitor_choose_by_direction(int cmon, int dir)
|
||||||
|
{
|
||||||
|
int mon = cmon;
|
||||||
|
int i; Monitor *m;
|
||||||
|
if (dir == LEFT)
|
||||||
|
{
|
||||||
|
for_monitors(i, m)
|
||||||
|
if (OVERLAP(m->y, m->h, monitors[cmon].y, monitors[cmon].h) && m->x < monitors[cmon].x && (mon == cmon || m->x >= monitors[mon].x))
|
||||||
|
mon = i;
|
||||||
|
if (mon == cmon) for_monitors(i, m)
|
||||||
|
if (m->x < monitors[cmon].x && (mon == cmon || m->x >= monitors[mon].x))
|
||||||
|
mon = i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (dir == RIGHT)
|
||||||
|
{
|
||||||
|
for_monitors(i, m)
|
||||||
|
if (OVERLAP(m->y, m->h, monitors[cmon].y, monitors[cmon].h) && m->x >= monitors[cmon].x + monitors[cmon].w && (mon == cmon || m->x <= monitors[mon].x))
|
||||||
|
mon = i;
|
||||||
|
if (mon == cmon) for_monitors(i, m)
|
||||||
|
if (m->x >= monitors[cmon].x + monitors[cmon].w && (mon == cmon || m->x <= monitors[mon].x))
|
||||||
|
mon = i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (dir == UP)
|
||||||
|
{
|
||||||
|
for_monitors(i, m)
|
||||||
|
if (OVERLAP(m->x, m->w, monitors[cmon].x, monitors[cmon].w) && m->y < monitors[cmon].y && (mon == cmon || m->y >= monitors[mon].y))
|
||||||
|
mon = i;
|
||||||
|
if (mon == cmon) for_monitors(i, m)
|
||||||
|
if (m->y < monitors[cmon].y && (mon == cmon || m->y >= monitors[mon].y))
|
||||||
|
mon = i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (dir == DOWN)
|
||||||
|
{
|
||||||
|
for_monitors(i, m)
|
||||||
|
if (OVERLAP(m->x, m->w, monitors[cmon].x, monitors[cmon].w) && m->y >= monitors[cmon].y + monitors[cmon].h && (mon == cmon || m->y <= monitors[mon].y))
|
||||||
|
mon = i;
|
||||||
|
if (mon == cmon) for_monitors(i, m)
|
||||||
|
if (m->y >= monitors[cmon].y + monitors[cmon].h && (mon == cmon || m->y <= monitors[mon].y))
|
||||||
|
mon = i;
|
||||||
|
}
|
||||||
|
return mon;
|
||||||
|
}
|
||||||
1
xoat.c
1
xoat.c
@@ -216,6 +216,7 @@ void exec_cmd(char *cmd)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "monitor.c"
|
||||||
#include "window.c"
|
#include "window.c"
|
||||||
#include "ewmh.c"
|
#include "ewmh.c"
|
||||||
#include "client.c"
|
#include "client.c"
|
||||||
|
|||||||
10
xoatrc
10
xoatrc
@@ -110,12 +110,12 @@ bind Mod4+h action_maximize_horz
|
|||||||
bind Mod4+m action_maximize
|
bind Mod4+m action_maximize
|
||||||
|
|
||||||
# Switch focus between monitors.
|
# Switch focus between monitors.
|
||||||
bind Mod4+Next action_focus_monitor -1
|
bind Mod4+Next action_focus_monitor right
|
||||||
bind Mod4+Prior action_focus_monitor +1
|
bind Mod4+Prior action_focus_monitor left
|
||||||
|
|
||||||
# Move windows between monitors.
|
# Move windows between monitors.
|
||||||
bind Mod4+Shift+Next action_move_monitor -1
|
bind Mod4+Shift+Next action_move_monitor right
|
||||||
bind Mod4+Shift+Prior action_move_monitor +1
|
bind Mod4+Shift+Prior action_move_monitor left
|
||||||
|
|
||||||
# Launchers
|
# Launchers
|
||||||
bind Mod4+x action_command dmenu_run
|
bind Mod4+x action_command dmenu_run
|
||||||
@@ -138,4 +138,4 @@ bind F4 action_find_or_start sublime-text
|
|||||||
# Consider carefully if this is really what you want. Launch commands
|
# Consider carefully if this is really what you want. Launch commands
|
||||||
# will be run on startup and on every "xoat restart" there after...
|
# will be run on startup and on every "xoat restart" there after...
|
||||||
# launch xterm
|
# launch xterm
|
||||||
# launch xsetroot -cursor_name left_ptr
|
# launch xsetroot -cursor_name left_ptr
|
||||||
|
|||||||
Reference in New Issue
Block a user