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 333129 - [Multihead] cannot launch multiple instances of gedit on different heads
[Multihead] cannot launch multiple instances of gedit on different heads
Status: VERIFIED FIXED
Product: gedit
Classification: Applications
Component: general
2.13.x
Other opensolaris
: Normal normal
: 2.14.0
Assigned To: Gedit maintainers
Gedit maintainers
Depends on:
Blocks:
 
 
Reported: 2006-03-02 13:41 UTC by robert.kinsella
Modified: 2006-03-22 17:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
This patch is a first step toward fixing the problem reported in this bug report (4.25 KB, patch)
2006-03-02 18:39 UTC, Paolo Maggi
needs-work Details | Review
patch (8.19 KB, patch)
2006-03-03 12:02 UTC, Paolo Borelli
needs-work Details | Review
patch (8.61 KB, patch)
2006-03-03 14:55 UTC, Paolo Borelli
none Details | Review
update bindings (1.94 KB, patch)
2006-03-03 15:40 UTC, Paolo Borelli
none Details | Review

Description robert.kinsella 2006-03-02 13:41:01 UTC
Origanlly filed as 
http://bugzilla.gnome.org/show_bug.cgi?id=91976
logging new bug to track issue in gnome2.13.

Testcase 1
Select applications, accessories, text editor on screen 0.
gedit is launched.
on screen 1 select applications, accessories, text editor.
A new instalce of gedit is launched on screen 0.

Testcase 2
Open gedit on screen1, 
goto screen 2 type gedit --new-window
expected result:-
gedit should open on screen 2
actual result
gedit opens on screen 1
Similarly
(first close all gedit windows)
Open Gedit on screen2
goto screen 1, type gedit --new-window
Expected result
gedit launches on screen1
actual result
gedit launches on screen2
Comment 1 Paolo Borelli 2006-03-02 15:14:05 UTC
Ouch! This is going to be tricky. None of the current developers have the possibility to test a multiscreen setup :(

Beside the solution adopted in the 'old' bug is not really applicable IMHO (it was broken in the first place): having two gedit applications running (I don't mean toplevel windows, I mean two gedit processes) is going to lead to other problems, for instance the corruption of the metadata file which would be written by both processes without locking.
Comment 2 Paolo Borelli 2006-03-02 15:19:45 UTC
<pbor> is there a way to know the GdkScreen an app has been launched in?
<pbor> and, as a side question, can a window be moved from a screen to another?
<matthias> pbor: just get the screen of your main window ? Or do you mean from the outside ?
<matthias> pbor: regarding moving between screens/displays, see gtk-demo
<pbor> matthias: I mean on startup... I don't have a window yet
<pbor> thinking how to solve http://bugzilla.gnome.org/show_bug.cgi?id=333129 
<pbor> I need a way to decide on which screen to create the new window
<matthias> pbor: Xnest -scrns 2 gives you a multiscreen setup...
<matthias> pbor: whats wrong with just gedit --display :0.2  ?
<pbor> (good point about xnest)
<pbor> matthias: well it should work also when launching from the menu or clicking on a file
<matthias> pbor: doesn't do xinerama though, which is a pity
<matthias> pbor: in that case, you need support from the launching app, ie the panel/nautilus, I think
<matthias> pbor: they need to specify the screen
<pbor> that's what I feared...
<matthias> gtk really has no data beyond whats in DISPLAY
<pbor> does startup-notification already provide that info?
<pbor> ok, thanks
<pbor> I'll investigate
Comment 3 Paolo Maggi 2006-03-02 15:34:55 UTC
I know it is not a real solution but IMHO we should:
- launch multiple gedit instances (as we did)
- add file locking to metadata and hope for the best (in the worst case scenario, there could be case where we will lose some metadata, but this is not a critical problem).

In this case we will avoid regressions.
Does SJ or totem support multihead?

Comment 4 Paolo Borelli 2006-03-02 15:39:20 UTC
I'd prefer to try to fix it for good: it seems that startup-notification should pass us the SCREEN=N
Comment 5 Paolo Borelli 2006-03-02 15:54:02 UTC
grr... should check my facts before writing :(

This is what I get in the env var when launching gedit by clicking on a panel launcher

gnome-panel/gedit/4894-26-murdock_TIME3148144093

no SCREEN is sight :/
Comment 6 Paolo Maggi 2006-03-02 18:39:09 UTC
Created attachment 60511 [details] [review]
This patch is a first step toward fixing the problem reported in this bug report

The patch still needs some work.
In particular it should modify the code so that gedit create a new window when
no window exists in the current workspace of the screen where the client has been launched.
Comment 7 Paolo Borelli 2006-03-03 12:02:42 UTC
Created attachment 60555 [details] [review]
patch

this patch (totally untested!) should do the right thing with regard to selecting an existing window on the current workspace of the current screen.

Note that the app_create_window() function now takes a screen arg, so if this is ok we'll also need to update the bindings
Comment 8 Paolo Maggi 2006-03-03 13:41:11 UTC
Comment on attachment 60555 [details] [review]
patch


> GeditWindow *
>-gedit_app_create_window (GeditApp *app)
>+gedit_app_create_window (GeditApp  *app,
>+			 GdkScreen *screen)
> {

I don't think we should change gedit_app_create_window.

>
> 
>+static gboolean
>+is_in_workspace (GeditWindow *window,
>+		 GdkScreen   *screen,
>+		 gint         workspace)
>+{
>+	GdkScreen *s;
>+	gint ws;
>+
>+	s = gtk_window_get_screen (GTK_WINDOW (window));
>+	ws = gedit_utils_get_window_workspace (GTK_WINDOW (window));
>+
>+	return (s == screen &&  //CHECK: can we compare pointers or should we compare number/name?

Well, I don't know and so I think it is safer compare numbers and names.

Have you tested the patch in the "normal" case ? I mean in the single screen case.
Comment 9 Paolo Borelli 2006-03-03 14:55:05 UTC
Created attachment 60567 [details] [review]
patch

after a bit of discussion we decided that modifing create_window is acceptable, so that the whole multiscreen issue is wrapped in the GeditApp class.

I was also told that comparing screen pointers was ok, but when I tried it didn't seem to work, so here I strcmp the display name and the screen number.
Comment 10 Paolo Borelli 2006-03-03 15:40:12 UTC
Created attachment 60574 [details] [review]
update bindings

updated binding from create_window(), overridden so that the screen param is optional
Comment 11 Paolo Maggi 2006-03-03 16:31:36 UTC
Patch committed.

Robert: could you please confirm it fixes the problem for you (we have not a real multihead configuration to test it).
Comment 12 Christian Persch 2006-03-03 19:45:59 UTC
Just FYI, gedit's copy of ephy-spinner isn't multihead-safe.
Comment 13 Paolo Borelli 2006-03-03 21:48:10 UTC
Thanks for the heads-up Christian. I overcome my lazyness and synced the code to latest ephy-spinner.
Comment 14 robert.kinsella 2006-03-06 12:40:09 UTC
I will test the fix for this bug within the next couple of weeks
Comment 15 Paolo Borelli 2006-03-06 12:44:40 UTC
Thank you Robert.

Note that we released gedit 2.13.93 which includes the fix.
Comment 16 robert.kinsella 2006-03-22 17:42:20 UTC
this bug is verified fix on gedit 2.14, it is now possible to open gedit on both heads of a dual head display, thank you