Exemple #1
0
/* Safely returns the bottom-most (root) window */
static WnckWindow *getRootWindow (WnckScreen *screen) {
	GList *winstack = wnck_screen_get_windows_stacked(screen);
	if (winstack)
		return winstack->data;
	else
		return NULL;
}
static WnckWindow *get_root_window (WnckScreen *screen)
{
    GList *winstack = wnck_screen_get_windows_stacked(screen);
    // we can't access data directly because sometimes we will get NULL or not desktop window
    if (winstack && wnck_window_get_window_type (winstack->data) == WNCK_WINDOW_DESKTOP)
        return winstack->data;
    else
        return NULL;
}
Exemple #3
0
/* Returns the highest maximized window */
static WnckWindow *getUpperMaximized (WTApplet *wtapplet) {	
	if (!wtapplet->prefs->only_maximized)
		return wtapplet->activewindow;
	
	GList *windows = wnck_screen_get_windows_stacked(wtapplet->activescreen);
	WnckWindow *returnwindow = NULL;

	while (windows && windows->data) {
		if (wnck_window_is_maximized(windows->data)) {
			// if(wnck_window_is_on_workspace(windows->data, wtapplet->activeworkspace))
			if (!wnck_window_is_minimized(windows->data))
				if (wnck_window_is_in_viewport(windows->data, wtapplet->activeworkspace))
					returnwindow = windows->data;
		}
		windows = windows->next;
	}
	 
	// start tracking the new umaxed window
	if (wtapplet->umaxedwindow) {
		if (g_signal_handler_is_connected(G_OBJECT(wtapplet->umaxedwindow), wtapplet->umaxed_handler_state))
			g_signal_handler_disconnect(G_OBJECT(wtapplet->umaxedwindow), wtapplet->umaxed_handler_state);
		if (g_signal_handler_is_connected(G_OBJECT(wtapplet->umaxedwindow), wtapplet->umaxed_handler_name))
			g_signal_handler_disconnect(G_OBJECT(wtapplet->umaxedwindow), wtapplet->umaxed_handler_name);
		if (g_signal_handler_is_connected(G_OBJECT(wtapplet->umaxedwindow), wtapplet->umaxed_handler_icon))
			g_signal_handler_disconnect(G_OBJECT(wtapplet->umaxedwindow), wtapplet->umaxed_handler_icon); 
	}
	if (returnwindow) {
		// maxed window was found
		wtapplet->umaxed_handler_state = g_signal_connect(G_OBJECT(returnwindow),
		                                             "state-changed",
		                                             G_CALLBACK (umaxed_window_state_changed),
		                                                  wtapplet);
		wtapplet->umaxed_handler_name = g_signal_connect(G_OBJECT(returnwindow),
		                                             "name-changed",
		                                             G_CALLBACK (umaxed_window_nameicon_changed),
		                                             wtapplet);		
		wtapplet->umaxed_handler_icon = g_signal_connect(G_OBJECT(returnwindow),
		                                             "icon-changed",
		                                             G_CALLBACK (umaxed_window_nameicon_changed),
		                                             wtapplet);	
		//return returnwindow;
	} else {
		// maxed window was not found
		returnwindow = wtapplet->rootwindow; //return wtapplet->rootwindow;
	}
	return returnwindow;
	// WARNING: if this function returns NULL, applet won't detect clicks!
}
static gboolean is_window_on_active_workspace_and_no_other_maximized_windows_above(WnckWindow *window)
{
    WnckWorkspace *workspace = wnck_window_get_workspace(window);
    WnckScreen *screen = wnck_workspace_get_screen(workspace);
    if (wnck_screen_get_active_workspace(screen) != workspace) {
        return FALSE;
    }
    GList *windows = wnck_screen_get_windows_stacked(screen);
    GList *top_window = g_list_last(windows);
    GList *bottom_window = g_list_first(windows);
    while (top_window->data != window && top_window != bottom_window) {
        if (wnck_window_is_maximized((WnckWindow *)top_window->data)) {
            return FALSE;
        }
        top_window = top_window->prev;
    }
    return TRUE;
}
/* Returns the highest maximized window */
static WnckWindow *get_upper_maximized (WckUtils *win)
{
    WnckWindow      *umaxedwindow = NULL;

    GList *windows = wnck_screen_get_windows_stacked(win->activescreen);

    while (windows && windows->data)
    {
        if (!win->activeworkspace
            || wnck_window_is_in_viewport(windows->data, win->activeworkspace))
            if (wnck_window_is_maximized(windows->data)
                && !wnck_window_is_minimized(windows->data))
        {
                umaxedwindow = windows->data;
        }
        windows = windows->next;
    }
    /* NULL if no maximized window found */
    return umaxedwindow;
}
Exemple #6
0
static void wibuti_watcher_find_window(WibutiWatcher *self) {
	WnckWorkspace *activeworkspace = wnck_screen_get_active_workspace(self->screen);
	WnckWindow *new_active = wnck_screen_get_active_window(self->screen);
	WnckWindow *new_tracked = NULL;

	// stop tracking the old active window
	if (G_IS_OBJECT(self->active)) {
		if (g_signal_handler_is_connected(G_OBJECT(self->active), self->handler_active_state_changed)) {
			g_signal_handler_disconnect(G_OBJECT(self->active), self->handler_active_state_changed);
		}
	}

	if (self->only_maximized) {
		// find upper maximized window
		GList *windows = wnck_screen_get_windows_stacked(self->screen);
		while (windows && windows->data) {
			if (!self->only_maximized || wnck_window_is_maximized(windows->data))
				if (!wnck_window_is_minimized(windows->data) && !wnck_window_is_skip_pager(windows->data))
					if (wnck_window_is_in_viewport(windows->data, activeworkspace))
						new_tracked = windows->data;
			windows = windows->next;
		}

		// start tracking the new active window
		if (new_active) {
			self->handler_active_state_changed = g_signal_connect(G_OBJECT(new_active), "state-changed",
			                                     G_CALLBACK(wibuti_watcher_window_state_changed_cb), self);
		}
	} else {
		new_tracked = new_active;
	}

	// stop tracking the old window
	if (G_IS_OBJECT(self->tracked)) {
#ifdef WIBUTI_WITH_TITLE
		if (g_signal_handler_is_connected(G_OBJECT(self->tracked), self->handler_name_changed)) {
			g_signal_handler_disconnect(G_OBJECT(self->tracked), self->handler_name_changed);
		}
		if (g_signal_handler_is_connected(G_OBJECT(self->tracked), self->handler_icon_changed)) {
			g_signal_handler_disconnect(G_OBJECT(self->tracked), self->handler_icon_changed);
		}
#endif // WIBUTI_WITH_TITLE
		if (g_signal_handler_is_connected(G_OBJECT(self->tracked), self->handler_tracked_state_changed)) {
			g_signal_handler_disconnect(G_OBJECT(self->tracked), self->handler_tracked_state_changed);
		}
	}

	// start tracking the new window
	if (new_tracked) {
#ifdef WIBUTI_WITH_TITLE
		self->handler_name_changed = g_signal_connect(G_OBJECT(new_tracked), "name-changed",
	                                                  G_CALLBACK(wibuti_watcher_name_changed_cb), self);
		self->handler_icon_changed = g_signal_connect(G_OBJECT(new_tracked), "icon-changed",
	                                                  G_CALLBACK(wibuti_watcher_icon_changed_cb), self);
#endif // WIBUTI_WITH_TITLE
		self->handler_tracked_state_changed = g_signal_connect(G_OBJECT(new_tracked), "state-changed",
                                                      G_CALLBACK(wibuti_watcher_window_state_changed_cb), self);
	}
	
	self->tracked = new_tracked;
	self->active = new_active;
}
Exemple #7
0
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;
}