Can SciTE grab window-focus when a file is dragged in?

63 views
Skip to first unread message

Byron Hawkins

unread,
Sep 9, 2012, 8:10:43 PM9/9/12
to scite-i...@googlegroups.com
I'm using SciTE with the Nautilus file browser (on Ubuntu), so my normal process for opening a file is to drag it in from the Nautilus window. But the SciTE window does not take focus, so I am constantly sending keystrokes to Nautilus, thinking they will go to SciTE. For example, often I look at a file for 3 seconds and then press ctrl+w to close it--only to have the Nautilus window disappear! :-( Is there some command from lua that can switch focus to SciTE whenever any buffer is opened? Thanks for your help.

Byron

Neil Hodgson

unread,
Sep 9, 2012, 11:49:15 PM9/9/12
to scite-i...@googlegroups.com
Byron Hawkins:

> Is there some command from lua that can switch focus to SciTE whenever any buffer is opened?

Due to applications grabbing focus too greedily in the past, the general rule now is to leave focus management to the environment.

You could try changing the C++ drop code to call gtk_window_present.

Neil

Jeff Pohlmeyer

unread,
Sep 10, 2012, 11:48:38 AM9/10/12
to scite-i...@googlegroups.com
On Sun, Sep 9, 2012 at 7:10 PM, Byron Hawkins <by...@hawkinssoftware.net> wrote:

> Is there some command from lua that can switch focus
> to SciTE whenever any buffer is opened?


You can try my "xctrl" module for Lua:
http://code.google.com/p/xctrl/



And then add something like this to your startup script:

-------------------------------

require "xctrl"

local xc=xctrl.new()


function OnOpen()
for i,win in ipairs(xc:get_win_list())
do
if (xc:get_win_class(win)=="SciTE.SciTE")
then
xc:activate_win(win)
break
end
end
end

-------------------------------

Should work as long as you only have one instance of SciTE
running, otherwise it might need some tweaking.


- Jeff

Jim

unread,
Oct 5, 2012, 12:16:40 AM10/5/12
to scite-i...@googlegroups.com
I'm fighting the same focus problem in GTK3+.  It seems the Gnome community want us to spend most of the day clicking windows to get them up front.  wmctrl doesn't work with my setup.  What function was changed from SciTE 2.29 to 3.00 that now causes SciTE to "play nice," for I'd like to revert that logic?

Details follow (for those that are interested):
I was originally using SciTE 2.28, which would dutifully pop forward when I would edit a file from the command-line (I'm using multi-buffers).  The update to 3.22 broke this.  I'm not as familiar with GTK as I am with QT, so bear with me.  You say to use the "gtk_window_present" command, which I see is still present in the code.  Where is this "drop code" area that I need to employ this.  Better yet, just let me know which function I need to modify so that I can diff between 2.29 and 3.00 and see where I need to make the change.  Is it in Scintilla or SciTE?

I tried the wmctrl hack, but I access the server through Exceed on my Windows work machine.  wmctrl can not even see the SciTE window (wmctrl -l only shows desktop and panel widgets).  So, it looks like my best option is to modify the SciTE source and re-compile.  Besides, a text editor is often called from a shell, so "playing nice" with Gnome's bizarre windows policy is counter-productive to how a programmer works with a text editor anyways.  At the very least, I'd like to see if I can add a compiler option.  Any help would be greatly appreciated!

- Jim

Neil Hodgson

unread,
Oct 5, 2012, 12:50:06 AM10/5/12
to scite-i...@googlegroups.com
Jim:

> I'm fighting the same focus problem in GTK3+. It seems the Gnome community want us to spend most of the day clicking windows to get them up front. wmctrl doesn't work with my setup. What function was changed from SciTE 2.29 to 3.00 that now causes SciTE to "play nice," for I'd like to revert that logic?

I don't think that a recent change in SciTE or Scintilla caused SciTE to "play nice". The last significant work in this area was in 2007 for SciTE 1.76.
http://scintilla.hg.sourceforge.net/hgweb/scintilla/scite/rev/bba9916efeea
Its possible I've overlooked something but I expect its a change to GTK+, your window manager, or the preferences set for your environment.

Neil

James Sorenson

unread,
Oct 5, 2012, 1:44:25 AM10/5/12
to scite-i...@googlegroups.com
Neal:

Thanks for your fast response on this.  I do recall that some version 1.7x had this issue,awhile back, but a change was put in to resolve that (possibly what you have posted).  My issue is that the move from 2.29 to 3.x has changed how SciTE works whence called from the xterm command line when using the "check.if.already.open" flag.  When I send a file to SciTE, it will flash in the menubar, but will not come forward.  I know that this is a "feature" of Gnome 3.x, but I also know that many applications can still be "rude" and pop up on top anyways (including SciTE 2.29, which is what I want from a text editor).

Now that I think about it, one change is that you switched from GDK to CAIRO.  It may be because I updated GTK long after I had compiled SciTE 2.29.  I bet if I re-compile 2.29 of SciTE, then it will now have the same focus issue since it would now link to the newer libraries.  Unfortunately, you've phased out GDK, so I may be stuck with trying to find a solution within GNOME or continue using the old version of SciTE.

Crimonies...this is why Linux has not toppled Windows or Mac...

---
Jim





   Neil

--
You received this message because you are subscribed to the Google Groups "scite-interest" group.
To post to this group, send email to scite-i...@googlegroups.com.
To unsubscribe from this group, send email to scite-interes...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/scite-interest?hl=en.


Reply all
Reply to author
Forward
0 new messages