Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/relative multimonitor position #47

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1260891
add base for better multimonitor support
juster-0 Jul 3, 2022
712bf6e
add monitor option to conf
juster-0 Jul 3, 2022
5e4ee37
update doc
juster-0 Jul 3, 2022
5f041d0
fix relative length of bars for monitors with different resolution
juster-0 Jul 3, 2022
4681e57
fix README.md
juster-0 Jul 3, 2022
ad4f058
fix doc
juster-0 Jul 3, 2022
0601e32
Update README.md
juster-0 Jul 4, 2022
0e33dd7
rename auto mode to combined; small cosmetics fixes
juster-0 Jul 4, 2022
8586a59
refactor multimonitor code
juster-0 Jul 8, 2022
9e73e9a
add code to support changing bar position depends on focused window
juster-0 Jul 8, 2022
b399c08
fix mistake with max possible height
juster-0 Jul 8, 2022
3b51fd3
Merge branch 'dev' into feature/relative-multimonitor-position
juster-0 Jul 8, 2022
1322dda
add code to support changing bar position depends on pointer position
juster-0 Jul 9, 2022
552766d
move bar position related stuff to Geometry_context
juster-0 Jul 10, 2022
1719410
use clang-format; small improvements
juster-0 Jul 11, 2022
5161fd0
change bar sizes relative to monitor sizes
juster-0 Jul 11, 2022
307bb0e
update doc; delete unnecessary code
juster-0 Jul 15, 2022
6b5cdc1
fix if statement that used to determine monitor info by coords; in re…
juster-0 Jul 15, 2022
bf55c19
draw all elements of the bar separately
juster-0 Jul 15, 2022
f446332
cosmetics fix
juster-0 Jul 18, 2022
00d7c32
merge dev
juster-0 Jul 18, 2022
a397499
fix overflow mode
juster-0 Jul 18, 2022
ef69d4d
perfomance improvements (don't redraw frame everytime)
juster-0 Jul 18, 2022
77fc933
use pointers for display_context in show, hide and display_context_de…
juster-0 Jul 19, 2022
a714f63
improve perfomance for relative bars
juster-0 Jul 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PROGRAM = xob
MANPAGE = doc/xob.1
SYSCONF = styles.cfg
LIBS = x11 libconfig
LIBS = x11 libconfig xrandr
SOURCES = src/conf.c src/display.c src/main.c

# Feature: alpha channel (transparency)
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ When starting, xob looks for the configuration file in the following order:
Consult the man page for detailed information about the configuration file and the available options. The following `styles.cfg` defines a single style called "default" that showcases all the possible options set to the default values. The configuration file may contain additional styles to choose among using the **-s** argument.

default = {
monitor = "combined";
x = {relative = 1; offset = -48;};
y = {relative = 0.5; offset = 0;};
length = {relative = 0.3; offset = 0;};
Expand Down Expand Up @@ -315,9 +316,10 @@ There is no support for panel integration. You can however use absolute position

> "How about multiple monitors?"

xob works well under multihead setups. The `x`, `y`, and `length` style options refer to the combined screen surface. By default the bar is vertical near the right edge of the rightmost monitor. In vertical layouts, you may prefer to switch the bar to horizontal mode as follows to avoid splits.
xob works well under multihead setups. The default orientation of bar is `vertical` and is positioned at the right edge of the screen surface. By default, `x`, `y`, and `length` style options refer to the combined screen surface, but you can specify a monitor for the bar, for example you can set option `monitor = "HDMI-1"` to show the bar only on `HDMI-1` (use `xrandr` command to get monitors names). In vertical layouts, you may prefer to switch the bar to horizontal mode as follows to avoid splits.

horizontal = {
monitor = "combined";
x = {relative = 0.5; offset = 0;};
y = {relative = 1; offset = -48;};
orientation = "horizontal";
Expand Down
30 changes: 19 additions & 11 deletions doc/xob.1
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ In the following, a dot \[lq].\[rq] means \[lq]suboption\[rq].
For instance \[lq]color.normal.fg\[rq] means \[lq]The suboption fg of
the suboption normal of option color\[rq].
.TP
\f[B]monitor\f[R] \f[I]\[lq]output_name\[rq] | \[lq]relative_focus\[rq] | \[lq]relative_pointer\[rq] | \[lq]combined\[rq]\f[R] (default: combined)
Output monitor for the bar, use \f[I]xrandr\f[R] command to get monitors names.
Use \f[I]relative_focus\f[R] to show the bar on the monitor with a focused window.
Use \f[I]relative_pointer\f[R] to show the bar on the monitor with a mouse
pointer. Use \f[I]combined\f[R] to show the bar on the combined surface of all
monitors. The option is case-sensitive.
.TP
\f[B]orientation\f[R] \f[I]\[lq]horizontal\[rq] | \[lq]vertical\[rq]\f[R] (default: vertical)
Orientation of the bar which either fills up from left to right
(\[lq]horizontal\[rq]) or bottom to top (\[lq]vertical\[rq]).
Expand Down Expand Up @@ -301,6 +308,7 @@ backlight = {
.nf
\f[C]
default = {
monitor = \[dq]combined\[dq];
x = {relative = 1; offset = -48;};
y = {relative = 0.5; offset = 0;};
length = {relative = 0.3; offset = 0;};
Expand Down Expand Up @@ -367,17 +375,17 @@ situations.
\[lq]How to set up xob with multiple monitors?\[rq]
.RE
.PP
xob works well under multihead setups but there is no easy way to
configure the position of the bar for now.
For example, in a dual monitor setup with the default configuration, the
horizontal centering is not local to one of the two monitors.
It is global.
The bar might be split in two: one part on each screen.
Stick to a corner or use absolute positioning.
If you want an xob instance to be centered (horizontally) on the
far-right monitor, set \f[I]x.relative\f[R] to 1.0 (anchored on the far
right) and the \f[I]x.offset\f[R] to minus half the width of that
screen.
xob works well under multihead setups, use option \f[I]monitor\f[R] to
specify one. By default xob use \f[I]combined\f[R] for the option. It means
that in a dual monitor setup with the default configuration,
the horizontal centering is not local to one of the two monitors.
It is global. The bar might be split in two: one part on each screen.
If you want an xob instance to be centered (horizontally) on the specific
monitor, set \f[I]monitor\f[R] option to your monitor output,
for example \f[I]monitor = \[lq]HDMI-1\[rq]\f[R] and set options
\f[I]x.relative\f[R] and \f[I]y.relative\f[R] relative to the monitor.
To get monitors output name you can use \f[I]xrandr --listmonitors\f[R]
command in your terminal.
.SH CONTRIBUTIONS
.PP
Feedback and contributions are welcome.
Expand Down
7 changes: 5 additions & 2 deletions doc/xob.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ Options can be grouped together inside curly brackets. Some options expect a gro

In the following, a dot "." means "suboption". For instance "color.normal.fg" means "The suboption fg of the suboption normal of option color".

**monitor** *"output_name" | "relative_focus" | "relative_pointer" | "combined"* (default: combined)
: Output monitor for the bar, use `xrandr` command to get monitors names. Use "relative_focus" to show the bar on the monitor with a focused window. Use "relative_pointer" to show the bar on the monitor with a mouse pointer. Use "combined" to show the bar on the combined surface of all monitors. The option is case-sensitive.

**orientation** *"horizontal" | "vertical"* (default: vertical)
: Orientation of the bar which either fills up from left to right ("horizontal") or bottom to top ("vertical").

Expand Down Expand Up @@ -156,7 +159,6 @@ Each of the following have three suboptions ".fg", ".bg", and ".border" correspo


## STYLES

All the options described above must be encompassed inside a style specification. A style consists of a group of all or some of the options described above. The name of the style is the name of an option at the root level of the configuration file. When an option is missing from a style, the default values are used instead. A configuration file may specify several styles (at least 1) to choose using the **-s** argument.

This example configuration file provides two styles "volume" and "backlight". Instances of xog launched with **-s volume** and **-s backlight** will look according to the corresponding style.
Expand Down Expand Up @@ -194,6 +196,7 @@ This example configuration file provides two styles "volume" and "backlight". In
## DEFAULT CONFIGURATION FILE

default = {
monitor = "combined";
x = {relative = 1; offset = -48;};
y = {relative = 0.5; offset = 0;};
length = {relative = 0.3; offset = 0;};
Expand Down Expand Up @@ -242,7 +245,7 @@ There is no support for panel integration. You can however use absolute position

> "How to set up xob with multiple monitors?"

xob works well under multihead setups but there is no easy way to configure the position of the bar for now. For example, in a dual monitor setup with the default configuration, the horizontal centering is not local to one of the two monitors. It is global. The bar might be split in two: one part on each screen. Stick to a corner or use absolute positioning. If you want an xob instance to be centered (horizontally) on the far-right monitor, set *x.relative* to 1.0 (anchored on the far right) and the *x.offset* to minus half the width of that screen.
xob works well under multihead setups, use option `monitor` to specify one. By default xob use `combined` for the option. It means that in a dual monitor setup with the default configuration, the horizontal centering is not local to one of the two monitors. It is global. The bar might be split in two: one part on each screen. If you want an xob instance to be centered (horizontally) on the specific monitor, set `monitor` option to your monitor output, for example `monitor = "HDMI-1"` and set options `x.relative` and `y.relative` relative to the monitor. To get monitors output name you can use `xrandr --listmonitors` command in your terminal.

# CONTRIBUTIONS

Expand Down
17 changes: 17 additions & 0 deletions src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,22 @@ static int config_setting_lookup_orientation(const config_setting_t *setting,
return success_status;
}

static int config_setting_lookup_monitor(const config_setting_t *setting,
const char *name, char *monitorvalue)
{
const char *stringvalue;

if (config_setting_lookup_string(setting, name, &stringvalue))
{
strncpy(monitorvalue, stringvalue, LNAME_MONITOR);
}
else
{
fprintf(stderr, "Error: No style %s.\n", name);
}
return CONFIG_TRUE;
}

Style parse_style_config(FILE *file, const char *stylename, Style default_style)
{
config_t config;
Expand All @@ -243,6 +259,7 @@ Style parse_style_config(FILE *file, const char *stylename, Style default_style)
xob_config = config_lookup(&config, stylename);
if (xob_config != NULL)
{
config_setting_lookup_monitor(xob_config, "monitor", style.monitor);
config_setting_lookup_int(xob_config, "thickness",
&style.thickness);
config_setting_lookup_int(xob_config, "border", &style.border);
Expand Down
8 changes: 8 additions & 0 deletions src/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@

#include <stdio.h>

#define MONITOR_RELATIVE_FOCUS "relative_focus"
#define MONITOR_RELATIVE_POINTER "relative_pointer"
#define MONITOR_COMBINED "combined"

#define LNAME_MONITOR 17

typedef struct
{
unsigned char red;
Expand Down Expand Up @@ -63,6 +69,7 @@ typedef enum

typedef struct
{
char monitor[LNAME_MONITOR];
Dim x;
Dim y;
Dim length;
Expand All @@ -77,6 +84,7 @@ typedef struct

/* clang-format off */
#define DEFAULT_CONFIGURATION (Style) {\
.monitor = MONITOR_COMBINED,\
.x =\
{\
.rel = 1.0,\
Expand Down
Loading