9 static Atom net_sel_atom
;
10 static Atom net_manager_atom
;
11 static Atom net_message_data_atom
;
13 /* defined in the systray spec */
14 #define SYSTEM_TRAY_REQUEST_DOCK 0
15 #define SYSTEM_TRAY_BEGIN_MESSAGE 1
16 #define SYSTEM_TRAY_CANCEL_MESSAGE 2
18 static void net_create_selection_window()
20 net_sel_win
= XCreateSimpleWindow(display
, root
, -1, -1, 1, 1, 0, 0, 0);
25 static void net_destroy_selection_window()
27 XDestroyWindow(display
, net_sel_win
);
37 name
= g_strdup_printf("_NET_SYSTEM_TRAY_S%d", DefaultScreen(display
));
38 net_sel_atom
= XInternAtom(display
, name
, False
);
40 net_opcode_atom
= XInternAtom(display
, "_NET_SYSTEM_TRAY_OPCODE", False
);
41 assert(net_opcode_atom
);
42 net_manager_atom
= XInternAtom(display
, "MANAGER", False
);
43 assert(net_manager_atom
);
44 net_message_data_atom
= XInternAtom(display
, "_NET_SYSTEM_TRAY_MESSAGE_DATA",
46 assert(net_message_data_atom
);
48 net_create_selection_window();
50 XSetSelectionOwner(display
, net_sel_atom
, net_sel_win
, CurrentTime
);
51 if (XGetSelectionOwner(display
, net_sel_atom
) != net_sel_win
)
52 return; /* we don't get the selection */
54 m
.type
= ClientMessage
;
55 m
.xclient
.message_type
= net_manager_atom
;
56 m
.xclient
.format
= 32;
57 m
.xclient
.data
.l
[0] = CurrentTime
;
58 m
.xclient
.data
.l
[1] = net_sel_atom
;
59 m
.xclient
.data
.l
[2] = net_sel_win
;
60 m
.xclient
.data
.l
[3] = 0;
61 m
.xclient
.data
.l
[4] = 0;
62 XSendEvent(display
, root
, False
, StructureNotifyMask
, &m
);
68 net_destroy_selection_window();
72 void net_message(XClientMessageEvent
*e
)
79 opcode
= e
->data
.l
[1];
83 case SYSTEM_TRAY_REQUEST_DOCK
: /* dock a new icon */
85 if (id
&& icon_add(id
, NET
))
86 XSelectInput(display
, id
, StructureNotifyMask
);
89 case SYSTEM_TRAY_BEGIN_MESSAGE
:
90 g_printerr("Message From Dockapp\n");
94 case SYSTEM_TRAY_CANCEL_MESSAGE
:
95 g_printerr("Message Cancelled\n");
100 if (opcode
== net_message_data_atom
) {
101 g_printerr("Text For Message From Dockapp:\n%s\n", e
->data
.b
);
106 /* unknown message type. not in the spec. */
107 g_printerr("Warning: Received unknown client message to System Tray "
108 "selection window.\n");
114 void net_icon_remove(TrayWindow
*traywin
)
118 XSelectInput(display
, traywin
->id
, NoEventMask
);