gtkd-developers/GtkD

GtkD Menus do not display properly on Windows

Opened this issue · 4 comments

When experimenting with the GtkD UI library, I created a simple window with a menu. The code for the menu is below:

class TopView : Box
{
   MainMenu theBar;

    this()
    {
        super(Orientation.VERTICAL,10);
        theBar = new MainMenu();
    
        packStart(theBar,false,false,0);
   }
}

class MainMenu : MenuBar
{
    private MenuItem fileItem;
    private FileMenu fileMenu;

    this()
    {
        super();

        fileItem = new MenuItem("File");
        fileMenu = new FileMenu();

        fileItem.setSubmenu(fileMenu);
        append(fileItem);
    }
}

class FileMenu : Menu
{
    private MenuItem exitItem;

    this()
    {
        super();

        exitItem = new MenuItem("Exit");
        exitItem.addOnActivate(&closeApp);
        append(exitItem);
    }

    private void closeApp(MenuItem anItem)
    {
        Main.quit();
    }
}

The window is displayed without problems and the menubar appears with the "File" item, but when I click on the "File" item, the menu with "Exit" does not appear under it. Regardless of where the main window is positioned, the menu with Exit appears at screen position 0,0!

In other words, the menu appears at the top left corner of my computer screen whenever I click on "File".

This only happens on Windows. I copied this same code to CentOS and recompiled it. The CentOS executable displayed the menus properly.

This is clearly a bug somewhere in the Windows version of Gtk. The only thing I am uncertain about is if the bug is in GtkD itself or if it is in the underlying Gtk Runtime.

Please let me know if I am reporting this in the right place. If I am not, please let me know where to report it.

This is clearly a bug somewhere in the Windows version of Gtk. The only thing I am uncertain about is if the bug is in GtkD itself or if it is in the underlying Gtk Runtime.

Try rewriting it in C. If it is still broken then it's indeed a problem in GTK.

However, always remember that widgets in gtk3 are invisible by default. I don't see you show() ing anything in your code.

baedert:

You don't see a show() because for brevity I left out the code I wrote for the main window. I only provided the code that created the menu. If I hadn't called a show() function the entire window wouldn't have appeared. Furthermore, the show() function should have no effect on where a menu is going to appear (assuming a correct implementation, of course).

Unfortunately, for various reasons I am unable to set up and test this using C/C++. The machine I am using is a company machine and I have neither the permission nor privilege to install anything other than the current D programming environment I am using.

The best people for testing this bug are GtkD developers, and possibly Gtk+ developers. I would like to report this bug to the Gtk folks, but it is unclear where I can go to do this. Do you know the proper place to report this bug?

For your edification, the code for the main window is below:

class MainWin : MainWindow
{
    this(string[] theArgs)
    {
        Main.init(theArgs);

        super("Test of Basic Window Components");
        setDefaultSize(800,600);

        add(new TopView());
        addOnDestroy(&closeApplication);
    }

    private void closeApplication(Widget theWidge)
    {
        Main.quit();
    }

    void runWindow()
    {
        showAll();import mainwin;
    }
}

From the code above, the creation and display of the window should be obvious:

void main(string[] args)
{
	    MainWin win = new MainWin(args);
    win.runWindow();
}

Do you know the proper place to report this bug?

Of course, that's https://gitlab.gnome.org/GNOME/gtk, but they will naturally ask you for a C reproducer anyway.

I learned more about this problem:

I have run this same code on another Windows machine, and the menu displays properly. Whatever this bug is, it seems to manifest on (so far) one specific Windows machine. It may not be in Gtk or GtkD, but in some Windows system DLL that the Gtk libraries interact with.

I do not have the resources to isolate where this bug is. The only way to figure this out is to go through the Gtk code, see what Windows system libraries are being called, and compare versions of that library on different Windows machines. If I get in situations where I have time to do this, I will do as much as I can. Until then, the only recourse is to not develop on the machine that doesn't do the display properly.