Exemplo n.º 1
0
static void
on_screen_monitors_changed (GdkScreen *screen,
                            GSManager *manager)
{
        GSList *l;
        int     n_monitors;
        int     n_windows;
        int     i;

        n_monitors = gdk_screen_get_n_monitors (screen);
        n_windows = g_slist_length (manager->priv->windows);

        gs_debug ("Monitors changed for screen %d: num=%d",
                  gdk_screen_get_number (screen),
                  n_monitors);

        if (n_monitors > n_windows) {

                /* add more windows */
                for (i = n_windows; i < n_monitors; i++) {
                        gs_manager_create_window_for_monitor (manager, screen, i);
                }
        } else {

                gdk_x11_grab_server ();

                /* remove the extra windows */
                l = manager->priv->windows;
                while (l != NULL) {
                        GdkScreen *this_screen;
                        int        this_monitor;
                        GSList    *next = l->next;

                        this_screen = gs_window_get_screen (GS_WINDOW (l->data));
                        this_monitor = gs_window_get_monitor (GS_WINDOW (l->data));
                        if (this_screen == screen && this_monitor >= n_monitors) {
                                gs_window_destroy (GS_WINDOW (l->data));
                                manager->priv->windows = g_slist_delete_link (manager->priv->windows, l);
                        }
                        l = next;
                }

                gdk_flush ();
                gdk_x11_ungrab_server ();
        }

	for (l = manager->priv->windows; l != NULL; l = l->next) {
		GdkScreen *this_screen;

		this_screen = gs_window_get_screen (GS_WINDOW (l->data));
		if (this_screen == screen) {
			gtk_widget_queue_resize (GTK_WIDGET (l->data));
		}
	}
}
Exemplo n.º 2
0
static void
on_display_monitor_added (GdkDisplay *display,
                          GdkMonitor *monitor,
                          GSManager  *manager)
{
	GSList     *l;
	int         n_monitors;

	n_monitors = gdk_display_get_n_monitors (display);

	gs_debug ("Monitor added on display %s, now there are %d",
	          gdk_display_get_name (display), n_monitors);

	/* Tear down the unlock dialog in case we want to move it
	 * to the new monitor
	 */
	l = manager->priv->windows;
	while (l != NULL)
	{
		gs_window_cancel_unlock_request (GS_WINDOW (l->data));
		l = l->next;
	}

	/* add a new window */
	gs_manager_create_window_for_monitor (manager, monitor);

	/* and put unlock dialog up whereever it's supposed to be */
	gs_manager_request_unlock (manager);
}
Exemplo n.º 3
0
static void
window_destroyed_cb (GtkWindow *window,
                     gpointer   data)
{
        disconnect_window_signals (GS_WINDOW (window));
        gs_grab_release (grab);
        gtk_main_quit ();
}
Exemplo n.º 4
0
static void
gs_window_build_ui (GsWindow *window)
{
	GtkWidget *menubar;

	g_return_if_fail (GS_IS_WINDOW (window));

	window->priv->box = gtk_vbox_new (FALSE, 0);
	gtk_container_add (GTK_CONTAINER (window), window->priv->box);
	gtk_widget_show (window->priv->box);

	window->priv->ui_manager = gtk_ui_manager_new ();

	window->priv->ui_actions = gtk_action_group_new ("MenuActions");
	gtk_action_group_add_actions (window->priv->ui_actions,
				      action_entries,
				      G_N_ELEMENTS (action_entries),
				      window);
	gtk_action_group_add_toggle_actions (window->priv->ui_actions,
					     toggle_action_entries,
					     G_N_ELEMENTS (toggle_action_entries),
					     window);
	gtk_ui_manager_insert_action_group (window->priv->ui_manager, window->priv->ui_actions, 0);

	if (!gtk_ui_manager_add_ui_from_string (window->priv->ui_manager, UI_DEFINITION, -1, NULL)) {
		g_assert ("No se pudo cargar la UI");
	}

	menubar = gtk_ui_manager_get_widget (window->priv->ui_manager, "/MainMenu");
	g_assert (GTK_IS_WIDGET (menubar));
	gtk_box_pack_start (GTK_BOX (window->priv->box), menubar, FALSE, FALSE, 0);
	gtk_widget_show (menubar);

	gtk_window_add_accel_group (GTK_WINDOW (window),
				    gtk_ui_manager_get_accel_group (window->priv->ui_manager));

	window->priv->graph = gs_graph_new ();
	gtk_widget_show (window->priv->graph);

	window->priv->hpaned = gtk_hpaned_new ();
	gtk_paned_pack1 (GTK_PANED (window->priv->hpaned), window->priv->graph, TRUE, FALSE);

	window->priv->plot_list_panel = gs_plot_list_panel_new (GS_WINDOW (window));
	gtk_paned_pack2 (GTK_PANED (window->priv->hpaned), window->priv->plot_list_panel, TRUE, FALSE);
	gtk_widget_show (window->priv->plot_list_panel);
	gtk_widget_show (window->priv->hpaned);

	gtk_box_pack_start (GTK_BOX (window->priv->box), window->priv->hpaned, TRUE, TRUE, 0);

	window->priv->statusbar = gtk_statusbar_new ();
	gtk_box_pack_end (GTK_BOX (window->priv->box), window->priv->statusbar, FALSE, FALSE, 0);
	gtk_widget_show (window->priv->statusbar);

}
Exemplo n.º 5
0
static void
on_display_monitor_removed (GdkDisplay *display,
                            GdkMonitor *monitor,
                            GSManager  *manager)
{
	GSList     *l;
	int         n_monitors;

	n_monitors = gdk_display_get_n_monitors (display);

	gs_debug ("Monitor removed on display %s, now there are %d",
	          gdk_display_get_name (display), n_monitors);

	gdk_x11_grab_server ();

	/* remove the now extra window */
	l = manager->priv->windows;
	while (l != NULL)
	{
		GdkDisplay *this_display;
		GdkMonitor *this_monitor;
		GSList     *next = l->next;

		this_display = gs_window_get_display (GS_WINDOW (l->data));
		this_monitor = gs_window_get_monitor (GS_WINDOW (l->data));
		if (this_display == display && this_monitor == monitor)
		{
			manager_maybe_stop_job_for_window (manager,
			                                   GS_WINDOW (l->data));
			g_hash_table_remove (manager->priv->jobs, l->data);
			gs_window_destroy (GS_WINDOW (l->data));
			manager->priv->windows = g_slist_delete_link (manager->priv->windows, l);
		}
		l = next;
	}

	gdk_display_flush (display);
	gdk_x11_ungrab_server ();
}
Exemplo n.º 6
0
static GSWindow *
find_window_at_pointer (GSManager *manager)
{
	GdkDisplay *display;
	GdkDevice  *device;
	GdkMonitor *monitor;
	int         x, y;
	GSWindow   *window;
	GSList     *l;

	display = gdk_display_get_default ();

	device = gdk_seat_get_pointer (gdk_display_get_default_seat (display));
	gdk_device_get_position (device, NULL, &x, &y);
	monitor = gdk_display_get_monitor_at_point (display, x, y);

	/* Find the gs-window that is on that monitor */
	window = NULL;
	for (l = manager->priv->windows; l; l = l->next)
	{
		GSWindow *win = GS_WINDOW (l->data);
		if (gs_window_get_display (win) == display &&
		    gs_window_get_monitor (win) == monitor)
		{
			window = win;
		}
	}

	if (window == NULL)
	{
		gs_debug ("WARNING: Could not find the GSWindow for display %s",
		          gdk_display_get_name (display));
		/* take the first one */
		window = manager->priv->windows->data;
	}
	else
	{
		gs_debug ("Requesting unlock for display %s",
		          gdk_display_get_name (display));
	}

	return window;
}
Exemplo n.º 7
0
static GSWindow *
find_window_at_pointer (GSManager *manager)
{
	GdkDisplay *display;
	GdkScreen  *screen;
	int         monitor;
	int         x, y;
	GSWindow   *window;
	int         screen_num;
	GSList     *l;

	display = gdk_display_get_default ();
	gdk_display_get_pointer (display, &screen, &x, &y, NULL);
	monitor = gdk_screen_get_monitor_at_point (screen, x, y);
	screen_num = gdk_screen_get_number (screen);

	/* Find the gs-window that is on that screen */
	window = NULL;
	for (l = manager->priv->windows; l; l = l->next)
	{
		GSWindow *win = GS_WINDOW (l->data);
		if (gs_window_get_screen (win) == screen
		        && gs_window_get_monitor (win) == monitor)
		{
			window = win;
		}
	}

	if (window == NULL)
	{
		gs_debug ("WARNING: Could not find the GSWindow for screen %d", screen_num);
		/* take the first one */
		window = manager->priv->windows->data;
	}
	else
	{
		gs_debug ("Requesting unlock for screen %d", screen_num);
	}

	return window;
}
Exemplo n.º 8
0
static void
window_destroyed_cb (GtkWindow *window,
                     GSManager *manager)
{
        disconnect_window_signals (manager, GS_WINDOW (window));
}
Exemplo n.º 9
0
static void
on_screen_monitors_changed (GdkScreen *screen,
                            GSManager *manager)
{
	GSList *l;
	int     n_monitors;
	int     n_windows;
	int     i;

	n_monitors = gdk_screen_get_n_monitors (screen);
	n_windows = g_slist_length (manager->priv->windows);

	gs_debug ("Monitors changed for screen %d: num=%d",
	          gdk_screen_get_number (screen),
	          n_monitors);

	if (n_monitors > n_windows)
	{

		/* Tear down unlock dialog in case we want to move it
		 * to a new monitor
		 */
		l = manager->priv->windows;
		while (l != NULL)
		{
			gs_window_cancel_unlock_request (GS_WINDOW (l->data));
			l = l->next;
		}

		/* add more windows */
		for (i = n_windows; i < n_monitors; i++)
		{
			gs_manager_create_window_for_monitor (manager, screen, i);
		}

		/* And put unlock dialog up where ever it's supposed to be
		 */
		gs_manager_request_unlock (manager);
	}
	else
	{

		gdk_x11_grab_server ();

		/* remove the extra windows */
		l = manager->priv->windows;
		while (l != NULL)
		{
			GdkScreen *this_screen;
			int        this_monitor;
			GSList    *next = l->next;

			this_screen = gs_window_get_screen (GS_WINDOW (l->data));
			this_monitor = gs_window_get_monitor (GS_WINDOW (l->data));
			if (this_screen == screen && this_monitor >= n_monitors)
			{
				manager_maybe_stop_job_for_window (manager, GS_WINDOW (l->data));
				g_hash_table_remove (manager->priv->jobs, l->data);
				gs_window_destroy (GS_WINDOW (l->data));
				manager->priv->windows = g_slist_delete_link (manager->priv->windows, l);
			}
			l = next;
		}

		/* make sure there is a lock dialog on a connected monitor,
		 * and that the keyboard is still properly grabbed after all
		 * the windows above got destroyed*/
		if (n_windows > n_monitors)
		{
			gs_manager_request_unlock (manager);
		}

		gdk_flush ();
		gdk_x11_ungrab_server ();
	}
}