コード例 #1
0
static void
window_opened_callback            (WnckScreen* ,
                                   WnckWindow* window,
                                   gpointer )
{
  g_print ("Window '%s' opened (pid = %d session_id = %s)\n",
           wnck_window_get_name (window),
           wnck_window_get_pid (window),
           wnck_window_get_session_id (window) ?
           wnck_window_get_session_id (window) : "none");

  g_signal_connect (G_OBJECT (window), "name_changed",
                    G_CALLBACK (window_name_changed_callback),
                    NULL);
  g_signal_connect (G_OBJECT (window), "state_changed",
                    G_CALLBACK (window_state_changed_callback),
                    NULL);
  g_signal_connect (G_OBJECT (window), "workspace_changed",
                    G_CALLBACK (window_workspace_changed_callback),
                    NULL);
  g_signal_connect (G_OBJECT (window), "icon_changed",
                    G_CALLBACK (window_icon_changed_callback),
                    NULL);
  g_signal_connect (G_OBJECT (window), "geometry_changed",
                    G_CALLBACK (window_geometry_changed_callback),
                    NULL);

}
コード例 #2
0
ファイル: main.c プロジェクト: Exel232/Configurations
static void continue_all(WnckScreen *screen)
{
	GList *window_l;
	for (window_l = wnck_screen_get_windows(screen); window_l != NULL; window_l = window_l->next) {
		WnckWindow *window = WNCK_WINDOW(window_l->data);
		int pid = wnck_window_get_pid(window);
		cont_pid(pid);
	}
}
コード例 #3
0
ファイル: gva-wnck.c プロジェクト: mbarnes/gnome-video-arcade
static void
wnck_window_opened_cb (WnckScreen *screen,
                       WnckWindow *window,
                       GvaProcess *process)
{
        GPid pid;

        /* XXX This is totally non-portable. */
        pid = (GPid) wnck_window_get_pid (window);

        /* XXX The process ID for SDLMAME windows currently comes back 0.
         *     We can use this as a heuristic for matching SDLMAME windows
         *     to SDLMAME processes.  But it's not perfect. */
        if (pid != gva_process_get_pid (process) && pid != 0)
                return;

        /*** From this point forward, assume we have a match. ***/

        /* Exchange the weak reference for a real reference. */
        g_object_weak_unref (
                g_object_ref (process), (GWeakNotify)
                wnck_weak_notify_cb, screen);

        /* Bind the referenced process to the window. */
        g_object_set_data_full (
                G_OBJECT (window), "process", process,
                (GDestroyNotify) g_object_unref);

        /* No need to be notified of new windows anymore. */
        g_signal_handler_disconnect (screen, window_opened_handler_id);
        window_opened_handler_id = 0;

        wnck_window_initialize (window);

        g_signal_connect (
                window, "geometry-changed",
                G_CALLBACK (wnck_window_timeout_reset), NULL);

        g_signal_connect (
                window, "state-changed",
                G_CALLBACK (wnck_window_timeout_reset), NULL);

        g_signal_connect (
                screen, "window-closed",
                G_CALLBACK (wnck_window_closed_cb), NULL);

        gva_main_cursor_normal ();
}
コード例 #4
0
static void
wnck_pid_read_resource_usage_no_cache (GdkDisplay        *gdisplay,
                                       gulong             pid,
                                       WnckResourceUsage *usage)
{
  Display *xdisplay;
  int i;

  xdisplay = GDK_DISPLAY_XDISPLAY (gdisplay);

  i = 0;
  while (i < ScreenCount (xdisplay))
    {
      WnckScreen *screen;
      GList *windows;
      GList *tmp;

      screen = wnck_screen_get (i);

      g_assert (screen != NULL);

      windows = wnck_screen_get_windows (screen);
      tmp = windows;
      while (tmp != NULL)
        {
          if (wnck_window_get_pid (tmp->data) == pid)
            {
              wnck_xid_read_resource_usage (gdisplay,
                                            wnck_window_get_xid (tmp->data),
                                            usage);

              /* stop on first window found */
              return;
            }

          tmp = tmp->next;
        }

      ++i;
    }
}
コード例 #5
0
ファイル: dh-base.c プロジェクト: BYC/geany-plugins
GtkWidget *
dh_base_get_window_on_current_workspace (DhBase *base)
{
        DhBasePriv *priv;

        g_return_val_if_fail (DH_IS_BASE (base), NULL);

        priv = GET_PRIVATE (base);

        if (!priv->windows) {
                return NULL;
        }

#ifdef GDK_WINDOWING_X11
        {
                WnckWorkspace *workspace;
                WnckScreen    *screen;
                GtkWidget     *window;
                GList         *windows, *w;
                GSList        *l;
                gulong         xid;
                pid_t          pid;

                screen = wnck_screen_get (0);
                if (!screen) {
                        return NULL;
                }

                workspace = wnck_screen_get_active_workspace (screen);
                if (!workspace) {
                        return NULL;
                }

                xid = 0;
                pid = getpid ();

                /* Use _stacked so we can use the one on top. */
                windows = wnck_screen_get_windows_stacked (screen);
                windows = g_list_last (windows);

                for (w = windows; w; w = w->prev) {
                        if (wnck_window_is_on_workspace (w->data, workspace) &&
                            wnck_window_get_pid (w->data) == pid) {
                                xid = wnck_window_get_xid (w->data);
                                break;
                        }
                }

                if (!xid) {
                        return NULL;
                }

                /* Return the first matching window we have. */
                for (l = priv->windows; l; l = l->next) {
                        window = l->data;

#if GTK_CHECK_VERSION (2,14,0)
                        if (GDK_WINDOW_XID (gtk_widget_get_window (window)) == xid) {
#else
                        if (GDK_WINDOW_XID (window->window) == xid) {
#endif
                                return window;
                        }
                }
        }

        return NULL;
#else
        return priv->windows->data;
#endif
}

GtkWidget *
dh_base_get_window (DhBase *base)
{
        GtkWidget *window;

        g_return_val_if_fail (DH_IS_BASE (base), NULL);

        window = dh_base_get_window_on_current_workspace (base);
        if (!window) {
                window = dh_base_new_window (base);
                gtk_window_present (GTK_WINDOW (window));
        }

        return window;
}