Example #1
0
void init_X11() {
    server.dsp = XOpenDisplay(NULL);
    if (!server.dsp) DIE("tint: could not open display.");

    server_init_atoms();
    server.screen = DefaultScreen(server.dsp);
    server.root_win = RootWindow(server.dsp, server.screen);
    server.desktop = server_get_current_desktop();
    server_init_visual();
    XSetErrorHandler((XErrorHandler)server_catch_error);

#ifdef HAVE_SN
    // Initialize startup-notification
    server.sn_dsp = sn_display_new(server.dsp, error_trap_push, error_trap_pop);
    server.pids = g_tree_new(cmp_ptr);
    // Setup a handler for child termination
    struct sigaction act;
    memset(&act, 0, sizeof(struct sigaction));
    act.sa_handler = sigchld_handler;
    if (sigaction(SIGCHLD, &act, 0)) {
        perror("sigaction");
    }
#endif  // HAVE_SN

    imlib_context_set_display(server.dsp);
    imlib_context_set_visual(server.visual);
    imlib_context_set_colormap(server.colormap);

    /* Catch events */
    XSelectInput(server.dsp, server.root_win,
                 PropertyChangeMask | StructureNotifyMask);

    setlocale(LC_ALL, "");
    // config file use '.' as decimal separator
    setlocale(LC_NUMERIC, "POSIX");

    // load default icon
    gchar* path;
    const gchar* const* data_dirs;
    data_dirs = g_get_system_data_dirs();
    int i;
    for (i = 0; data_dirs[i] != NULL; i++) {
        path = g_build_filename(data_dirs[i], "tinto", "default_icon.png", NULL);
        if (g_file_test(path, G_FILE_TEST_EXISTS))
            default_icon = imlib_load_image(path);
        g_free(path);
    }

    // get monitor and desktop config
    get_monitors();
    get_desktops();
}
Example #2
0
void
tinto_init_x11 (void) {
  server.dsp = XOpenDisplay (getenv ("DISPLAY"));
  if (!server.dsp)
    DIE ("%s Failed to open display.", PROJECT_NAME);

  server_init_atoms ();
  server.screen = DefaultScreen (server.dsp);
  server.root_win = RootWindow (server.dsp, server.screen);
  server.desktop = server_get_current_desktop ();

  // config file use '.' as decimal separator
  setlocale (LC_ALL, "");
  setlocale (LC_NUMERIC, "POSIX");

  // get monitor and desktop config
  get_monitors ();
  get_desktops ();

  server.disable_transparency = 0;

  server_init_visual ();

  imlib_context_set_display (server.dsp);
  imlib_context_set_visual (server.visual);
  imlib_context_set_colormap (server.colormap);

  /* Catch events */
  XSelectInput (server.dsp, server.root_win,
		PropertyChangeMask | StructureNotifyMask);

  gchar *path;
  const gchar * const *data_dirs = g_get_system_data_dirs ();
  for (size_t i = 0; data_dirs[i] != NULL; ++i)	{
    path = g_build_filename (data_dirs[i], "tint2", "icon.png", NULL);
    if (g_file_test (path, G_FILE_TEST_EXISTS))
      default_icon = imlib_load_image (path);

    g_free (path);
  }
}