Beispiel #1
0
static void
gdk_x11_screen_get_monitor_workarea (GdkScreen    *screen,
                                     gint          monitor_num,
                                     GdkRectangle *dest)
{
  GdkRectangle workarea;

  gdk_x11_screen_get_monitor_geometry (screen, monitor_num, dest);
  get_work_area (screen, &workarea);
  gdk_rectangle_intersect (&workarea, dest, dest);
}
Beispiel #2
0
static void
position_window (MateRRLabeler  *labeler,
		 GtkWidget       *window,
		 int              x,
		 int              y)
{
	GdkRectangle    workarea;
	GdkRectangle    monitor;
	int             monitor_num;

	get_work_area (labeler, &workarea);
	monitor_num = gdk_screen_get_monitor_at_point (labeler->priv->screen, x, y);
	gdk_screen_get_monitor_geometry (labeler->priv->screen,
                                         monitor_num,
                                         &monitor);
	gdk_rectangle_intersect (&monitor, &workarea, &workarea);

	gtk_window_move (GTK_WINDOW (window), workarea.x, workarea.y);
}
Beispiel #3
0
static void
gdk_x11_screen_get_monitor_workarea (GdkScreen    *screen,
                                     gint          monitor_num,
                                     GdkRectangle *dest)
{
  GdkRectangle workarea;

  gdk_x11_screen_get_monitor_geometry (screen, monitor_num, dest);

  /* The EWMH constrains workarea to be a rectangle, so it
   * can't adequately deal with L-shaped monitor arrangements.
   * As a workaround, we ignore the workarea for anything
   * but the primary monitor. Since that is where the 'desktop
   * chrome' usually lives, this works ok in practice.
   */
  if (monitor_num == GDK_X11_SCREEN (screen)->primary_monitor)
    {
      get_work_area (screen, &workarea);
      if (gdk_rectangle_intersect (dest, &workarea, &workarea))
        *dest = workarea;
    }
}
static void
notify_stack_shift_notifications (NotifyStack *stack,
                                  GtkWindow   *nw,
                                  GList      **nw_l,
                                  gint         init_width,
                                  gint         init_height,
                                  gint        *nw_x,
                                  gint        *nw_y)
{
        GdkRectangle    workarea;
        GdkRectangle    monitor;
        GdkRectangle   *positions;
        GList          *l;
        gint            x, y;
        gint            shiftx = 0;
        gint            shifty = 0;
        int             i;
        int             n_wins;

        get_work_area (stack, &workarea);
        gdk_screen_get_monitor_geometry (stack->screen,
                                         stack->monitor,
                                         &monitor);
        gdk_rectangle_intersect (&monitor, &workarea, &workarea);

        add_padding_to_rect (&workarea);

        n_wins = g_list_length (stack->windows);
        positions = g_new0 (GdkRectangle, n_wins);

        get_origin_coordinates (stack->location,
                                &workarea,
                                &x, &y,
                                &shiftx,
                                &shifty,
                                init_width,
                                init_height);

        if (nw_x != NULL)
                *nw_x = x;

        if (nw_y != NULL)
                *nw_y = y;

        for (i = 0, l = stack->windows; l != NULL; i++, l = l->next) {
                GtkWindow      *nw2 = GTK_WINDOW (l->data);
                GtkRequisition  req;

                if (nw == NULL || nw2 != nw) {
                        gtk_widget_size_request (GTK_WIDGET (nw2), &req);

                        translate_coordinates (stack->location,
                                               &workarea,
                                               &x,
                                               &y,
                                               &shiftx,
                                               &shifty,
                                               req.width,
                                               req.height + NOTIFY_STACK_SPACING);
                        positions[i].x = x;
                        positions[i].y = y;
                } else if (nw_l != NULL) {
                        *nw_l = l;
                        positions[i].x = -1;
                        positions[i].y = -1;
                }
        }

        /* move bubbles at the bottom of the stack first
           to avoid overlapping */
        for (i = n_wins - 1, l = g_list_last (stack->windows); l != NULL; i--, l = l->prev) {
                GtkWindow *nw2 = GTK_WINDOW (l->data);

                if (nw == NULL || nw2 != nw) {
                        theme_move_notification (nw2, positions[i].x, positions[i].y);
                }
        }

        g_free (positions);
}
Beispiel #5
0
gint notification_window_open(const gchar *message, const gchar *submessage,
			      guint timeout)
{
	GtkWidget *window;
	GtkWidget *vbox;
	GtkWidget *msglabel;
	GtkWidget *sublabel;
	GdkRectangle rect;
	gint x, y;
	GtkRequisition requisition;

	if (notify_window.window) {
		notification_window_destroy();
	}

	window = gtk_window_new(GTK_WINDOW_POPUP);
	gtk_window_set_title(GTK_WINDOW(window), _("Notification"));
	gtk_window_set_wmclass(GTK_WINDOW(window), "notification", "Sylpheed");
	gtk_container_set_border_width(GTK_CONTAINER(window), 8);
	gtk_widget_set_events(window, GDK_EXPOSURE_MASK|GDK_BUTTON_MOTION_MASK|GDK_POINTER_MOTION_MASK|GDK_POINTER_MOTION_HINT_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK|GDK_ENTER_NOTIFY_MASK|GDK_LEAVE_NOTIFY_MASK);
	gtk_window_set_skip_taskbar_hint(GTK_WINDOW(window), TRUE);
	gtk_window_set_gravity(GTK_WINDOW(window), GDK_GRAVITY_SOUTH_EAST);
	gtk_widget_set_size_request(window, NOTIFICATIONWINDOW_WIDTH, -1);
	gtk_widget_realize(window);
	gdk_window_set_type_hint(window->window, GDK_WINDOW_TYPE_HINT_NOTIFICATION);

	/* move window bottom-right */
	get_work_area(&rect);
	x = rect.x + rect.width - NOTIFICATIONWINDOW_WIDTH - 2;
	if (x < 0) x = 0;
	y = rect.y + rect.height - NOTIFICATIONWINDOW_HEIGHT - 2;
	if (y < 0) y = 0;
	gtk_window_move(GTK_WINDOW(window), x, y);

	g_signal_connect(G_OBJECT(window), "destroy",
			 G_CALLBACK(nwin_destroy_cb), NULL);
	g_signal_connect(G_OBJECT(window), "button_press_event",
			 G_CALLBACK(nwin_button_pressed), NULL);
	g_signal_connect(G_OBJECT(window), "enter_notify_event",
			 G_CALLBACK(nwin_entered), NULL);
	g_signal_connect(G_OBJECT(window), "motion_notify_event",
			 G_CALLBACK(nwin_motion_notify), NULL);

	vbox = gtk_vbox_new(FALSE, 8);
	gtk_container_add(GTK_CONTAINER(window), vbox);

	msglabel = gtk_label_new(message);
	gtk_box_pack_start(GTK_BOX(vbox), msglabel, FALSE, FALSE, 0);

	sublabel = gtk_label_new("");
	gtk_label_set_ellipsize(GTK_LABEL(sublabel), PANGO_ELLIPSIZE_END);
	gtk_label_set_markup(GTK_LABEL(sublabel), submessage);
	gtk_box_pack_start(GTK_BOX(vbox), sublabel, FALSE, FALSE, 0);
	gtk_label_set_justify(GTK_LABEL(sublabel), GTK_JUSTIFY_LEFT);
	gtk_misc_set_alignment(GTK_MISC(sublabel), 0.0, 0.5);

	gtk_widget_show_all(window);

	/* adjust window size and position */
	gtk_widget_get_child_requisition(window, &requisition);
	notify_window.width = NOTIFICATIONWINDOW_WIDTH;
	notify_window.height = MAX(requisition.height, NOTIFICATIONWINDOW_HEIGHT);
	gtk_widget_set_size_request(window, NOTIFICATIONWINDOW_WIDTH, notify_window.height);
	y = rect.y + rect.height - notify_window.height - 2;
	if (y < 0) y = 0;
	gtk_window_move(GTK_WINDOW(window), x, y);

	if (timeout == 0)
		timeout = 1;
	notify_window.notify_tag = g_timeout_add(timeout * 1000,
						 notify_timeout_cb, NULL);

	debug_print("notification window created\n");

	notify_window.window = window;
	notify_window.msglabel = msglabel;
	notify_window.sublabel = sublabel;
	notify_window.x = x;
	notify_window.y = y;
	notify_window.fade_length = 0;
	notify_window.fade_count = 0;
	notify_window.notify_event_count = 0;
	notify_window.timeout = timeout;

	return 0;
}