示例#1
0
void test_background_util()
{
	setup_fixture();


	Test({


	},"test_");
    typedef struct _xfade_data
    {
        //all in seconds.
        gdouble start_time;
        gdouble total_duration;
        gdouble interval;

        cairo_surface_t* fading_surface;
        GdkPixbuf* end_pixbuf;
        gdouble alpha;

        Pixmap pixmap;
    } xfade_data_t;


    GdkScreen *screen = NULL;
    Display *display = NULL;

    screen = gdk_screen_get_default();
    gint number = gdk_screen_get_number(screen);
    gint width = gdk_screen_get_width(screen);
    gint height = gdk_screen_get_height(screen);
    display = XOpenDisplay(gdk_display_get_name(gdk_screen_get_display(screen)));
    Pixmap pixmap = XCreatePixmap (display, RootWindow(display, number), width, height, DefaultDepth(display, number));

    cairo_surface_t *get_surface(Pixmap);
    xfade_data_t *data = g_slice_new(xfade_data_t);
    data->pixmap = pixmap;
    data->fading_surface = get_surface(pixmap);
    data->end_pixbuf = gdk_pixbuf_new_from_file(file1, NULL);

    // _update_rootpmap Successful.
    /* extern void _update_rootpmap(); */
    /* Test({ */
    /*     _update_rootpmap(pixmap); */
    /* }, "_update_rootpmap"); */

    // on_tick Successful.
    /* extern void on_tick(xfade_data_t *data); */
    /* Test({ */
    /*     on_tick(data); */
    /* }, "on_tick"); */

    // draw_background Successful.
    /* extern void draw_background(xfade_data_t *data); */
    /* Test({ */
    /*     draw_background(data); */
    /* }, "draw_background"); */

    g_object_unref(data->end_pixbuf);
    cairo_surface_destroy(data->fading_surface);
    g_free(data);

    // remove_timers Successful.
    /* extern void remove_timers(); */
    /* Test({ */
    /*     remove_timers(); */
    /* }, "remove_timers"); */

    // get_current_picture_path Successful.
    /* extern const char *get_current_picture_path(); */
    /* Test({ */
    /*     get_current_picture_path(); */
    /* }, "get_current_picture_path"); */

    // get_next_picture_index Successful.
    /* extern guint get_next_picture_index(); */
    /* Test({ */
    /*     get_next_picture_index(); */
    /* }, "get_next_picture_index"); */

    // get_next_picture_path Successful.
    /* extern const char *get_next_picture_path(); */
    /* Test({ */
    /*     get_next_picture_path(); */
    /* }, "get_next_picture_path"); */

    // get_xformed_gdk_pixbuf  Succcessful.
    extern GdkPixbuf *get_xformed_gdk_pixbuf(const char *path);
    /* Test({ */
    /*     const gchar *path = get_current_picture_path(); */
    /*     GdkPixbuf *pixbuf = get_xformed_gdk_pixbuf(path); */
    /*     g_object_unref(pixbuf); */
    /* }, "get_xformed_gdk_pixbuf"); */

    // on_bg_duration_tick Successful.
    extern gboolean on_bg_duration_tick(gpointer data);
    Test({
        on_bg_duration_tick(NULL);
    }, "on_bg_duration_tick");
示例#2
0
void
mate_panel_applet_position_menu (GtkMenu   *menu,
			    int       *x,
			    int       *y,
			    gboolean  *push_in,
			    GtkWidget *applet)
{
	GtkAllocation   allocation;
	GtkRequisition  requisition;
#if GTK_CHECK_VERSION(3, 0, 0)
	GdkDevice      *device;
#endif
	GdkScreen      *screen;
	GtkWidget      *parent;
	int             menu_x = 0;
	int             menu_y = 0;
	int             pointer_x;
	int             pointer_y;

	parent = gtk_widget_get_parent (applet);

	g_return_if_fail (PANEL_IS_WIDGET (parent));

	screen = gtk_widget_get_screen (applet);

#if GTK_CHECK_VERSION (3, 0, 0)
	gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, NULL);
#else
	gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
#endif

	gdk_window_get_origin (gtk_widget_get_window (applet), &menu_x, &menu_y);
#if GTK_CHECK_VERSION (3, 0, 0)
	device = gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (gtk_widget_get_display (applet)));
	gdk_window_get_device_position(gtk_widget_get_window (applet), device, &pointer_x, &pointer_y, NULL);
#else
	gtk_widget_get_pointer (applet, &pointer_x, &pointer_y);
#endif
	gtk_widget_get_allocation (applet, &allocation);

	if (!gtk_widget_get_has_window (applet)) {
		menu_x += allocation.x;
		menu_y += allocation.y;
	}

	if (PANEL_WIDGET (parent)->orient == GTK_ORIENTATION_HORIZONTAL) {
		if (gtk_widget_get_direction (GTK_WIDGET (menu)) != GTK_TEXT_DIR_RTL) {
			if (pointer_x < allocation.width &&
			    requisition.width < pointer_x)
				menu_x += MIN (pointer_x,
					       allocation.width - requisition.width);
		} else {
			menu_x += allocation.width - requisition.width;
			if (pointer_x > 0 && pointer_x < allocation.width &&
			    pointer_x < allocation.width - requisition.width) {
				menu_x -= MIN (allocation.width - pointer_x,
					       allocation.width - requisition.width);
			}
		}
		menu_x = MIN (menu_x, gdk_screen_get_width (screen) - requisition.width);

		if (menu_y > gdk_screen_get_height (screen) / 2)
			menu_y -= requisition.height;
		else
			menu_y += allocation.height;
	} else {
		if (pointer_y < allocation.height &&
		    requisition.height < pointer_y)
			menu_y += MIN (pointer_y, allocation.height - requisition.height);
		menu_y = MIN (menu_y, gdk_screen_get_height (screen) - requisition.height);

		if (menu_x > gdk_screen_get_width (screen) / 2)
			menu_x -= requisition.width;
		else
			menu_x += allocation.width;
	}

	*x = menu_x;
	*y = menu_y;
#if GTK_CHECK_VERSION (3, 0, 0)
	*push_in = FALSE;
#else
	*push_in = TRUE;
#endif
}
示例#3
0
static void
screen_get_work_area(GdkScreen      *screen,
                     HippoRectangle *work_area)
{
    /* Making two round trips to the X server everytime the code calls get_screen_info()
     * has a certain potential for performance problems. We might want to consider
     * caching the results for a small amount of time.
     */
    GdkDisplay *display = gdk_screen_get_display(screen);
    GdkWindow *root = gdk_screen_get_root_window(screen);
    Atom current_desktop_atom = gdk_x11_get_xatom_by_name_for_display(display, "_NET_CURRENT_DESKTOP");
    Atom workarea_atom = gdk_x11_get_xatom_by_name_for_display(display, "_NET_WORKAREA");
    int format;
    Atom type;
    unsigned long n_items;
    unsigned long bytes_after;
    unsigned char *data;
    guint current_desktop;
    guint n_desktops;
    
    if (XGetWindowProperty(GDK_WINDOW_XDISPLAY(root), GDK_WINDOW_XWINDOW(root),
                           current_desktop_atom, 
                           0, G_MAXLONG, False, XA_CARDINAL,
                           &type, &format, &n_items, &bytes_after, &data) != Success) {
        g_warning("Failed to get _NET_CURRENT_DESKTOP property");
        goto fail;
    }
        
    if (format != 32 || type != XA_CARDINAL || n_items != 1) {
        g_warning("Bad _NET_CURRENT_DESKTOP property");
        XFree(data);
        goto fail;
    }

    current_desktop = ((unsigned long *)data)[0];
    XFree(data);
    

    if (XGetWindowProperty(GDK_WINDOW_XDISPLAY(root), GDK_WINDOW_XWINDOW(root),
                           workarea_atom, 
                           0, G_MAXLONG, False, XA_CARDINAL,
                           &type, &format, &n_items, &bytes_after, &data) != Success) {
        g_warning("Failed to get _NET_WORKAREA property");
        goto fail;
    }
        
    if (format != 32 ||  type != XA_CARDINAL || n_items < 4 || (n_items % 4) != 0) {
        g_warning("Bad _NET_WORKAREA property");
        XFree(data);
        goto fail;
    }

    n_desktops = n_items / 4;
    if (current_desktop > n_desktops) {
        g_warning("Current desktop out of range");
        current_desktop = 0;
    }

    work_area->x = ((unsigned long *)data)[current_desktop * 4];
    work_area->y = ((unsigned long *)data)[current_desktop * 4 + 1];
    work_area->width = ((unsigned long *)data)[current_desktop * 4 + 2];
    work_area->height = ((unsigned long *)data)[current_desktop * 4 + 3];
    
    XFree(data);
    return;

 fail:
    work_area->x = 0;
    work_area->y = 0;
    work_area->width = gdk_screen_get_width(screen);
    work_area->height = gdk_screen_get_height(screen);
}
示例#4
0
Size pDesktop::size() {
  return {
    gdk_screen_get_width(gdk_screen_get_default()),
    gdk_screen_get_height(gdk_screen_get_default())
  };
}
示例#5
0
static gboolean
get_work_area (NotifyStack  *stack,
               GdkRectangle *rect)
{
        Atom            workarea;
        Atom            type;
        Window          win;
        int             format;
        gulong          num;
        gulong          leftovers;
        gulong          max_len = 4 * 32;
        guchar         *ret_workarea;
        long           *workareas;
        int             result;
        int             disp_screen;

	workarea = XInternAtom(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), "_NET_WORKAREA", True);


        disp_screen = GDK_SCREEN_XNUMBER (stack->screen);

        /* Defaults in case of error */
        rect->x = 0;
        rect->y = 0;
        rect->width = gdk_screen_get_width (stack->screen);
        rect->height = gdk_screen_get_height (stack->screen);

        if (workarea == None)
                return FALSE;


	win = XRootWindow(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), disp_screen);

	result = XGetWindowProperty(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
		win,
		workarea,
		0,
		max_len,
		False,
		AnyPropertyType,
		&type,
		&format,
		&num,
		&leftovers,
		&ret_workarea);


        if (result != Success
            || type == None
            || format == 0
            || leftovers
            || num % 4) {
                return FALSE;
        }

        workareas = (long *) ret_workarea;
        rect->x = workareas[disp_screen * 4];
        rect->y = workareas[disp_screen * 4 + 1];
        rect->width = workareas[disp_screen * 4 + 2];
        rect->height = workareas[disp_screen * 4 + 3];

        XFree (ret_workarea);

        return TRUE;
}
int QDesktopWidget::width()
{
    return gdk_screen_get_width(gdk_screen_get_default());
}
/**
 * gsc_utils_move_to_iter:
 * @window: the #GtkWindow to move
 * @view: the view
 * @iter: the iter to move @window to
 *
 */
void
gsc_utils_move_to_iter (GtkWindow     *window,
                        GtkTextView *view,
                        GtkTextIter   *iter)
{
    gint x;
    gint y;
    gint w;
    gint h;
    gint cx;
    gint cy;
    gint oy;
    gint height;
    GdkScreen *screen;
    gboolean overlapup;

    gint sw = gdk_screen_width();
    gint sh = gdk_screen_height();

    if (window != NULL)
    {
        screen = gtk_window_get_screen (window);
    }
    else
    {
        screen = gdk_screen_get_default ();
    }

    sw = gdk_screen_get_width (screen);
    sh = gdk_screen_get_height (screen);

    get_iter_pos (view, iter, &x, &y, &height);
    gtk_window_get_size (window, &w, &h);

    oy = y;
    compensate_for_gravity (window, &cx, &cy, w, h);

    /* Push window inside screen */
    if (x - cx + w > sw)
    {
        x = (sw - w) + cx;
    }
    else if (x - cx < 0)
    {
        x = cx;
    }

    if (y - cy + h > sh)
    {
        y = (sh - h) + cy;
        overlapup = TRUE;
    }
    else if (y - cy < 0)
    {
        y = cy;
        overlapup = FALSE;
    }
    else
    {
        overlapup = TRUE;
    }

    /* Make sure that text is still readable */
    move_overlap (&x, &y, w, h, oy, cx, cy, height, overlapup);

    gtk_window_move (window, x, y);
}