Skip to content

Commit

Permalink
Merge pull request #215 from Ruby-Dragon/RemoveOffsets
Browse files Browse the repository at this point in the history
Remove offsets
  • Loading branch information
MrGlockenspiel authored Sep 10, 2024
2 parents 633b280 + c3feb89 commit 84a8d07
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 44 deletions.
20 changes: 2 additions & 18 deletions ARGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ Default color is `1-1-1-0.35` (dimmed white)

## Size and position

Note that message always appears in the top left corner of the overlay.

### Custom overlay width
```console
# Default width = 340px
Expand All @@ -78,24 +80,6 @@ Default color is `1-1-1-0.35` (dimmed white)
./activate-linux --scale 1.5
```

### Move overlay horizontally
```console
# 42 pixels left
./activate-linux -H 42
# 42 pixels right
./activate-linux -H -42
./activate-linux --overlay-offset-left -42
```

### Move overlay vertically
```console
# 42 pixels bottom
./activate-linux -V 42
# 42 pixels up
./activate-linux -V -42
./activate-linux --overlay-offset-top -42
```

## Other

### Skip compositor (only works for compliant compositors)
Expand Down
8 changes: 0 additions & 8 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,6 @@ void load_config(const char *const file) {
options.overlay_height = itmp;
}

if (config_lookup_int(cf, "overlay-offset-top", &itmp) != CONFIG_FALSE) {
options.offset_top = itmp;
}

if (config_lookup_int(cf, "overlay-offset-left", &itmp) != CONFIG_FALSE) {
options.offset_left = itmp;
}

if (config_lookup_bool(cf, "daemonize", &itmp) != CONFIG_FALSE) {
options.daemonize = (bool)itmp;
}
Expand Down
12 changes: 2 additions & 10 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ Options options = {
// overlay position
.overlay_width = 340,
.overlay_height = 120,
.offset_left = 0,
.offset_top = 0,

// default color is light grey, which has enough contrast to be noticed
// on both light and dark background.
Expand Down Expand Up @@ -68,8 +66,6 @@ void parse_options(int argc, char *const argv[]) {
{"overlay-width", required_argument, NULL, 'x'},
{"overlay-height", required_argument, NULL, 'y'},
{"scale", required_argument, NULL, 's'},
{"overlay-offset-left", required_argument, NULL, 'H'},
{"overlay-offset-top", required_argument, NULL, 'V'},
// other
{"bypass-compositor", no_argument, NULL, 'w'},
{"daemonize", no_argument, NULL, 'd'},
Expand All @@ -89,7 +85,7 @@ void parse_options(int argc, char *const argv[]) {
};

int opt;
while ((opt = getopt_long(argc, argv, "t:m:p:f:bic:x:y:s:H:V:wdKvlqGh"
while ((opt = getopt_long(argc, argv, "t:m:p:f:bic:x:y:s:wdKvlqGh"
#ifdef X11
"S"
#endif
Expand All @@ -110,8 +106,6 @@ void parse_options(int argc, char *const argv[]) {
// size and position
case 'x': options.overlay_width = atoi(optarg); break;
case 'y': options.overlay_height = atoi(optarg); break;
case 'H': options.offset_left = atoi(optarg); break;
case 'V': options.offset_top = atoi(optarg); break;
// other
case 'w': options.bypass_compositor = true; break;
case 'd': options.daemonize = true; break;
Expand All @@ -128,7 +122,7 @@ void parse_options(int argc, char *const argv[]) {
case 's':
options.scale = atof(optarg);
if (options.scale < 0.0f) {
__error__("Cannot parse custom scale value. It must be number from 0.0 to 1.0\n");
__error__("Cannot parse custom scale value. It must be number greater than 0.0.\n");
exit(EXIT_FAILURE);
}
break;
Expand Down Expand Up @@ -196,8 +190,6 @@ void print_help(const char *const file_name) {
HELP("-x, --overlay-width width \tSet overlay width before scaling (integer)");
HELP("-y, --overlay-height height \tSet overlay height before scaling (integer)");
HELP("-s, --scale scale \t\tScale ratio (float)");
HELP("-H, --overlay-offset-left offset \tMove overlay horizontally (integer)");
HELP("-V, --overlay-offset-top offset \tMove overlay vertically (integer)");
END();

SECTION("Other", "");
Expand Down
2 changes: 0 additions & 2 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ typedef struct options_t {

int overlay_width;
int overlay_height;
int offset_left;
int offset_top;

rgba_color text_color;

Expand Down
4 changes: 2 additions & 2 deletions src/wayland/wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ static void output_done(void *data, struct wl_output *wl_output)
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT);
zwlr_layer_surface_v1_set_exclusive_zone(output->layer_surface, -1);
zwlr_layer_surface_v1_set_margin(output->layer_surface,
0, options.offset_top,
0, options.offset_left);
0, 0,
0, 0);
zwlr_layer_surface_v1_add_listener(output->layer_surface,
&layer_surface_listener, output);
wl_surface_commit(output->surface);
Expand Down
8 changes: 4 additions & 4 deletions src/x11/x11.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ int x11_backend_start(void)
__debug__("Creating overlay on %d screen\n", i);
overlay[i] = XCreateWindow(d, // display
root, // parent
si[i].x_org + si[i].width + options.offset_left - overlay_width, // x position
si[i].y_org + si[i].height + options.offset_top - overlay_height, // y position
si[i].x_org + si[i].width - overlay_width, // x position
si[i].y_org + si[i].height - overlay_height, // y position
overlay_width, // width
overlay_height, // height
0, // border width
Expand Down Expand Up @@ -201,8 +201,8 @@ int x11_backend_start(void)
__debug__(" Moving window on screen %d according new position\n", i);
XMoveWindow(d, // display
overlay[i], // window
si[i].x_org + si[i].width + options.offset_left - overlay_width, // x position
si[i].y_org + si[i].height + options.offset_top - overlay_height // y position
si[i].x_org + si[i].width - overlay_width, // x position
si[i].y_org + si[i].height - overlay_height // y position
);
}
}
Expand Down

0 comments on commit 84a8d07

Please sign in to comment.