wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
24.5k stars 1.18k forks source link

[V2] [Windows, Linux] Resize cursors are shown when maximised #1503

Open KiddoV opened 2 years ago

KiddoV commented 2 years ago

There is another really really... small bug about the cursor I forgot to mention back then. When the window in full screen mode (maximize), the mouse cursor should NOT change to resize arrow when hover the edges of the window.

Originally posted by @KiddoV in https://github.com/wailsapp/wails/issues/1087#issuecomment-1168646102

leaanthony commented 2 years ago

Can't you normally resize a maximised (not fullscreen) window? EDIT: No! 😉

leaanthony commented 2 years ago

Depends on #1349

leaanthony commented 1 year ago

Bumping this to v2.2. I think we need to rework how we detect window status (fullscreen/maximised/minimised) to make this work properly. Waiting for a callback to Go is not a great solution: I'd like the state pushed to JS as soon as it happens so the test for resizing can be instant.

More info: https://stackoverflow.com/a/47911169

glitchedgitz commented 1 year ago

Hi @leaanthony, Any update on this bug, as v2.2.0 is out?

Indeed it's a small bug but it prevents me from dragging the window. (When the cursor changes on edges in fullscreen)

leaanthony commented 1 year ago

Oh sorry no - it slipped from the release. It's an aggressive roadmap. I think we need to pare it down somewhat and this particular bug isn't a high priority. Would be happy to accept a PR if you can create a fix though?

glitchedgitz commented 1 year ago

Sure, Can you point me in some direction?

leaanthony commented 1 year ago

To fix the original bug, when a cursor hits the edges, we want to first check the window is fullscreen and if so, cancel out the drag operation.

Place to look: v2/internal/frontend/runtime

glitchedgitz commented 1 year ago

Here is a semi-solution. So it's fixed when the user will use buttons to maximize and minimize (Basically when using functions, it fixed it)

But the common way users will go maximize is by dragging the title and hitting the top to maximize.

The best way would be if we have an event handler so that whenever the window goes maximize we can change enableResize.

Or may be using WindowIsMaximised() in v2\internal\frontend\runtime\desktop\main.js, Like this

Note: Code needs to be updated as the function returns promise, but just for example.

leaanthony commented 1 year ago

Yeah, it does feel like the state should be available in the frontend without making a call to the backend. And this needs to be per window in the future 😅

stffabi commented 1 year ago

I think you should be able to Enable/Disable resize with ExecJS from the WndProc in window.go here, that line is only executed for Frameless windows.

https://github.com/wailsapp/wails/blob/eb2d929824c118c29bb95cc89114bbefe5e0e5c4/v2/internal/frontend/desktop/windows/window.go#L240

Depending on style&w32.WS_MAXIMIZE you can either disable/enable it. IIRC that should fix the problem in all cases, since that's the event Windows raises when when maximizing/unmaximizing.

glitchedgitz commented 1 year ago

Well in that case I think w & f both need to be connected with the parent struct. So I can use f's funcitons in w. Consider r(root) as the parent struct, so I can use r.f.ExecJS

stffabi commented 1 year ago

You can directly access chromium and do an eval, like in this snippet in window.go

https://github.com/wailsapp/wails/blob/eb2d929824c118c29bb95cc89114bbefe5e0e5c4/v2/internal/frontend/desktop/windows/window.go#L170-L172

glitchedgitz commented 1 year ago

Great! This worked when I maximized.

But when I put to use the same code in the else statement for unmaximized it crashes and shows a nil memory address error. I tried different things but not working.

glitchedgitz commented 1 year ago

I think if we invoke the code after the window appears it should work.

stffabi commented 1 year ago

Yeah you are right, needs some more handling than just adding it there.

glitchedgitz commented 1 year ago

Yeah, it does feel like the state should be available in the front end without making a call to the back end. And this needs to be per window in the future 😅

I like this Idea, seems like it will solve multiple problems including zoom problems as well.

leaanthony commented 1 year ago

Yeah, state sync is a general problem that should be usable in user-space as well as Wails internals...

stffabi commented 1 year ago

This bug also applies to Linux.

stffabi commented 1 year ago

On macOS the resize cursor are also shown, but on that platform it's possible to resize from maximized.