Skip to content

Commit d9722aa

Browse files
committedMay 31, 2020
Fix interaction of auto hide and toggle functions
1 parent b672f42 commit d9722aa

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed
 

‎highlight-pointer.c

+9-4
Original file line numberDiff line numberDiff line change
@@ -265,19 +265,21 @@ void handle_key(KeySym keysym, unsigned int modifiers) {
265265
break;
266266

267267
case KEY_TOGGLE_CURSOR:
268-
if (cursor_visible) {
268+
if (options.cursor_visible) {
269269
hide_cursor();
270270
} else {
271271
show_cursor();
272272
}
273+
options.cursor_visible = 1 - options.cursor_visible;
273274
break;
274275

275276
case KEY_TOGGLE_HIGHLIGHT:
276-
if (highlight_visible) {
277+
if (options.highlight_visible) {
277278
hide_highlight();
278279
} else {
279280
show_highlight();
280281
}
282+
options.highlight_visible = 1 - options.highlight_visible;
281283
break;
282284

283285
case KEY_TOGGLE_AUTOHIDE_CURSOR:
@@ -339,10 +341,10 @@ void main_loop() {
339341
XFreeEventData(dpy, cookie);
340342
#endif
341343
if (cookie->evtype == XI_RawMotion) {
342-
if (options.auto_hide_cursor && !cursor_visible) {
344+
if (options.auto_hide_cursor && options.cursor_visible && !cursor_visible) {
343345
show_cursor();
344346
}
345-
if (options.auto_hide_highlight && !highlight_visible) {
347+
if (options.auto_hide_highlight && options.highlight_visible && !highlight_visible) {
346348
show_highlight();
347349
} else if (highlight_visible) {
348350
get_pointer_position(&x, &y);
@@ -530,6 +532,9 @@ static struct option long_options[] = {{"auto-hide-cursor", no_argument, &option
530532
{NULL, 0, NULL, 0}};
531533

532534
int set_options(int argc, char* argv[]) {
535+
options.auto_hide_cursor = 0;
536+
options.auto_hide_highlight = 0;
537+
options.cursor_visible = 0;
533538
options.highlight_visible = 1;
534539
options.radius = 5;
535540
options.outline = 0;

0 commit comments

Comments
 (0)