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:
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?
env
variable or setting file in/home/user
folder. If you trysudo -u youruser ./yourprogram
has different size the running it directly. I will try investigate more.