4

I'm not sure whether to ask this question on this site or on StackOverflow, because although this is programming related, I suspect that the behavior is influenced by the OS.

So I have decided to study creating software for Elementary OS, using the language and library they recommend -- Vala and GTK+.

The problem is, why is the GTK Window set default size function <GTKWindow>.set_default_size(w, h) not working the way it should be when running the program normally, whereas working correctly when running the program under elevated privileges (sudo).

Here's a screen capture to better explain the situation: enter image description here

Image: The program with the larger window is run with sudo, while the smaller one is run without sudo

The code, is fairly simple; I just copied it from Elementary OS development guide:

using Gtk;

//Program entry point.
int main (string[] args){
    Gtk.init (ref args);

    //Create GTK Window.
    var window = new Gtk.Window ();
    window.title = "Hello World! From Vala.";
    window.set_position (Gtk.WindowPosition.CENTER);
    window.set_default_size (550, 450);
    window.destroy.connect (Gtk.main_quit);

    window.show_all ();

    Gtk.main ();

    return 0;
}

The window's client area is (444, 318) without su, and (550, 450) if under su.

Anyone who can explain why is happening? How can I make the default size correct even without su?

3
  • Yep it seems related to eOS, just tried in Ubuntu 15.10, got exactly same size. I could reproduce same case in a VirtualBox Elementary OS freya.
    – user.dz
    Jan 1, 2016 at 16:34
  • I see, thank you for your help. So should I report this as a bug to the developers of eOS? Jan 1, 2016 at 19:09
  • 1
    It does not seems like a bug, but it either an env variable or setting file in /home/user folder. If you try sudo -u youruser ./yourprogram has different size the running it directly. I will try investigate more.
    – user.dz
    Jan 1, 2016 at 19:19

3 Answers 3

3

One of these windows is using client-side decorations and the other is using sever-side decorations. There is a bug right now where client-side decorations include the shadow as part of the window geometry. Which technically it is, but the toolkit should compensate.

Starting in Loki (because of the newer libmutter version), all windows will be drawn with this client-side decoration method. There will no longer be a configuration option. We decided to opt-in early in Freya, but the configuration option is only set for regular user accounts.

1
  • This explains the behavior of the two windows. I also tried it with other applications, and some are affected by this bug. Is there any workaround I can do to get the correct window geometry under client-side decoration? Thank you very much. Jan 2, 2016 at 13:02
1

I found the effective env variable: GTK_CSD=1 , you can verify:

  • sudo GTK_CSD=1 ./yourprogram
  • GTK_CSD="" ./yourprogram

The GTK Client-Side Decorations enabled by:

$ sudo grep -r GTK_CSD /etc/
/etc/profile.d/gtk-csd.sh:export GTK_CSD=1

$ dpkg -S /etc/profile.d/gtk-csd.sh
elementary-default-settings: /etc/profile.d/gtk-csd.sh

I didn't notice such size issue in the other desktops, you probably right about submiting a bug report.

1
  • 1
    Interesting. I tried executing the program with the commands you've given and yup, it is indeed affected by the env variable GTK_CSD=1. I hope there's another workaround until it is fixed. Thank you very much. Jan 2, 2016 at 12:34
-2

This isn't a elementary OS bug. It happen when you haven't child widgets into your window.

Try adding :

window.set_resizable (false);
1
  • I also tried that. The size worked correctly under elevated privileges but not when run normally, so not having child widgets should not be a problem at all. Thanks for the help. Jan 2, 2016 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.