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

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Stefan Salewski-2
Some days ago my Gentoo box finally updated to Gnome 3.22.

First surprise: GtkSourceView ignores Text Scaling settings -- seems to
be a well known bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1382840
Not a real problem, but surprising.

Today I logged in using wayland session, selected by gears menu of GDM
login screen and launched my chess game. I got this:

http://ssalewski.de/tmp/nimchesswayland.png

When I log out and in again with ordinary Gnome X session all is fine
again as in

https://github.com/ngtk3/nim-chess2

The cutoff effect is large for a small window, and decreases for a very
large window. So there seems to be a fixed wrong offset in font glyph
size? I have still no real idea, and I wonder why wayland can make a
difference at all for pango font rendering.

Any ideas?

_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Stefan Salewski-2
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
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Emmanuele Bassi
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 <[hidden email]> 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
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-list



--
https://www.bassi.io
[@] ebassi [@gmail.com]
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Stefan Salewski-2
On Mon, 2017-04-10 at 11:07 +0100, Emmanuele Bassi wrote:
> allocated size of
> your widget

Thanks.

I think that is gtk_widget_get_allocation() for GTK3

as mentioned in

http://stackoverflow.com/questions/2675514/totally-fed-up-with-get-gtk-widget-height-and-width

I will try that soon.
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

Stefan Salewski-2
On Mon, 2017-04-10 at 12:28 +0200, Stefan Salewski wrote:
> I will try that soon.

Yes, works fine:

  var
    w, h: cint
    #width: cint = widget.parentWindow.width
    #height = widget.parentWindow.height
    width = getAllocatedWidth(widget)
    height = getAllocatedHeight(widget)
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Loading...