Bug 297801 - konsole does not always honor '--display'
Summary: konsole does not always honor '--display'
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: single-process (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-09 20:15 UTC by jcwoods
Modified: 2012-08-16 13:38 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.9.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jcwoods 2012-04-09 20:15:21 UTC
I have two screens (:0.0 and :0.1) on two physical monitors.  When I run "konsole --display :0.0" or "konsole --display :0.1" from an existing konsole, I can open a new konsole on the desired screen.

I have created two new menu items using kmenuedit called "konsole :0.0" and "konsole :0.1" so that I can easily launch a new konsole on either screen from a menu shortcut.  The desktop shortcuts for these look like this:

$ cat ~/.local/share/applications/konsole.desktop
[Desktop Entry]
Comment=
Exec=/usr/bin/konsole --display :0.0 
GenericName=Terminal
Icon=utilities-terminal
Name=Konsole :0.0
NoDisplay=false
Path[$e]=
StartupNotify=true
Terminal=0
TerminalOptions=
Type=Application
X-DBUS-StartupType=Unique
X-DocPath=konsole/index.html
X-KDE-AuthorizeAction=shell_access
X-KDE-StartupNotify=true
X-KDE-SubstituteUID=false
X-KDE-Username=


and


$ cat ~/.local/share/applications/konsole-2.desktop 
[Desktop Entry]
Comment=/home/jxw82/scripts/konsole-0.1.sh
Exec=/usr/bin/konsole --display :0.1
GenericName=Terminal
Icon=utilities-terminal
Name=Konsole :0.1
NoDisplay=false
Path[$e]=
StartupNotify=true
Terminal=0
TerminalOptions=
Type=Application
X-DBUS-StartupType=Unique
X-DocPath=konsole/index.html
X-KDE-AuthorizeAction=shell_access
X-KDE-StartupNotify=true
X-KDE-SubstituteUID=false
X-KDE-Username=


When I use either of these menu items, the konsole will display on the active display REGARDLESS of the "--display" setting in the "Exec=" line.  For instance, if I use the K-menu on screen 0:0 to launch the "Konsole 0.1" shortcut, the konsole appears on :0.0.

In troubleshooting this issue, I've gone as far as writing scripts to wrap the launching of konsole with bash and capture and/or manipulate the environment:


$ cat konsole-0.0.sh
#!/bin/bash

env | sort > /tmp/konsole-0.0.$$
exec /usr/bin/konsole --display :0.0

$ cat konsole-0.1.sh
#!/bin/bash

env | sort > /tmp/konsole-0.1.$$
exec /usr/bin/konsole --display :0.1


As before, everything works when I run these scripts from the command line.  When I add these scripts as menu entries and launch them from the menu, they do not work (konsole pops up on wrong screen).

Diff'ing the environment files generated by these scripts show there are a handful of differences.  I've modified the scripts to unset and/or modify the values which do not match, but I get the same result.

This may not be a problem with konsole itself, but I don't know how to dig further.  Could it be an issue with the kde launcher?  What can I do to gather additional diagnostic information?
Comment 1 Jekyll Wu 2012-04-10 04:21:53 UTC
Thanks for reporting.

Your problem sounds quite similar to or related with bug 297224.  See comment #1 in that bug report for why Konsole behave differently when started from a terminal emulator.

"For instance, if I use the K-menu on screen 0:0 to launch the "Konsole 0.1" shortcut, the konsole appears on :0.0." 

When you do that, is there any konsole already running on :0.0 ?
Comment 2 jcwoods 2012-04-10 12:26:53 UTC
Redirecting stdout to /dev/null does allow me to reproduce the problem from the command line. "konsole --display :0.1" will always start a new konsole on :0.1 when run in a konsole on screen :0.0.   "konsole --display :0.1 >/dev/null" will not start a konsole on :0.1 when run in a konsole on :0.0.

Interestingly, if I have no konsole processes running on any screen, the "konsole :0.0" and "konsole :0.1" shortcuts will always work as expected.  If I have a konsole on :0.0, the "konsole :0.1" shortcut will never launch on :0.1.  Likewise, if I only have a konsole running on :0.1, I cannot launch a konsole on :0.0 from the shortcut.
Comment 3 Jekyll Wu 2012-04-10 13:03:38 UTC
(In reply to comment #2)
> Redirecting stdout to /dev/null does allow me to reproduce the problem from
> the command line. "konsole --display :0.1" will always start a new konsole
> on :0.1 when run in a konsole on screen :0.0.   "konsole --display :0.1
> >/dev/null" will not start a konsole on :0.1 when run in a konsole on :0.0.
> 
> Interestingly, if I have no konsole processes running on any screen, the
> "konsole :0.0" and "konsole :0.1" shortcuts will always work as expected. 
> If I have a konsole on :0.0, the "konsole :0.1" shortcut will never launch
> on :0.1.  Likewise, if I only have a konsole running on :0.1, I cannot
> launch a konsole on :0.0 from the shortcut.

Thanks for your feedback.

So that is the "expected buggy behavior". The thing is just that Konsole tries to keep all opened konsole windows running in the same process, which in turn means all those konsole windows are shown on the same display(more precisely, the display where the first konsole window opened through menu/icon/shortcut is shown)

That "single process" model makes sense most of time, but clearly not when user has specified the --display option. The logical behavior should be always creating a new process to make sure the new konsole window are shown on the specified dispaly.

Unfortunately, currently Konsole simply does not check and treat --display option in a special way.  Actually there are  other Qt options which do not work well with this "single process" model, like --session, --reverse, --graphicssystem, etc. 

So to sum it up, this is a known issue. I will try to do something to improve this situation in KDE SC 4.9 .
Comment 4 Jekyll Wu 2012-04-20 07:35:35 UTC
Git commit 6b811ec2b6e4fbf459af9765c9ead506c9a0cd3c by Jekyll Wu.
Committed on 18/04/2012 at 10:04.
Pushed by jekyllwu into branch 'master'.

Konsole should use new process when some Qt/KDE options are given

One typical option is "--display", because two konsole windows
belonging to the same process are destined to be shown in the same
display, which defeats the purpose of the "--display" option
Related: bug 179010, bug 297224
FIXED-IN: 4.9.0
REVIEW: 104653

M  +28   -0    src/main.cpp

http://commits.kde.org/konsole/6b811ec2b6e4fbf459af9765c9ead506c9a0cd3c
Comment 5 jcwoods 2012-04-20 11:42:25 UTC
While this is certainly an improvement, is this going to break collaberation between processes within a display?

For instance, I launch (using the shortcut in K-menu at the top of this bug) two konsole processes on display :0.1.  Because each was launched with the '--display' flag -- even though they are both to the same screen -- they will run as two separate processes.  Will I still be able to do things like dragging a tab between two windows (now in two different processes)?
Comment 6 Jekyll Wu 2012-04-20 12:27:43 UTC
(In reply to comment #5)
> While this is certainly an improvement, is this going to break collaberation
> between processes within a display?
> 
> For instance, I launch (using the shortcut in K-menu at the top of this bug)
> two konsole processes on display :0.1.  Because each was launched with the
> '--display' flag -- even though they are both to the same screen -- they
> will run as two separate processes.  Will I still be able to do things like
> dragging a tab between two windows (now in two different processes)?

Unfortunately, dragging tab between two processes is impossible.