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

implement screen positioning #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions doc/dtao.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,15 @@ dtao(1) -- general-purpose status, messaging, and notification bar for Wayland
* `-w` <PIXEL>:
set window width

* `-x` <PIXEL>:
set x position on the screen

* `-xs` <NUM>:
display on output number <NUM>

* `-y` <PIXEL>:
set y position on the screen

* `-z`:
when used once: bar will not cover "exclusive zones" of other layer-shell surfaces; when used twice: bar will request its own exclusive zone

Expand Down
27 changes: 23 additions & 4 deletions dtao.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,11 @@ main(int argc, char **argv)
uint32_t anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
int margintop = 0, marginbottom = 0, marginleft = 0, marginright = 0;

/* Parse options */
for (int i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-b")) {
anchor ^= ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
} else if (!strcmp(argv[i], "-bg")) {
if (!strcmp(argv[i], "-bg")) {
if (++i >= argc)
BARF("option -bg requires an argument");
if (parse_color(argv[i], &bgcolor))
Expand Down Expand Up @@ -550,6 +548,25 @@ main(int argc, char **argv)
BARF("option -xs requires an argument");
/* One-based to match dzen2 */
output = atoi(argv[i]) - 1;
} else if (!strcmp(argv[i], "-x")) {
if (++i >= argc)
BARF("option -x requires an argument");
if (*argv[i] == '-')
marginright = atoi(argv[i] + 1);
else
marginleft = atoi(argv[i]);
} else if (!strcmp(argv[i], "-y")) {
if (++i >= argc)
BARF("option -y requires an argument");
if (*argv[i] == '-') {
marginbottom = atoi(argv[i] + 1);
anchor |= ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
anchor &= ~ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP;
} else {
margintop = atoi(argv[i]);
anchor |= ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP;
anchor &= ~ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
}
} else if (!strcmp(argv[i], "-z")) {
exclusive_zone++;
} else {
Expand Down Expand Up @@ -594,6 +611,8 @@ main(int argc, char **argv)

zwlr_layer_surface_v1_set_size(layer_surface, width, height);
zwlr_layer_surface_v1_set_anchor(layer_surface, anchor);
zwlr_layer_surface_v1_set_margin(layer_surface, margintop, marginright,
marginbottom, marginleft);
wl_surface_commit(wl_surface);
wl_display_roundtrip(display);

Expand Down