After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 750384 - GtkDialog can not be moved when gtk_dialog_run from GtkListBox row-activated signal callback
GtkDialog can not be moved when gtk_dialog_run from GtkListBox row-activated ...
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
3.16.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2015-06-04 09:15 UTC by Leslie Zhai
Modified: 2015-06-08 12:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gnome-control-center display panel outputs dialog moveable (12.78 KB, patch)
2015-06-05 02:32 UTC, Leslie Zhai
none Details | Review
main: Push the current event on the stack at the very beginning (3.03 KB, patch)
2015-06-05 17:35 UTC, Rui Matos
none Details | Review
main: Push the current event on the stack before we start needing it (2.56 KB, patch)
2015-06-08 11:46 UTC, Rui Matos
committed Details | Review

Description Leslie Zhai 2015-06-04 09:15:24 UTC
Hi Gtk developers,

The best testcase is Gnome Control Center`s display panel, it is able to run 
$ gnome-control-center display
in your terminal to experience it, when clicked one row of the displays GtkListBox, it will show a dialog for setting resolution and rotation, but the dialog is ***NOT*** able to move by pressing and holding the header bar.

The row-activated signal callback is cc_display_panel_box_row_activated
https://git.gnome.org/browse/gnome-control-center/tree/panels/display/cc-display-panel.c?h=gnome-3-16#n2354

There is show_setup_dialog https://git.gnome.org/browse/gnome-control-center/tree/panels/display/cc-display-panel.c?h=gnome-3-16#n1991

But the 
$ gnome-control-center background 
is able to move the Wallpaper dialog.

And I also write some examples to test GtkDialog with GtkWindow button-press-event signal callback https://github.com/xiangzhai/leetcode/blob/master/src/gtk/hello-dlg.c#L12
 
and GtkComboBox changed signal callback https://github.com/xiangzhai/leetcode/blob/master/src/gtk/hello-combo.c#L74

In GtkWindow`s button-press-event signal callback, the dialog is able to move, but GtkComboBox, ***NOT*** able to move!

Regards,
Leslie Zhai
Comment 1 Matthias Clasen 2015-06-04 18:14:29 UTC
This is a side-effect of using gtk_dialog_run. I think this should be fixed in the control-center by not using gtk_dialog_run.
Comment 2 Leslie Zhai 2015-06-05 01:38:21 UTC
Hi Matthias,

Thanks for your reply!

Yes, I tested comment gtk_dialog_run https://github.com/xiangzhai/leetcode/blob/master/src/gtk/hello-combo.c#L107

It is ok now ;-)

Regards,
Leslie Zhai
Comment 3 Leslie Zhai 2015-06-05 02:32:02 UTC
Created attachment 304624 [details] [review]
gnome-control-center display panel outputs dialog moveable

As Matthias mentioned, gtk_dialog_run has a side effect, so I just removed the gtk_dialog_run, use gtk_widget_show_all instead, please pay some attention to my patch, thanks a lot!
Comment 4 Leslie Zhai 2015-06-05 03:14:46 UTC
Gnome Control Center`s display panel is able to move, and GtkComboBox popup menu`s ypos is correct ;-)

https://twitter.com/xiangzhai/status/606659795404218368
Comment 5 Leslie Zhai 2015-06-05 03:16:15 UTC
And about gnome-control-center display panel`s dialog GtkComboBox popup menu issue https://bugzilla.gnome.org/show_bug.cgi?id=750372 please have a look, thanks a lot!
Comment 6 Rui Matos 2015-06-05 17:35:13 UTC
(In reply to Matthias Clasen from comment #1)
> This is a side-effect of using gtk_dialog_run. I think this should be fixed
> in the control-center by not using gtk_dialog_run.

This used to work with gtk+ 3.14 though. I bisected it and came up with the following patch.
Comment 7 Rui Matos 2015-06-05 17:35:38 UTC
Created attachment 304665 [details] [review]
main: Push the current event on the stack at the very beginning

The changes in commit 13e22e20300b7312e52bba7d077fc7e231695fc1 made
_gtk_window_check_handle_wm_event() indirectly depend on
gtk_get_current_event_time() which relies on the current event being
available on the current_events stack.

Since the current event is only pushed on the stack afterwards we get
an invalid timestamp which breaks ewmh window moving.

This fixes the issue by pushing the current event before anything else
in gtk_main_do_event() and, as a byproduct, also fixes a potential
memory leak when we have a rewritten event and return early due to
_gtk_window_check_handle_wm_event() being TRUE.
Comment 8 Matthias Clasen 2015-06-06 22:06:16 UTC
Carlos, can you review this ?
Comment 9 Carlos Garnacho 2015-06-07 10:07:51 UTC
Comment on attachment 304665 [details] [review]
main: Push the current event on the stack at the very beginning

Nice catch Rui :). Note however that we replace entirely the event variable with our rewritten_event at:

https://git.gnome.org/browse/gtk+/tree/gtk/gtkmain.c#n1566

Pushing the event so early will maybe get you with the received event and gtk_get_current_event() being different. I agree with the approach, but the queueing should happen after that, and the gotos above turned back into plain returns. I guess the goto label might be better "cleanup" then if we're not using it on all return paths.
Comment 10 Leslie Zhai 2015-06-08 00:56:05 UTC
(In reply to Rui Matos from comment #6)
> (In reply to Matthias Clasen from comment #1)
> > This is a side-effect of using gtk_dialog_run. I think this should be fixed
> > in the control-center by not using gtk_dialog_run.
> 
> This used to work with gtk+ 3.14 though. I bisected it and came up with the
> following patch.

yes, gtk-3-14 branch worked ;-) I will try the master branch.
Comment 11 Leslie Zhai 2015-06-08 01:15:31 UTC
(In reply to Rui Matos from comment #7)
> Created attachment 304665 [details] [review] [review]
> main: Push the current event on the stack at the very beginning
> 
> The changes in commit 13e22e20300b7312e52bba7d077fc7e231695fc1 made
> _gtk_window_check_handle_wm_event() indirectly depend on
> gtk_get_current_event_time() which relies on the current event being
> available on the current_events stack.
> 
> Since the current event is only pushed on the stack afterwards we get
> an invalid timestamp which breaks ewmh window moving.
> 
> This fixes the issue by pushing the current event before anything else
> in gtk_main_do_event() and, as a byproduct, also fixes a potential
> memory leak when we have a rewritten event and return early due to
> _gtk_window_check_handle_wm_event() being TRUE.

cool, I have tried your patch for gtk-3-16 and master branch, it worked happily ;-)
Comment 12 Rui Matos 2015-06-08 11:46:28 UTC
Created attachment 304763 [details] [review]
main: Push the current event on the stack before we start needing it

--

(In reply to Carlos Garnacho from comment #9)

> Nice catch Rui :). Note however that we replace entirely the event
> variable with our rewritten_event at:

> https://git.gnome.org/browse/gtk+/tree/gtk/gtkmain.c#n1566

Ups, right

> Pushing the event so early will maybe get you with the received
> event and gtk_get_current_event() being different. I agree with the
> approach, but the queueing should happen after that, and the gotos
> above turned back into plain returns. I guess the goto label might
> be better "cleanup" then if we're not using it on all return paths.

Sure, done
Comment 13 Carlos Garnacho 2015-06-08 11:52:55 UTC
Comment on attachment 304763 [details] [review]
main: Push the current event on the stack before we start needing it

Now it looks good :)
Comment 14 Rui Matos 2015-06-08 12:26:05 UTC
   6ff49ee..d87769d  gtk-3-16 -> gtk-3-16
   3c1a2c8..ef93257  master -> master