chaosparrot / talon_hud

Unofficial Talon Head Up Display scripts
68 stars 29 forks source link

HUD disappears after dragging and does not save position #2

Closed nriley closed 3 years ago

nriley commented 3 years ago

I just updated to the latest version from this repository. Now when I drag the HUD, I see a box like this:

image

(sometimes, the bottom/right edges become visible)

But when I drop the HUD, the red box disappears, and the HUD window doesn't replace it. When I try to hide/show the HUD it appears back where it did previously.

If I edit the location in preferences.csv, it does cause the actual window to appear in that place:

image

But when I drag it, while the window lands in the right place it appears to not have any content.

image

Finally if I use "head up hide" then "head up show", it appears offscreen (note the negative x/y position):

image

Not sure if this is a Talon bug or a HUD bug, but figured I might report it here first. (This is macOS 10.15.7 and Talon 0.1.5-207).

chaosparrot commented 3 years ago

Hey thanks for making a detailed issue about this!

The thing I made for dragging and resizing purposes was to specifically add a border during setup mode. Moving the mouse around should make the status bar or the event log visible eventually as the red border should encapsulate the full content / canvas of the element. During my testing with a single monitor it seemed to work on both linux and windows ( on the beta as well as the 0.1.5 release ).

Do you happen to have multiple monitors? If so, what are they set up like? I think I made some calculation short cuts with the naive assumption that there wouldn't be negative coordinates in screen space, but I am uncertain if that scenario happens with multiple monitors, which would explain the weird behavior.

If there are negative coordinates involved, I will rework a lot of positioning code to mitigate the issues

nriley commented 3 years ago

Yes, I do have 2 monitors — but neither seem to be in negative coordinates.

image

From the REPL — ugh, I think i see the problem with the size being 0×0. This seems to be related to https://github.com/talonvoice/talon/issues/248 / https://github.com/talonvoice/talon/issues/303. Wonder if there is a way you can work around this for now until aegis gets around to fixing it?

>>> screen.screens()
[Screen(x=0.0, y=1440.0, size=(0.0, 0.0), mm=(599.2995301699309, 340.24185535519626)), Screen(x=685.0, y=1440.0, size=(1112.0, 834.0), mm=(392.2888829973009, 294.2166622479757))]
chaosparrot commented 3 years ago

Hmm I see, one thing you could try is rename the preferences.csv file to a different file temporarily and let it setup the defaults again, and see if the issues persist still.

( I'm fairly certain this is a HUD bug, I'm just unsure yet where the issue originates from )

chaosparrot commented 3 years ago

Oh, that 0x0 dimension might make some canvas rendering weird, I'm going to look and see if I use the screen coordinates / widths anywhere in the code. Edit - Could not find any coordinates that are derived from the screens api

nriley commented 3 years ago

Hmm, maybe not. I restarted Talon and the screen.screens() output is sane again (think it's related to hot plugging screens).

[Screen(x=0.0, y=0.0, size=(2560.0, 1440.0), mm=(599.2995301699309, 340.24185535519626)), Screen(x=709.0, y=1440.0, size=(1112.0, 834.0), mm=(392.2888829973009, 294.2166622479757))]

Another thing I discovered — dragging the event log works perfectly. Only dragging the status bar is a problem.

chaosparrot commented 3 years ago

Hmmm, one thing you could try for me is set the value: mouse_enabled to False in statusbar.py and try again.

The major difference between statusbar and eventlog is that the eventlog isn't a window, and the statusbar is, which allows it to capture the mouse clicks, that might be thing that is causing these issues.

One other thing you could do for debugging is copy and paste all the values in preferences.csv prefixed with status_bar

nriley commented 3 years ago

Somehow I got myself into a position where I could not get the status bar to display no matter what.

I moved preferences.csv out of its folder and now status bar dragging works (regardless of the value of mouse_enabled)! There must have been something in there that was breaking things.

Here's my (nonfunctional) preferences.csv:

show_animations,1
enabled,1
theme_name,light
status_bar_x,200
status_bar_y,200
status_bar_width,250
status_bar_height,50
status_bar_enabled,1
event_log_x,0
event_log_y,1239
event_log_width,450
event_log_height,200
event_log_enabled,1
status_bar_type,status_bar
status_bar_sleep_enabled,1
status_bar_show_animations,1
status_bar_limit_x,11
status_bar_limit_y,37
status_bar_limit_width,250
status_bar_limit_height,50
status_bar_font_size,24
status_bar_alignment,left
status_bar_expand_direction,down
event_log_type,event_log
event_log_sleep_enabled,0
event_log_show_animations,1
event_log_limit_x,0
event_log_limit_y,1239
event_log_limit_width,450
event_log_limit_height,200
event_log_font_size,18
event_log_alignment,right
event_log_expand_direction,up

And a working one:

show_animations,1
enabled,1
theme_name,light
status_bar_type,status_bar
status_bar_enabled,1
status_bar_sleep_enabled,1
status_bar_show_animations,1
status_bar_x,2278
status_bar_y,1374
status_bar_width,250
status_bar_height,50
status_bar_limit_x,2278
status_bar_limit_y,1374
status_bar_limit_width,250
status_bar_limit_height,50
status_bar_font_size,24
status_bar_alignment,left
status_bar_expand_direction,down
chaosparrot commented 3 years ago

Hmm, I think I know where the problem is and why the bar didn't show up anymore.

I've added two sets of dimensions, a bounding box prefixed with limit, and the regular positions we had before. The regular positions and dimensions MUST be fully contained inside the bounding box, and from the coordinates that I see in the csv file, that doesn't seem to be the case.

The limit coordinate X starts at 11, and the width is 250 which would make the largest width coordinate 261. However, the rendering of the statusbar starts at 200 with a width of 250, which would place those pixels at 450 at the maximum, outside of the rendering canvas which is dictated by the limits. The code I wrote specifically validates and corrects for that during dragging, but not during loading.

What seemed to have happened is that I unintentionally broke existing preferences.csv files by adding these limits and not properly setting them up with the old csvs that didn't include this functionality. For that I apologize, should have tested that better before merging to master.

The issues should not persist after this however, I am keeping this issue open for a while just in case more users find this problem. If no new issues arise I will close it in about a week.