summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--doc/startup-notification.txt16
-rw-r--r--libsn/sn-launcher.c2
-rw-r--r--libsn/sn-monitor.c9
-rw-r--r--libsn/sn-xmessages.c34
-rw-r--r--libsn/sn-xmessages.h1
-rw-r--r--test/test-monitor.c14
-rw-r--r--test/test-watch-xmessages.c1
8 files changed, 48 insertions, 34 deletions
diff --git a/ChangeLog b/ChangeLog
index e787802..360f537 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
-2002-10-20 Havoc Pennington <hp@pobox.com>
+2002-10-21 Havoc Pennington <hp@pobox.com>
+
+ * doc/startup-notification.txt: Add "SCREEN" property, and note
+ that there may be a max message size.
* libsn/sn-xmessages.c (sn_internal_unserialize_message): fix the
escaping
diff --git a/doc/startup-notification.txt b/doc/startup-notification.txt
index 1939c19..8aad6ff 100644
--- a/doc/startup-notification.txt
+++ b/doc/startup-notification.txt
@@ -58,6 +58,10 @@ To send a string as an X message, a client does the following:
The window can be destroyed immediately, it is only used
for its window ID.
+Implementations may impose a maximum length of message they are
+willing to accept. Typically this length will be reasonably low,
+perhaps 4K of data.
+
Key-value strings
===
@@ -199,6 +203,10 @@ in either a "new" or a "changed" message:
for example, "Control Center" or "Untitled Document";
this name should be localized.
+ SCREEN
+
+ the X screen number the startup sequence is on
+
The following keys may be provided optionally in either a "new" or a
"changed" message:
@@ -213,10 +221,10 @@ The following keys may be provided optionally in either a "new" or a
DESKTOP
- the desktop on which the application should appear,
- counting from 0, as in _NET_WM_DESKTOP. However,
- this value should never override a _NET_WM_DESKTOP
- property.
+ the desktop on which the application should appear, counting
+ from 0, as in _NET_WM_DESKTOP. However, this value should
+ never override a _NET_WM_DESKTOP property. This desktop is
+ relative to the screen provided by the SCREEN key.
DESCRIPTION
diff --git a/libsn/sn-launcher.c b/libsn/sn-launcher.c
index 3e27d35..c206863 100644
--- a/libsn/sn-launcher.c
+++ b/libsn/sn-launcher.c
@@ -261,6 +261,8 @@ sn_launcher_context_initiate (SnLauncherContext *context,
(const char**) names,
(const char**) values);
+ printf ("Sending '%s'\n", message);
+
sn_internal_broadcast_xmessage (context->display,
context->screen,
"_NET_STARTUP_INFO",
diff --git a/libsn/sn-monitor.c b/libsn/sn-monitor.c
index c3f3f1a..e38d10c 100644
--- a/libsn/sn-monitor.c
+++ b/libsn/sn-monitor.c
@@ -45,7 +45,6 @@ struct SnMonitorEvent
SnMonitorEventType type;
SnMonitorContext *context;
SnStartupSequence *sequence;
- Window xwindow; /* where event occurred */
};
struct SnStartupSequence
@@ -79,7 +78,6 @@ static int next_sequence_serial = 0;
static void xmessage_func (SnDisplay *display,
const char *message_type,
- Window xwindow,
const char *message,
void *user_data);
@@ -223,7 +221,6 @@ sn_monitor_event_copy (SnMonitorEvent *event)
copy->sequence = event->sequence;
if (copy->sequence)
sn_startup_sequence_ref (copy->sequence);
- copy->xwindow = event->xwindow;
return copy;
}
@@ -570,7 +567,6 @@ unref_event_foreach (void *value,
static void
xmessage_func (SnDisplay *display,
const char *message_type,
- Window xwindow,
const char *message,
void *user_data)
{
@@ -626,7 +622,6 @@ xmessage_func (SnDisplay *display,
event->type = SN_MONITOR_EVENT_INITIATED;
event->context = NULL;
event->sequence = sequence; /* ref from add_sequence goes here */
- event->xwindow = xwindow;
sn_list_append (events, event);
}
@@ -696,7 +691,7 @@ xmessage_func (SnDisplay *display,
++i;
}
- if (changed)
+ if (changed && strcmp (prefix, "new") != 0)
{
SnMonitorEvent *event;
@@ -707,7 +702,6 @@ xmessage_func (SnDisplay *display,
event->context = NULL;
event->sequence = sequence;
sn_startup_sequence_ref (sequence);
- event->xwindow = xwindow;
sn_list_append (events, event);
}
@@ -723,7 +717,6 @@ xmessage_func (SnDisplay *display,
event->context = NULL;
event->sequence = sequence;
sn_startup_sequence_ref (sequence);
- event->xwindow = xwindow;
sn_list_append (events, event);
}
diff --git a/libsn/sn-xmessages.c b/libsn/sn-xmessages.c
index f5225db..794e86f 100644
--- a/libsn/sn-xmessages.c
+++ b/libsn/sn-xmessages.c
@@ -234,10 +234,9 @@ handler_for_atom_foreach (void *value,
{
SnXmessageHandler *handler = value;
HandlerForAtomData *hfad = data;
-
+
if (handler->xdisplay == hfad->xdisplay &&
- handler->type_atom == hfad->atom &&
- handler->root == hfad->xwindow)
+ handler->type_atom == hfad->atom)
{
hfad->found_handler = TRUE;
return FALSE;
@@ -278,11 +277,9 @@ 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->xevent->xclient.message_type == message->type_atom)
{
fmd->message = message;
return FALSE;
@@ -318,7 +315,9 @@ add_event_to_messages (SnDisplay *display,
if (message == NULL)
{
- /* Create a new message */
+ 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;
@@ -343,11 +342,14 @@ 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 + 20);
+ message->allocated + (src_end - src));
dest = message->message + message->allocated;
- message->allocated += 20;
+ message->allocated += (src_end - src);
completed = FALSE;
@@ -355,7 +357,7 @@ add_event_to_messages (SnDisplay *display,
while (src != src_end)
{
*dest = *src;
-
+
if (*src == '\0')
{
completed = TRUE;
@@ -391,7 +393,6 @@ dispatch_message_foreach (void *value,
(* handler->func) (mdd->display,
handler->message_type,
- mdd->message->xwindow,
mdd->message->message,
handler->func_data);
@@ -414,7 +415,7 @@ sn_internal_xmessage_process_event (SnDisplay *display,
if (some_handler_handles_event (display, xevent))
{
retval = TRUE;
-
+
message = add_event_to_messages (display, xevent);
}
break;
@@ -504,11 +505,12 @@ sn_internal_serialize_message (const char *prefix,
retval = NULL;
sn_internal_append_to_string (&retval, &len, prefix);
- sn_internal_append_to_string (&retval, &len, ": ");
+ sn_internal_append_to_string (&retval, &len, ":");
i = 0;
while (property_names[i])
{
+ sn_internal_append_to_string (&retval, &len, " ");
sn_internal_append_to_string (&retval, &len, property_names[i]);
sn_internal_append_to_string (&retval, &len, "=");
sn_internal_append_to_string_escaped (&retval, &len, property_values[i]);
@@ -595,7 +597,7 @@ unescape_string_inplace (char *str,
quoted = FALSE;
while (*s)
- {
+ {
if (escaped)
{
escaped = FALSE;
diff --git a/libsn/sn-xmessages.h b/libsn/sn-xmessages.h
index 57b933b..080a970 100644
--- a/libsn/sn-xmessages.h
+++ b/libsn/sn-xmessages.h
@@ -31,7 +31,6 @@ SN_BEGIN_DECLS
typedef void (* SnXmessageFunc) (SnDisplay *display,
const char *message_type,
- Window message_window,
const char *message,
void *user_data);
diff --git a/test/test-monitor.c b/test/test-monitor.c
index b6e40d2..ee64131 100644
--- a/test/test-monitor.c
+++ b/test/test-monitor.c
@@ -40,13 +40,21 @@ monitor_event_func (SnMonitorEvent *event,
switch (sn_monitor_event_get_type (event))
{
case SN_MONITOR_EVENT_INITIATED:
- printf ("Initiated sequence %s\n",
- sn_startup_sequence_get_id (sequence));
- /* FALL THRU */
case SN_MONITOR_EVENT_CHANGED:
{
const char *s;
+ if (sn_monitor_event_get_type (event) == SN_MONITOR_EVENT_INITIATED)
+ {
+ printf ("Initiated sequence %s\n",
+ sn_startup_sequence_get_id (sequence));
+ }
+ else
+ {
+ printf ("Changed sequence %s\n",
+ sn_startup_sequence_get_id (sequence));
+ }
+
s = sn_startup_sequence_get_id (sequence);
printf (" id %s\n", s ? s : "(unset)");
diff --git a/test/test-watch-xmessages.c b/test/test-watch-xmessages.c
index 3374f0e..75c55b6 100644
--- a/test/test-watch-xmessages.c
+++ b/test/test-watch-xmessages.c
@@ -32,7 +32,6 @@
static void
message_func (SnDisplay *display,
const char *message_type,
- Window xwindow,
const char *message,
void *user_data)
{