frame width and (get-display-size) ...

35 vues
Accéder directement au premier message non lu

Don Green

non lue,
5 août 2021, 11:36:3205/08/2021
à Racket Users
Creating a frame width that is half of the width given by (get-display-size), then moving the resulting window to the right and left of the screen you can see that if you had 2 windows of the same size they would not touch each other as you would expect.
For some reason, dividing the total pixel width in HALF, DOES NOT give 2 windows that will fill the space.
;Instead there is a mysterious gap that happens to be about the width of the O.S. vertical toolbar.
Can anyone explain?
Thanks

Jens Axel Søgaard

non lue,
5 août 2021, 12:30:4705/08/2021
à Don Green,Racket Users
Which OS?



--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/1e605128-50b3-4578-bf60-2aaa68016006n%40googlegroups.com.


--
--
Jens Axel Søgaard

Jens Axel Søgaard

non lue,
5 août 2021, 12:36:2805/08/2021
à Don Green,Racket Users
The program below produces the expected result on macOS.

image.png

#lang racket
(require racket/gui)
(define-values (w h) (get-display-size))
(define f1 (new frame% [label "Window 1"] [height 100] [width (/ w 2)] [y 0] [x 0]))
(define f2 (new frame% [label "Window 2"] [height 100] [width (/ w 2)] [y 0] [x (/ w 2)]))
(send f1 show #t)
(send f2 show #t)

George Neuner

non lue,
5 août 2021, 18:56:0205/08/2021
à racket users,Jens Axel Søgaard,Don Green
On 8/5/2021 12:36 PM, Jens Axel Søgaard wrote:
The program below produces the expected result on macOS.

image.png

#lang racket
(require racket/gui)
(define-values (w h) (get-display-size))
(define f1 (new frame% [label "Window 1"] [height 100] [width (/ w 2)] [y 0] [x 0]))
(define f2 (new frame% [label "Window 2"] [height 100] [width (/ w 2)] [y 0] [x (/ w 2)]))
(send f1 show #t)
(send f2 show #t)



But it doesn't work on Windows 10.





I know the reason ... it's the window 'snap' feature.

What I don't know is how to get around it.  'get-display-size'  is returning correct values for the screen, but when the windows are created - or perhaps when they are shown - their size is being adjusted to leave the 'snapping' areas at the side of the screen exposed.

If you add to the program

   (printf "~a ~a" w h)
   (define f3 (new frame% [label "Window 1"] [height h] [width w] [y 0] [x 0]))
   (send f3 show #t)

on Win10 you'll see on your console that the width is correct but the resulting "full screen" window reaches neither the sides nor the bottom of the screen.


You can turning off window snapping in Settings, but it's a per-user setting, and although turning it off disables the snap behavior it doesn't seem to affect the window sizing behavior.

Wondering now if native Windows programs have the same problem.  Have to dust off my C++ and try it with Visual Studio.

George

George Neuner

non lue,
6 août 2021, 03:28:3606/08/2021
à racket users,Jens Axel Søgaard,Don Green

I have no idea what this code will do on MacOS, but it works on Windows ... at least for the limited window tilings I tried.

YMMV.

-------------------------------------
#lang racket
(require racket/gui)
(define-values (w h) (get-display-size #:monitor 0))
(printf "screen: ~a ~a~n" w h)

(set! w (/ w 2))
(set! h 100)
 
(define f1 (new frame% [label "Window 1"] [height h] [width w] [y 0] [x 0]))
(define f2 (new frame% [label "Window 2"] [height h] [width w] [y h] [x w]))
(define f3 (new frame% [label "Window 3"] [height h] [width w] [y (+ h h)] [x 0]))

(define (align frm)
  (let*-values [
                ((wx)    (send frm get-x))
                ((wy)    (send frm get-y))
                ((ww wh) (send frm get-client-size))

                ((dx dy) (send frm client->screen 0 0))
             
                ]
    (printf "~s:~n" frm)
    (printf "~a,~a ~a ~a~n" wx wy ww wh)
    (printf "~a,~a~n" dx dy)
    (printf "~n")

    (let ((dx (- wx dx)))
      (send frm move (+ wx dx) wy))
    (send frm resize
          (+ w (abs (- ww w)))
          (+ h (- h (+ wh (- dy wy))))
          )

    (send frm show #t)
    ))

(align f1)
(align f2)
(align f3)

-------------------------------------


Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message