Steve Donovan wrote (in a private response to my previous email):
> That looks good, Nicolas!  You ask in the source:
> // We would have a Unix-equivalent to $(WindowID)
> ScitePM would already like us to create a property x11.windowid
> so it can bring SciTE to the front if necessary. That seems
> straightforward; there's a GDK macro for getting that from the
> main widget:
>
> #include <gdk/gdkx.h>
>
> Window w = GDK_WINDOW_XWINDOW(widget);

That's not what I meant by a Unix-equivalent to $(WindowID). I
meant an equivalent for the use of the Director interface, not
from the perspective of the OS or of the windowing system.

WindowID is useful to start a Director from a particular SciTE 
instance, as exemplified in the documentation by this:

command.name.0.*=Project Editor
command.0.*="C:\os\scite\bin\filerx.exe" "$(FileDir)" "$(WindowID)"
command.subsystem.0.*=2

This starts filerx and tells it which instance it is supposed to
talk to. The X window ID isn't useful for this purpose, what a 
director started from SciTE would need is the name of the pipe
SciTE is listening to. We could simply call this $(PipeName)

As for the ability to front SciTE, I'm almost done with the 
implementation of a "focus:" message.

As Neil mentionned in a previous email, we should be careful 
about this. Activating (the word X uses for that, i.e. giving a 
window the focus and raising it above the others) can be really 
annoying for a user, for example if a window is suddenly 
activated while we were doing something else.

To avoid that, we have to use timestamps. When we ask a window 
to be fronted, we give the X server timestamp of the user action 
that caused the actions leading to the activation. The window 
manager will then decide whether to front the window or not, 
depending whether the user activated another window since that 
action. If it doesn't activate the window, it might give an
indication that the window asked to be fronted (e.g. in Gnome, 
using Metacity, the button will flash in the task bar) [1].

So I've decided that the Director command would be "focus:time",
time being an X server time stamp. Note that it isn't the usual 
timestamp defined as "the number of seconds since epoch". It is:
  "A timestamp is a time value, expressed in milliseconds.
  It typically is the time since the last server reset."
    (From the X Window System Protocol specification [2])

Where to get that from? Remember we need to get the timestamp of 
the last user action, so we don't force the window to be fronted.
In a GTK+ application, you can get the timestamp of an event 
with gdk_event_get_time(). For example in a project manager, I 
might select several files and click a button "Open". The 
program would them send several "open:" command to SciTE and at 
the end a "focus:" message with the timestamp of the button
click. If I haven't done anything since, SciTE will be fronted 
by the window manager.

For the single instance code, I'm going to use something else, 
since there is no button anybody clicked on. When you start a
program by opening a file in Nautilus (in Gnome, but it's the
same in KDE as far as I know) or by lauching it from the menu, a
.desktop file [3] is used. If this file specifies
StartupNotification=true, then an environment variable called
DESKTOP_STARTUP_ID is set which contains a _TIME string followed
by the timestamp we need [4]. Unfortunately, this variable is
unset by gtk_init(), which means I need to store it before it is 
called.

Therefore I have the following problem: how should I pass this 
to CheckForRunningInstance() which is inside a class that is 
instanciated later? Would it be okay if I just added an argument
to SciTEGTK::Run()?

That's it about the focus: message for now. I should have some 
space on a web server soon, so I'll not have to worry about file 
size and wait because the mailing list thinks they're might be a 
virus in my emails, and will post some code.

Doesn't anyone have some comments about my remarks in 
DirectorExtension.cxx? Steve, you only commented on one of them.

Nicolas

_______________________________________________
Scite-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scite-interest

Reply via email to