Hi,
Am Donnerstag, den 02.02.2006, 22:41 -0200 schrieb Felipe Monteiro de
Carvalho:
> Ok, The problem was about giving enougth time for the window to show at
> least once.
You aren't supposed to either... there's something else interfering...
Can you use a GtkPlug instead of a normal window? I get the feeling that
normal forms do strange extra stuff... no, scratch that, I'm _pretty
sure_ that normal forms do strange extra stuff that system trays don't
particularily like.
for testing do something like that in CreateForm:
icon := gtk_plug_new(0);
g_signal_connect(icon, "realize", realize_cb); // [1]
label := gtk_label_new("foobar");
gtk_widget_show(label);
gtk_container_add(icon, label);
gtk_widget_show(icon);
--
(also, try to react on the realize signal of the icon to dock it (which
is the earliest point in it's life where it has a X window). [1])
procedure realize_cb(icon: PGtkWidget; userdata: gpointer); cdecl;
var
gdk_screen: PGdkScreen;
begin
fDisplay := GDK_WINDOW_XDISPLAY(icon^.window));
fWindow := GDK_WINDOW_XWINDOW(icon^.window));
gdk_screen := gtk_widget_get_screen(icon);
fScreen := GDK_SCREEN_XSCREEN(gdk_screen); // get the real screen
// fScreen := XDefaultScreenOfDisplay(fDisplay); // get the screen
fScreenID := XScreenNumberOfScreen(fScreen); // and it's number
tray opcode (... SYSTEM_TRAY_REQUEST_DOCK,
gtk_plug_get_id(icon)...);
end;
> Now it works 100% of the time on KDE, but for it to happen I
> had to move that Sleep(80) to CreateForm() .
well, it works with a workaround, you mean :)
As a general note, most functions that "take some time" in gtk are
asynchronous, in that you can't expect the action to be done by the time
the next statement is executed. Instead you have to react on a signal
(i.e. event) to do the next step.
The stuff currently done within CreateForm() is way too much.
it should:
- create the form
- set size (before showing the form)
- show the form
(END!)
The reason to keep it short is that the form is not shown (and not
realized) immediately.
This is also why the weird processmessage/sleep stuff is needed
otherwise (and NOT needed when done with signals :))
these:
------------
fDisplay :=
GDK_WINDOW_XDISPLAY(Pointer(PGtkWidget(GtkForm.Handle)^.window));
fWindow :=
GDK_WINDOW_XWINDOW(Pointer(PGtkWidget(GtkForm.Handle)^.window));
fScreen := XDefaultScreenOfDisplay(fDisplay); // get the screen
fScreenID := XScreenNumberOfScreen(fScreen); // and it's number
-----------
things belong into realize_cb. The SetEmbedded call _definitely_ doesn't
belong into TWidgetTrayIcon.Show either, but into realize_cb.
On the other hand, I'm not sure why the CreateForm is only called so
late (in Show). Why not call it at the beginning?
> On the other hand, on IceWM instead of my icon, I see some random colors
> painted and it doesn't respond to mouse events.
>
> On Gnome I get a 1x1 pixels Tray Icon.
A side effect of using a form (i.e. a real window) instead of a
gtk_plug, I suppose... is the tray icon visible in an external window
instead in any of these cases?
>
> Any idea???
>
> I am attaching the new source.
>
> thanks,
>
> Felipe
>
cheers,
Danny
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives