wails icon indicating copy to clipboard operation
wails copied to clipboard

[V2] [Windows] A Small Bug On Mouse Cursor

Open KiddoV opened this issue 3 years ago • 2 comments

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

KiddoV avatar Jun 28 '22 13:06 KiddoV

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

leaanthony avatar Jun 28 '22 13:06 leaanthony

Depends on #1349

leaanthony avatar Jul 09 '22 12:07 leaanthony

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

leaanthony avatar Oct 16 '22 10:10 leaanthony

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)

glitchedgitz avatar Dec 07 '22 08:12 glitchedgitz

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?

leaanthony avatar Dec 07 '22 09:12 leaanthony

Sure, Can you point me in some direction?

glitchedgitz avatar Dec 07 '22 16:12 glitchedgitz

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

leaanthony avatar Dec 07 '22 18:12 leaanthony

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.

glitchedgitz avatar Dec 11 '22 04:12 glitchedgitz

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 😅

leaanthony avatar Dec 11 '22 06:12 leaanthony

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.

stffabi avatar Dec 11 '22 09:12 stffabi

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

glitchedgitz avatar Dec 11 '22 11:12 glitchedgitz

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

stffabi avatar Dec 11 '22 12:12 stffabi

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 avatar Dec 12 '22 17:12 glitchedgitz

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

glitchedgitz avatar Dec 12 '22 17:12 glitchedgitz

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

stffabi avatar Dec 12 '22 18:12 stffabi

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.

glitchedgitz avatar Dec 15 '22 09:12 glitchedgitz

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

leaanthony avatar Dec 15 '22 10:12 leaanthony

This bug also applies to Linux.

stffabi avatar Jan 16 '23 11:01 stffabi

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

stffabi avatar Jan 16 '23 11:01 stffabi