diff options
author | Havoc Pennington <hp@redhat.com> | 2002-10-23 18:05:14 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2002-10-23 18:05:14 +0000 |
commit | 35e4a1f3a786c0697a70f8b9b08144ad46b47cd0 (patch) | |
tree | 97af85eca95a39bc12145c7f8cfeaa895c31d11d | |
parent | b52fcb46f8dd697cb4219c70d93ff63d17eb072b (diff) |
implement type_atom_begin stuff
add the idea of "type_atom_begin" to distinguish the first client message
in an X message.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | doc/startup-notification.txt | 35 | ||||
-rw-r--r-- | libsn/sn-launchee.c | 1 | ||||
-rw-r--r-- | libsn/sn-launcher.c | 1 | ||||
-rw-r--r-- | libsn/sn-monitor.c | 1 | ||||
-rw-r--r-- | libsn/sn-xmessages.c | 50 | ||||
-rw-r--r-- | libsn/sn-xmessages.h | 2 |
7 files changed, 56 insertions, 41 deletions
@@ -1,3 +1,10 @@ +2002-10-23 Havoc Pennington <hp@redhat.com> + + * libsn/sn-xmessages.c: implement type_atom_begin stuff + + * doc/startup-notification.txt: add the idea of "type_atom_begin" + to distinguish the first client message in an X message. + 2002-10-22 Havoc Pennington <hp@redhat.com> * doc/startup-notification.txt: fixes from Lubos diff --git a/doc/startup-notification.txt b/doc/startup-notification.txt index b919c83..5e16fba 100644 --- a/doc/startup-notification.txt +++ b/doc/startup-notification.txt @@ -26,25 +26,27 @@ clients. To send a string as an X message, a client does the following: - - Creates an X window to be used to identify the message - uniquely. This window need not be mapped, and may be + - Creates an X window to be used to identify the message + uniquely. This window need not be mapped, and may be a child of any window. - - Interns an atom type_atom indicating the type of message. + - Interns atoms type_atom and type_atom_begin indicating + the type of message. - - Decides on a target_xwindow; this is the root window + - Decides on a target_xwindow; this is the root window for "broadcast" messages, or a specific client's window. - Send a series of client messages to the target X window, where each client message contains a portion of the string. The client - messages should have the message_type field set to the type of - message, the window field set to the X window identifying the - message, and the format field set to 8. + messages should have the window field set to the X window + identifying the message, the format field set to 8, and + the message_type field set to the type of message, type_atom_begin + for the first client message and type_atom for any following client + messages. - The first byte in the first client message must be nul, and the - last byte used in the last client message must also be nul. No - intermediate bytes may be nul. The nul bytes identify the beginning - and end of the message. + The last byte used in the last client message must be nul, and no + intermediate bytes may be nul. The nul byte identifies + the end of the message. Client messages must be sent to the chosen target_xwindow, with the event mask PropertyChangeMask. @@ -153,9 +155,10 @@ Startup notification === The startup notification protocol involves sending X messages with the -message_type atom _NET_STARTUP_INFO to the root window. In multihead -setups, the messages should go to the root window of the X screen -where the launchee application is being launched. +message_type atom _NET_STARTUP_INFO_BEGIN/_NET_STARTUP_INFO to the +root window. In multihead setups, the messages should go to the root +window of the X screen where the launchee application is being +launched. As a general convention, any key-value pairs in startup notification messages that aren't understood by a given client should be ignored by @@ -345,7 +348,7 @@ this code and destroyed just after. char *dest_end; xevent.xclient.type = ClientMessage; - xevent.xclient.message_type = type_atom; + xevent.xclient.message_type = type_atom_begin; xevent.xclient.display = xdisplay; xevent.xclient.window = xwindow; xevent.xclient.format = 8; @@ -377,4 +380,6 @@ this code and destroyed just after. False, PropertyChangeMask, xevent); + + xevent.xclient.message_type = type_atom_begin; } diff --git a/libsn/sn-launchee.c b/libsn/sn-launchee.c index bdf9ab3..fdb5ae4 100644 --- a/libsn/sn-launchee.c +++ b/libsn/sn-launchee.c @@ -151,6 +151,7 @@ sn_launchee_context_complete (SnLauncheeContext *context) sn_internal_broadcast_xmessage (context->display, context->screen, "_NET_STARTUP_INFO", + "_NET_STARTUP_INFO_BEGIN", message); sn_free (message); diff --git a/libsn/sn-launcher.c b/libsn/sn-launcher.c index c206863..35771c5 100644 --- a/libsn/sn-launcher.c +++ b/libsn/sn-launcher.c @@ -266,6 +266,7 @@ sn_launcher_context_initiate (SnLauncherContext *context, sn_internal_broadcast_xmessage (context->display, context->screen, "_NET_STARTUP_INFO", + "_NET_STARTUP_INFO_BEGIN", message); sn_free (message); diff --git a/libsn/sn-monitor.c b/libsn/sn-monitor.c index e38d10c..ed0426d 100644 --- a/libsn/sn-monitor.c +++ b/libsn/sn-monitor.c @@ -129,6 +129,7 @@ sn_monitor_context_new (SnDisplay *display, sn_internal_add_xmessage_func (display, screen, "_NET_STARTUP_INFO", + "_NET_STARTUP_INFO_BEGIN", xmessage_func, NULL, NULL); diff --git a/libsn/sn-xmessages.c b/libsn/sn-xmessages.c index 794e86f..c86db27 100644 --- a/libsn/sn-xmessages.c +++ b/libsn/sn-xmessages.c @@ -31,6 +31,7 @@ typedef struct Display *xdisplay; Window root; Atom type_atom; + Atom type_atom_begin; char *message_type; SnXmessageFunc func; void *func_data; @@ -39,7 +40,7 @@ typedef struct typedef struct { - Atom type_atom; + Atom type_atom_begin; Window xwindow; char *message; int allocated; @@ -52,6 +53,7 @@ void sn_internal_add_xmessage_func (SnDisplay *display, int screen, const char *message_type, + const char *message_type_begin, SnXmessageFunc func, void *func_data, SnFreeFunc free_data_func) @@ -66,8 +68,9 @@ sn_internal_add_xmessage_func (SnDisplay *display, handler->xdisplay = sn_display_get_x_display (display); handler->root = RootWindow (handler->xdisplay, screen); handler->type_atom = sn_internal_atom_get (display, message_type); + handler->type_atom_begin = sn_internal_atom_get (display, message_type_begin); handler->message_type = sn_internal_strdup (message_type); - handler->func= func; + handler->func = func; handler->func_data = func_data; handler->free_data_func = free_data_func; @@ -136,9 +139,11 @@ void sn_internal_broadcast_xmessage (SnDisplay *display, int screen, const char *message_type, + const char *message_type_begin, const char *message) { Atom type_atom; + Atom type_atom_begin; Window xwindow; Display *xdisplay; @@ -171,6 +176,7 @@ sn_internal_broadcast_xmessage (SnDisplay *display, } type_atom = sn_internal_atom_get (display, message_type); + type_atom_begin = sn_internal_atom_get (display, message_type_begin); { XEvent xevent; @@ -180,7 +186,7 @@ sn_internal_broadcast_xmessage (SnDisplay *display, char *dest_end; xevent.xclient.type = ClientMessage; - xevent.xclient.message_type = type_atom; + xevent.xclient.message_type = type_atom_begin; xevent.xclient.display = xdisplay; xevent.xclient.window = xwindow; xevent.xclient.format = 8; @@ -191,14 +197,7 @@ sn_internal_broadcast_xmessage (SnDisplay *display, while (src != src_end) { dest = &xevent.xclient.data.b[0]; - dest_end = dest + 20; - - if (src == message) - { - /* first byte is nul */ - *dest = '\0'; - ++dest; - } + dest_end = dest + 20; while (dest != dest_end && src != src_end) @@ -213,6 +212,8 @@ sn_internal_broadcast_xmessage (SnDisplay *display, False, PropertyChangeMask, &xevent); + + xevent.xclient.message_type = type_atom; } } @@ -236,7 +237,8 @@ handler_for_atom_foreach (void *value, HandlerForAtomData *hfad = data; if (handler->xdisplay == hfad->xdisplay && - handler->type_atom == hfad->atom) + (handler->type_atom == hfad->atom || + handler->type_atom_begin == hfad->atom)) { hfad->found_handler = TRUE; return FALSE; @@ -278,8 +280,7 @@ find_message_foreach (void *value, SnXmessage *message = value; FindMessageData *fmd = data; - if (fmd->xevent->xclient.window == message->xwindow && - fmd->xevent->xclient.message_type == message->type_atom) + if (fmd->xevent->xclient.window == message->xwindow) { fmd->message = message; return FALSE; @@ -315,12 +316,10 @@ add_event_to_messages (SnDisplay *display, if (message == NULL) { - if (xevent->xclient.data.b[0] != '\0') /* if no nul byte, not a start */ - return NULL; message = sn_new0 (SnXmessage, 1); - message->type_atom = xevent->xclient.message_type; + message->type_atom_begin = xevent->xclient.message_type; message->xwindow = xevent->xclient.window; message->message = NULL; message->allocated = 0; @@ -330,7 +329,7 @@ add_event_to_messages (SnDisplay *display, sn_list_prepend (pending_messages, message); } - + if (message->allocated > MAX_MESSAGE_LENGTH) { /* This message is some kind of crap - just dump it. */ @@ -342,9 +341,6 @@ add_event_to_messages (SnDisplay *display, src = &xevent->xclient.data.b[0]; src_end = src + 20; - - if (message->message == NULL) - ++src; /* skip initial nul byte */ message->message = sn_realloc (message->message, message->allocated + (src_end - src)); @@ -390,11 +386,13 @@ dispatch_message_foreach (void *value, { SnXmessageHandler *handler = value; MessageDispatchData *mdd = data; - - (* handler->func) (mdd->display, - handler->message_type, - mdd->message->message, - handler->func_data); + + if (handler->type_atom_begin == mdd->message->type_atom_begin && + sn_display_get_x_display (mdd->display) == handler->xdisplay) + (* handler->func) (mdd->display, + handler->message_type, + mdd->message->message, + handler->func_data); return TRUE; } diff --git a/libsn/sn-xmessages.h b/libsn/sn-xmessages.h index 080a970..c2174e6 100644 --- a/libsn/sn-xmessages.h +++ b/libsn/sn-xmessages.h @@ -37,6 +37,7 @@ typedef void (* SnXmessageFunc) (SnDisplay *display, void sn_internal_add_xmessage_func (SnDisplay *display, int screen, const char *message_type, + const char *message_type_begin, SnXmessageFunc func, void *func_data, SnFreeFunc free_data_func); @@ -48,6 +49,7 @@ void sn_internal_remove_xmessage_func (SnDisplay *display, void sn_internal_broadcast_xmessage (SnDisplay *display, int screen, const char *message_type, + const char *message_type_begin, const char *message); char* sn_internal_serialize_message (const char *prefix, |