Re: Gnome 3.22 Wayland is eating my chess pieces (unicode chess font)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You're getting the size of the GdkWindow — and that's generally wrong
on any platform. It works by sheer accident on X11 on your setup, but
GdkWindows sizes may have no relations to the size of the widget
you're drawing, as they are native windowing system surfaces, and they
could extend past the widget boundaries, to draw things like drop
shadows.

Determining the size of the drawing area based on the size of the
parent is also not a good plan. You should use the allocated size of
your widget, at all times; that's where your rendering is guaranteed
to exist and be visible. The rendered area will also be clipped to it,
so you cannot really draw outside of your allocation (actually: your
clip, but that's managed internally by GTK+, to allow things like
shadows, negative margins, and borders).

If you want to ensure that your widget to have a certain size then you
should override the get_preferred_width/get_preferred_height virtual
functions and compute the minimum and natural sizes.

Ciao,
 Emmanuele.


On 10 April 2017 at 10:55, Stefan Salewski <mail@xxxxxxxxxxxx> wrote:
> On Mon, 2017-04-10 at 10:37 +0200, Stefan Salewski wrote:
>> Any ideas?
>
> Well, maybe the problem is not the font dimensions, but the window
> itself.
>
> The size calculations occur in
>
> https://github.com/ngtk3/nim-chess2/blob/master/board.nim
>
> proc drawIt(cr: cairo.Context; widget: Widget) {.cdecl.} =
>   const
>     Font = "Sans 64"
>
>   var
>     w, h: cint
>     width: cint = widget.parentWindow.width
>     height = widget.parentWindow.height
>
>
> I can not remember why size calculation was based on
>
> https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-get-parent-window
>
> I guess I found a hint with Google, it may be related to window
> decorations of window managers.
>
> When I set Window size with
>
> window.setDefaultSize(800, 800)
>
> I get different results for wayland and X:
>
> X:
> widget.parentWindow.width 800
> widget.parentWindow.height 800
>
> Wayland:
> widget.parentWindow.width 852
> widget.parentWindow.height 894
>
> I am not yet sure that this is the real problem, maybe both results are
> just right?
>
> But we need a solution which works for both, X and Wayland.
> _______________________________________________
> gtk-list mailing list
> gtk-list@xxxxxxxxx
> https://mail.gnome.org/mailman/listinfo/gtk-list



-- 
https://www.bassi.io
[@] ebassi [@gmail.com]
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list




[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux