diff options
author | Mark McLoughlin <mark@skynet.ie> | 2004-06-24 08:32:38 +0000 |
---|---|---|
committer | Mark McLoughlin <mark@skynet.ie> | 2004-06-24 08:32:38 +0000 |
commit | 5c4f61420dd0fd02484b2f5144bab32314f16534 (patch) | |
tree | 62d57203c07371ad4039ca131c4d23c3d8f918a9 | |
parent | 24120023bc2cf7282639ec532029bc83634c1cd2 (diff) | |
download | startup-notification-5c4f61420dd0fd02484b2f5144bab32314f16534.tar.gz |
Make a timestamp be part of the startup sequence (and not just part of the
startup_id for the startup sequence).
Add timestamp field to the SnLauncherContext struct,
(sn_launcher_context_new): initialize timestamp to 0,
(sn_launcher_context_initiate): Make timestamp part of the startup
sequence message,
Add timestamp field to the SnStartupSequence struct,
(sn_startup_sequence_get_timestamp): new function,
(sn_startup_sequence_new): set timestamp from startup sequence message,
if found,
new function,
new function (main): Make the test-launcher example provide a valid
timestamp, obtained from new slowly_obtain_timestamp function
-rw-r--r-- | ChangeLog | 25 | ||||
-rw-r--r-- | libsn/sn-launcher.c | 11 | ||||
-rw-r--r-- | libsn/sn-monitor.c | 17 | ||||
-rw-r--r-- | libsn/sn-monitor.h | 1 | ||||
-rw-r--r-- | test/test-launcher.c | 62 |
5 files changed, 113 insertions, 3 deletions
@@ -1,3 +1,28 @@ +2004-06-17 Elijah Newren <newren@math.utah.edu> + + Make a timestamp be part of the startup sequence (and not just + part of the startup_id for the startup sequence). + + * libsn/sn-launcher.c: Add timestamp field to the + SnLauncherContext struct, + (sn_launcher_context_new): initialize timestamp to 0, + (sn_launcher_context_initiate): Make timestamp part of the startup + sequence message, + + * libsn/sn-monitor.c: Add timestamp field to the SnStartupSequence + struct, + (sn_startup_sequence_get_timestamp): new function, + (sn_startup_sequence_new): set timestamp from startup sequence + message, if found, + + * libsn/sn-monitor.h: + (sn_startup_sequence_get_timestamp): new function, + + * test/test-launcher.c: + (slowly_obtain_timestamp): new function + (main): Make the test-launcher example provide a valid timestamp, + obtained from new slowly_obtain_timestamp function + 2004-04-01 Mark McLoughlin <mark@skynet.ie> * configure.in: post-release bump to 0.7. diff --git a/libsn/sn-launcher.c b/libsn/sn-launcher.c index 2707ccc..8bd6fc9 100644 --- a/libsn/sn-launcher.c +++ b/libsn/sn-launcher.c @@ -41,6 +41,7 @@ struct SnLauncherContext char *name; char *description; int workspace; + Time timestamp; char *wmclass; char *binary_name; char *icon_name; @@ -80,6 +81,7 @@ sn_launcher_context_new (SnDisplay *display, sn_display_ref (context->display); context->workspace = -1; + context->timestamp = 0; sn_list_prepend (context_list, context); @@ -177,6 +179,7 @@ sn_launcher_context_initiate (SnLauncherContext *context, char *values[MAX_PROPS]; char *message; char workspacebuf[257]; + char timestampbuf[257]; char screenbuf[257]; if (context->startup_id != NULL) @@ -209,7 +212,8 @@ sn_launcher_context_initiate (SnLauncherContext *context, sn_free (canonicalized_launcher); sn_free (canonicalized_launchee); - + + context->timestamp = timestamp; context->startup_id = s; i = 0; @@ -223,6 +227,11 @@ sn_launcher_context_initiate (SnLauncherContext *context, values[i] = screenbuf; ++i; + names[i] = "TIMESTAMP"; + sprintf (timestampbuf, "%lu", context->timestamp); + values[i] = timestampbuf; + ++i; + if (context->name != NULL) { names[i] = "NAME"; diff --git a/libsn/sn-monitor.c b/libsn/sn-monitor.c index 63940de..b4d4ff8 100644 --- a/libsn/sn-monitor.c +++ b/libsn/sn-monitor.c @@ -63,6 +63,7 @@ struct SnStartupSequence char *wmclass; int workspace; + Time timestamp; char *binary_name; char *icon_name; @@ -303,6 +304,12 @@ sn_startup_sequence_get_workspace (SnStartupSequence *sequence) return sequence->workspace; } +Time +sn_startup_sequence_get_timestamp (SnStartupSequence *sequence) +{ + return sequence->timestamp; +} + const char* sn_startup_sequence_get_wmclass (SnStartupSequence *sequence) { @@ -422,6 +429,7 @@ sn_startup_sequence_new (SnDisplay *display) sequence->screen = -1; /* not set */ sequence->workspace = -1; /* not set */ + sequence->timestamp = 0; sequence->initiation_time.tv_sec = 0; sequence->initiation_time.tv_usec = 0; @@ -783,6 +791,15 @@ xmessage_func (SnDisplay *display, sequence->workspace = workspace; changed = TRUE; } + else if (strcmp (names[i], "TIMESTAMP") == 0) + { + Time timestamp; + + timestamp = sn_internal_string_to_ulong (values[i]); + + sequence->timestamp = timestamp; + changed = TRUE; + } else if (strcmp (names[i], "WMCLASS") == 0) { if (sequence->wmclass == NULL) diff --git a/libsn/sn-monitor.h b/libsn/sn-monitor.h index 3f0cb74..15a38d7 100644 --- a/libsn/sn-monitor.h +++ b/libsn/sn-monitor.h @@ -69,6 +69,7 @@ sn_bool_t sn_startup_sequence_get_completed (SnStartupSequence *se const char* sn_startup_sequence_get_name (SnStartupSequence *sequence); const char* sn_startup_sequence_get_description (SnStartupSequence *sequence); int sn_startup_sequence_get_workspace (SnStartupSequence *sequence); +Time sn_startup_sequence_get_timestamp (SnStartupSequence *sequence); const char* sn_startup_sequence_get_wmclass (SnStartupSequence *sequence); const char* sn_startup_sequence_get_binary_name (SnStartupSequence *sequence); const char* sn_startup_sequence_get_icon_name (SnStartupSequence *sequence); diff --git a/test/test-launcher.c b/test/test-launcher.c index 053e84b..65a4cec 100644 --- a/test/test-launcher.c +++ b/test/test-launcher.c @@ -24,17 +24,74 @@ #include <config.h> #include <libsn/sn.h> +#include <assert.h> #include "test-boilerplate.h" static pid_t child_pid = 0; +/* This is a poor way to obtain a timestamp normally (one should be available + * to the app from the user clicking on a button or something), but such a + * method is not available for this simple test application. + */ +Time +slowly_obtain_timestamp (SnDisplay *display) +{ + Window xwindow; + Display *xdisplay; + XEvent event; + + xdisplay = sn_display_get_x_display (display); + + { + XSetWindowAttributes attrs; + Atom atom_name; + Atom atom_type; + char* name; + + attrs.override_redirect = True; + attrs.event_mask = PropertyChangeMask | StructureNotifyMask; + + xwindow = + XCreateWindow (xdisplay, + RootWindow (xdisplay, 0), + -100, -100, 1, 1, + 0, + CopyFromParent, + CopyFromParent, + CopyFromParent, + CWOverrideRedirect | CWEventMask, + &attrs); + + atom_name = XInternAtom (xdisplay, "WM_NAME", TRUE); + assert (atom_name != None); + atom_type = XInternAtom (xdisplay, "STRING", TRUE); + assert (atom_type != None); + + name = "Fake Window"; + XChangeProperty (xdisplay, + xwindow, atom_name, + atom_type, + 8, PropModeReplace, name, strlen (name)); + } + + XWindowEvent (xdisplay, + xwindow, + PropertyChangeMask, + &event); + + XDestroyWindow (xdisplay, xwindow); + + return event.xproperty.time; +} + int main (int argc, char **argv) { Display *xdisplay; SnDisplay *display; SnLauncherContext *context; + Time timestamp; if (argc < 2) { @@ -63,11 +120,12 @@ main (int argc, char **argv) sn_launcher_context_set_name (context, "Test Launch"); sn_launcher_context_set_description (context, "Launching a test program for libsn"); sn_launcher_context_set_binary_name (context, argv[1]); - + + timestamp = slowly_obtain_timestamp (display); sn_launcher_context_initiate (context, "test-launcher", argv[1], - CurrentTime); /* CurrentTime bad */ + timestamp); switch ((child_pid = fork ())) { |