Using Windows 7, java 6. jedit 4.4.2 or daily 2012-03-08, the same effect.
When I switch from jedit to a command prompt (or whatever) and try to open a file in jedit like:
java -jar c:\program_files\jedit\jedit.jar -reuseview C:\temp\1\file.txt
I experience different kinds of focus problems depending on the windows and editor state:
1. jedit is maximized and an old file (which was active in jedit at this moment) is being opened:
no cursor, jedit window not focused (the taskbar blinks), keyboard not working
2. jedit is maximized and a new file (which was not opened in jedit at this moment) is being opened:
cursor blinks, jedit window not focused (the taskbar blinks), keyboard not working
3. jedit is minimized and an old file is being opened
no cursor, jedit window focused, keyboard not working; goto next text area make all ok (fired as a keyboard shortcut)
4. jedit is minimized and a new file is being opened
It is problematic as one cannot use the keyboard for opening new files from outside, but always has to click the editor with mouse to get it working.
Probably there are 2 different bugs here. 1-2 platform dependent, 3-4 maybe not. But let's concentrate on points 1-2 where the jedit application is not focused at all. In fact the command prompt window still has the focus, as it can be detected through Alt-Space, Properties. When the jedit application is correctly activated (3-4), one has an easy workaround with a keyboard shortcut. For points 1-2 there is also a workaround - minimize jedit before going to another application.
I did a quick look at EditServer.handleClient. There are operations there that may be responsible for the problems, but I stopped investigating at the moment. However having the above steps described may help in further work.
|Submitted||jarekczek - 2012-03-09 - 09:11:52z||Assigned||nobody|
|2012-03-09 - 13:31:48z
|I spent more time on it and that's how it works on Windows 7. OS prevents old applications
(contrary to new application windows) to steal the focus. Right, I had this problem
with excel too, when programatically generated worksheet didn't appear, only started
flashing on taskbar. So when the user doesn't want this safety feature they can switch
it off through the registry. Google for ForegroundLockTimeout, it's in registry under
HKCU\Control Panel\Desktop. Requires windows restart. I am happy with the setting
as it solves both my excel and jedit problems.
The question is: whether jedit should be so bigheaded to consider itself a more important application than others and steal the focus regardless of the os settings. If one thinks it should, then see:
The answer I linked to, after some modification, works for jedit.
Then the code is:
I tested and it works fine on Windows 7 (EditServer.handleClient).
A perfect solution would be to provide a check-box like:
"always focus invoked editor window, overriding os settings"
but personally I don't consider this necessary.
All these remarks are about 1-2, platform dependent problem. 3-4 should be a separate ticket, as it is something inside jedit.
|2012-03-09 - 13:45:40z
|Well, actually I haven't discovered nothing new. There is a switch I was dreaming
Turn it to true to override windows anti-focus-stealer. Slava designed it ages ago, but looks like shlomy also haven't noticed that, introducing alwaysOnTop hack.
Slava's original revisions which is probably the best: r4169
Shlomy windows hack: r18554, for #1510651