source: trunk/third/startup-notification/test/test-launchee.c @ 18723

Revision 18723, 2.3 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18722, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * Copyright (C) 2002 Red Hat, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person
5 * obtaining a copy of this software and associated documentation
6 * files (the "Software"), to deal in the Software without
7 * restriction, including without limitation the rights to use, copy,
8 * modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25#include <config.h>
26#include <libsn/sn.h>
27
28#include "test-boilerplate.h"
29
30int
31main (int argc, char **argv)
32{
33  Display *xdisplay;
34  SnDisplay *display;
35  SnLauncheeContext *context;
36 
37  xdisplay = XOpenDisplay (NULL);
38  if (xdisplay == NULL)
39    {
40      fprintf (stderr, "Could not open display\n");
41      return 1;
42    }
43
44  if (getenv ("LIBSN_SYNC") != NULL)
45    XSynchronize (xdisplay, True);
46 
47  XSetErrorHandler (x_error_handler);
48 
49  display = sn_display_new (xdisplay,
50                            error_trap_push,
51                            error_trap_pop);
52
53  context = sn_launchee_context_new_from_environment (display,
54                                                      DefaultScreen (xdisplay));
55
56  if (context == NULL)
57    {
58      fprintf (stderr, "Failed to get launch feedback info from DESKTOP_LAUNCH_ID/DESKTOP_LAUNCH_WINDOW\n");
59      exit (1);
60    }
61
62  printf ("Launchee started with window ID \"%s\"\n",
63          sn_launchee_context_get_startup_id (context));
64
65  /* simulate startup time */
66  sleep (4);
67
68  printf ("Launchee startup complete\n");
69  sn_launchee_context_complete (context);
70 
71  while (TRUE)
72    {
73      XEvent xevent;
74
75      XNextEvent (xdisplay, &xevent);
76
77      sn_display_process_event (display, &xevent);
78    }
79 
80  return 0;
81}
Note: See TracBrowser for help on using the repository browser.