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

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

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.


On 10 April 2017 at 10:55, Stefan Salewski <mail ssalewski de> 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

The size calculations occur in

proc drawIt(cr: cairo.Context; widget: Widget) {.cdecl.} =
    Font = "Sans 64"

    w, h: cint
    width: cint = widget.parentWindow.width
    height = widget.parentWindow.height

I can not remember why size calculation was based on

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:

widget.parentWindow.width 800
widget.parentWindow.height 800

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 gnome org

[@] ebassi []

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