~eliasnaur/gio-patches

gio: app/internal/wm: fixed Windows window sizes v1 PROPOSED

~pierrec
~pierrec: 1
 app/internal/wm: fixed Windows window sizes

 1 files changed, 10 insertions(+), 4 deletions(-)
#474612 apple.yml success
#474613 freebsd.yml success
#474614 linux.yml success
#474615 openbsd.yml success
Let' backtrack a little.
I made a change in os_macos.go that is confusing me.

The screen scaling in os_macos.go/NewWindow will always do nothing:
```
screenScale := float32(C.gio_getScreenBackingScale())
cfg := configFor(screenScale)
...
width = int(float32(cfg.Px(o.Width)) / screenScale)
```

as it is equivalent to:
```
width = int(o.Width.V)
```

right?
I changed (an error on my side)
cfg := configFor(screenScale)

to

cfg := configFor(w.scale)

which *does* have an effect as the view backing scale factor is
different from the screen one.

Now, I am confused:
in window.draw(), w.scale is used (the view scale factor) NOT the
screen one, and in
NewWindow it is the screen factor, which is a noop.

What am I missing?
Le jeu. 1 avr. 2021 à 11:04, Elias Naur <mail@eliasnaur.com> a écrit :
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~eliasnaur/gio-patches/patches/21701/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH gio] app/internal/wm: fixed Windows window sizes Export this patch

~pierrec
From: pierre <pierre.curto@gmail.com>

Window creation on Windows did not take the screen scale into account.

Signed-off-by: pierre <pierre.curto@gmail.com>
---
-

 app/internal/wm/os_windows.go | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/app/internal/wm/os_windows.go b/app/internal/wm/os_windows.go
index f50fa43..f3277aa 100644
--- a/app/internal/wm/os_windows.go
+++ b/app/internal/wm/os_windows.go
@@ -179,9 +179,11 @@ func createNativeWindow(opts *Options) (*window, error) {
	}
	dpi := windows.GetSystemDPI()
	cfg := configForDPI(dpi)
	width := cfg.Px(opts.Width)
	height := cfg.Px(opts.Height)
	wr := windows.Rect{
		Right:  int32(cfg.Px(opts.Width)),
		Bottom: int32(cfg.Px(opts.Height)),
		Right:  int32(width),
		Bottom: int32(height),
	}
	dwStyle := uint32(windows.WS_OVERLAPPEDWINDOW)
	dwExStyle := uint32(windows.WS_EX_APPWINDOW | windows.WS_EX_WINDOWEDGE)
@@ -193,13 +195,17 @@ func createNativeWindow(opts *Options) (*window, error) {
	deltas.width = wr.Right - wr.Left - deltas.width
	deltas.height = wr.Bottom - wr.Top - deltas.height

	// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-createwindowa
	// For overlapped windows, nWidth is either the window's width, in screen coordinates,
	// or CW_USEDEFAULT.
	screenScale := cfg.PxPerDp
	hwnd, err := windows.CreateWindowEx(dwExStyle,
		resources.class,
		opts.Title,
		dwStyle|windows.WS_CLIPSIBLINGS|windows.WS_CLIPCHILDREN,
		windows.CW_USEDEFAULT, windows.CW_USEDEFAULT,
		wr.Right-wr.Left,
		wr.Bottom-wr.Top,
		int32(float32(width)/screenScale)+deltas.width,
		int32(float32(height)/screenScale)+deltas.height,
		0,
		0,
		resources.handle,
-- 
2.30.2
builds.sr.ht
gio/patches: SUCCESS in 21m35s

[app/internal/wm: fixed Windows window sizes][0] from [~pierrec][1]

[0]: https://lists.sr.ht/~eliasnaur/gio-patches/patches/21701
[1]: mailto:pierre.curto@gmail.com

✓ #474614 SUCCESS gio/patches/linux.yml   https://builds.sr.ht/~eliasnaur/job/474614
✓ #474612 SUCCESS gio/patches/apple.yml   https://builds.sr.ht/~eliasnaur/job/474612
✓ #474615 SUCCESS gio/patches/openbsd.yml https://builds.sr.ht/~eliasnaur/job/474615
✓ #474613 SUCCESS gio/patches/freebsd.yml https://builds.sr.ht/~eliasnaur/job/474613