sugarlabs / sugar-toolkit-gtk3

Sugar Learning Environment, Activity Toolkit, GTK 3.
GNU Lesser General Public License v2.1
21 stars 80 forks source link

sugar3.activity.iconify does not work #368

Closed quozl closed 4 years ago

quozl commented 7 years ago

On Ubuntu 17.10 Artful the Gtk.Window.iconify method called by an activity during __init__ does not result in the activity starting hidden. Works in previous versions. Unaffected GTK+ 3.22.11, affected GTK+ 3.22.15.

quozl commented 6 years ago

May be specific to the Sugar Toolkit, as it does not occur with Python GTK+ alone.

Test case: the Sugar Hello World activity.

Add to the end of __init__ a call to self.iconify() and start the activity; result should be window not displayed. Incorrect behaviour on Ubuntu 18.04 with GTK+ 3.22.26.

Test case: the GTK+ Hello World application

Add a call to iconify() and start; result should be window not displayed. Correct behaviour on Ubuntu 18.04 with GTK+ 3.22.26.

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

class MyWindow(Gtk.Window):

    def __init__(self):
        Gtk.Window.__init__(self, title="Hello World")

        self.button = Gtk.Button(label="Click Here")
        self.button.connect("clicked", self.on_button_clicked)
        self.add(self.button)

    def on_button_clicked(self, widget):
        print("Hello World")

win = MyWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
win.iconify()
Gtk.main()
amanharitsh123 commented 6 years ago

I was going through https://github.com/sugarlabs/sugar/blob/master/src/jarabe/journal/journalactivity.py What if we call self.iconify() before showing the window, I changed it in the journalactivity.py file. Although it didn't fix the issue, but I am wondering if there is another file where we can make this change.

P.S: "It’s permitted to call this function before showing a window, in which case the window will be iconified before it ever appears onscreen." I found this on Gnome Reference Guide. https://developer.gnome.org/gtk3/stable/GtkWindow.html#gtk-window-iconify

quozl commented 6 years ago

Thanks, good try, but as you can see in the GTK+ Hello World application test case above it doesn't matter when iconify() is called, as long as it is called before Gtk.main().

Given that the GTK+ Hello World application test case does not reproduce, the approaches to solve this problem include;

Understand Sugar Toolkit

Fix GTK+

quozl commented 5 years ago

Instrumented an activity and the Toolkit and iterated through several tests. Two window-state-event occur when the Gtk.main() begins, the first changing the state from nothing to Gdk.WindowState.FOCUSED | Gdk.WindowState.ICONIFIED, and the second changing the state to just Gtk.WindowState.FOCUSED. So the cause seems likely to be something that happens after the main loop begins processing events, idles, or timeouts.

A possible workaround might be to call iconify() again in response to the window-state-event.

quozl commented 5 years ago

Dug further into this problem;

quozl commented 5 years ago

Caused by upgrade of metacity from 3.24.0 to 3.25.2, git bisect shows first bad commit is unminimize windows with initial IconicState if first known on MapRequest ported from mutter.

quozl commented 5 years ago

Some testing done with a possible patch to force Journal to iconify when Metacity misbehaves and Metacity debugging flags; META_DEBUG=verbose in .sugar/default/debug. Result is that Journal does not cover home view, but an animated sequence of rectangles is shown by Metacity to indicate Journal is iconified. Logs.

aperezbios commented 5 years ago

Has this been tested by anyone using Top-of-Trunk Metacity? It's possible the bug (if they consider it one) has already been fixed there. The most recent release of Metacity is 3.30.1, which was released on September 9th of this year.

aperezbios commented 5 years ago

Also, I noticed at https://bodhi.fedoraproject.org/updates/metacity-3.30.1-1.fc29 that there is a testing build/RPM of metacity 3.30.1 for FC29.

quozl commented 5 years ago

Yes, I tested Metacity HEAD as of 24th November on Ubuntu 18.04 and it reproduced the bug. Also;

quozl commented 5 years ago

Fixed in https://github.com/GNOME/metacity/commit/074af8f87ef89b13ff326fb5d04ee424bbfd4ced

quozl commented 5 years ago

It's back, under certain conditions. https://github.com/sugarlabs/sugar-toolkit-gtk3/pull/413.