Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sugar3.activity.iconify does not work #368

Closed
quozl opened this Issue Jul 3, 2017 · 11 comments

Comments

Projects
None yet
3 participants
@quozl
Copy link
Contributor

quozl commented Jul 3, 2017

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

This comment has been minimized.

Copy link
Contributor Author

quozl commented Jan 16, 2018

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

This comment has been minimized.

Copy link

amanharitsh123 commented Feb 7, 2018

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

This comment has been minimized.

Copy link
Contributor Author

quozl commented Feb 7, 2018

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

  • document the pattern of GTK+ calls made by an activity between the time the Gtk.Window is created, the iconify() call, and the first call to the GTK+ main loop,
  • reproduce this pattern in the GTK+ Hello World application,
  • find the part of the pattern that causes the problem.

Fix GTK+

  • test each version of GTK+ between 3.22.11 and 3.22.26, to find which version regressed,
  • use git bisect on GTK+ sources to find the commit which regressed,
  • report upstream,
@quozl

This comment has been minimized.

Copy link
Contributor Author

quozl commented Nov 21, 2018

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

This comment has been minimized.

Copy link
Contributor Author

quozl commented Nov 22, 2018

Dug further into this problem;

  • tried instrumenting all GLib.idle_add callbacks, none were used,
  • tried removing all use of SugarExt; no change,
  • tried excluding the shell as cause; kill -STOP of jarabe, reproduce, kill -CONT; no change,
  • tried calling Gtk.Widget.iconify in the window-state-event callback; a viable workaround,
  • tried a timing analysis; the state change from iconified to normal occurs roughly 244 ms after the window is realised,
  • tried instrumenting or disabling all GLib.timeout_add callbacks, none were related,
  • tried excluding sugar-activity by adding the minimum necessary code to the tail of the activity main file; no change,
  • reviewed commits to GTK+ between 3.22.11 and 3.22.15, none of the 133 commits related to the problem,
  • tried using GDK_DEBUG=events; several property notify events for window manager precede the problem, which hints at the window manager as cause,
  • tried suspending the window manager; kill -STOP of metacity, the reproducer no longer reproduced, which suggested strongly the window manager as cause,
  • researched and noted the problem began on the day that metacity 3.25.2 was released by GNOME and packaged for Ubuntu Artful,
  • reviewed all commits to metacity between 3.25.1 and 3.25.2, about 28 of them, and found the most likely to be "window: handle legacy fullscreen requests", which was a fix to GNOME Bugzilla 781946,
  • confirmed that --no-force-fullscreen option for metacity was in use by Sugar for a long time, and that the option was added by Sugar Labs as a workaround in ticket 602,
  • tested without --no-force-fullscreen option; problem with an activity that calls self.iconify() is resolved, problem with the Journal activity remains,
@quozl

This comment has been minimized.

Copy link
Contributor Author

quozl commented Nov 24, 2018

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

This comment has been minimized.

Copy link
Contributor Author

quozl commented Nov 26, 2018

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

This comment has been minimized.

Copy link

aperezbios commented Nov 26, 2018

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

This comment has been minimized.

Copy link

aperezbios commented Nov 26, 2018

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

This comment has been minimized.

Copy link
Contributor Author

quozl commented Nov 26, 2018

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

  • 3.25.1 does reproduce,
  • 3.24.1 does not reproduce,

quozl added a commit to quozl/sugar that referenced this issue Nov 27, 2018

Journal - iconify again if Metacity misbehaves (RHBZ #1519042)
Journal covers Home View on startup when Metacity is 3.25.1 or later,
isolated to Metacity 6875256 ("unminimize windows with initial
IconicState if first known on MapRequest").

Detect the window state event where ICONIFIED is cleared without any
action by the user.  Repeat the iconify request.

Has side-effect of showing a Metacity iconify animation, but this is
better than not fixing it.

Fixes sugarlabs#769

Fixes sugarlabs/sugar-toolkit-gtk3#368

Tested on Fedora 18 and Ubuntu 16.04; does not trigger.

Tested on Ubuntu 18.04; does trigger.
@quozl

This comment has been minimized.

Copy link
Contributor Author

quozl commented Nov 29, 2018

@quozl quozl closed this Nov 29, 2018

quozl added a commit to sugarlabs/sugar that referenced this issue Nov 29, 2018

Journal - iconify again if Metacity misbehaves (RHBZ #1519042)
Journal covers Home View on startup when Metacity is 3.25.1 or later,
isolated to Metacity 6875256 ("unminimize windows with initial
IconicState if first known on MapRequest").

Detect the window state event where ICONIFIED is cleared without any
action by the user.  Repeat the iconify request.

Has side-effect of showing a Metacity iconify animation, but this is
better than not fixing it.

Fixes #769

Fixes sugarlabs/sugar-toolkit-gtk3#368

Tested on Fedora 18 and Ubuntu 16.04; does not trigger.

Tested on Ubuntu 18.04; does trigger.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.