Patch from Bruno Boaventura to sync metacity workspace previews with

2006-10-10  Elijah Newren  <newren gmail com>

	* src/draw-workspace.c (draw_window, wnck_draw_workspace): Patch
	from Bruno Boaventura to sync metacity workspace previews with
	libwnck.  #341893
This commit is contained in:
Elijah Newren 2006-10-10 18:19:32 +00:00 committed by Elijah Newren
parent b569dddc17
commit a34944d341
2 changed files with 89 additions and 71 deletions

View File

@ -1,3 +1,9 @@
2006-10-10 Elijah Newren <newren gmail com>
* src/draw-workspace.c (draw_window, wnck_draw_workspace): Patch
from Bruno Boaventura to sync metacity workspace previews with
libwnck. #341893
2006-10-07 Thomas Thurman <thomas@thurman.org.uk> 2006-10-07 Thomas Thurman <thomas@thurman.org.uk>
* configure.in: post-release bump to 2.17.1. * configure.in: post-release bump to 2.17.1.

View File

@ -69,18 +69,35 @@ static void
draw_window (GtkWidget *widget, draw_window (GtkWidget *widget,
GdkDrawable *drawable, GdkDrawable *drawable,
const WnckWindowDisplayInfo *win, const WnckWindowDisplayInfo *win,
const GdkRectangle *winrect) const GdkRectangle *winrect,
GtkStateType state)
{ {
cairo_t *cr;
GdkPixbuf *icon; GdkPixbuf *icon;
int icon_x, icon_y, icon_w, icon_h; int icon_x, icon_y, icon_w, icon_h;
gboolean is_active;
GdkColor *color;
gdk_draw_rectangle (drawable, is_active = win->is_active;
win->is_active ?
widget->style->bg_gc[GTK_STATE_SELECTED] : cr = gdk_cairo_create (drawable);
widget->style->bg_gc[GTK_STATE_NORMAL], cairo_rectangle (cr, winrect->x, winrect->y, winrect->width, winrect->height);
TRUE, cairo_clip (cr);
if (is_active)
color = &widget->style->light[state];
else
color = &widget->style->bg[state];
cairo_set_source_rgb (cr,
color->red / 65535.,
color->green / 65535.,
color->blue / 65535.);
cairo_rectangle (cr,
winrect->x + 1, winrect->y + 1, winrect->x + 1, winrect->y + 1,
winrect->width - 2, winrect->height - 2); MAX (0, winrect->width - 2), MAX (0, winrect->height - 2));
cairo_fill (cr);
icon = win->icon; icon = win->icon;
@ -117,43 +134,30 @@ draw_window (GtkWidget *widget,
icon_x = winrect->x + (winrect->width - icon_w) / 2; icon_x = winrect->x + (winrect->width - icon_w) / 2;
icon_y = winrect->y + (winrect->height - icon_h) / 2; icon_y = winrect->y + (winrect->height - icon_h) / 2;
{ cairo_save (cr);
/* render_to_drawable should take a clip rect to save gdk_cairo_set_source_pixbuf (cr, icon, icon_x, icon_y);
* us this mess... cairo_rectangle (cr, icon_x, icon_y, icon_w, icon_h);
*/ cairo_clip (cr);
GdkRectangle pixbuf_rect; cairo_paint (cr);
GdkRectangle draw_rect; cairo_restore (cr);
pixbuf_rect.x = icon_x;
pixbuf_rect.y = icon_y;
pixbuf_rect.width = icon_w;
pixbuf_rect.height = icon_h;
if (gdk_rectangle_intersect ((GdkRectangle *)winrect, &pixbuf_rect,
&draw_rect))
{
gdk_pixbuf_render_to_drawable_alpha (icon,
drawable,
draw_rect.x - pixbuf_rect.x,
draw_rect.y - pixbuf_rect.y,
draw_rect.x, draw_rect.y,
draw_rect.width,
draw_rect.height,
GDK_PIXBUF_ALPHA_FULL,
128,
GDK_RGB_DITHER_NORMAL,
0, 0);
}
}
} }
gdk_draw_rectangle (drawable, if (is_active)
win->is_active ? color = &widget->style->fg[state];
widget->style->fg_gc[GTK_STATE_SELECTED] : else
widget->style->fg_gc[GTK_STATE_NORMAL], color = &widget->style->fg[state];
FALSE,
winrect->x, winrect->y, cairo_set_source_rgb (cr,
winrect->width - 1, winrect->height - 1); color->red / 65535.,
color->green / 65535.,
color->blue / 65535.);
cairo_set_line_width (cr, 1.0);
cairo_rectangle (cr,
winrect->x + 0.5, winrect->y + 0.5,
MAX (0, winrect->width - 1), MAX (0, winrect->height - 1));
cairo_stroke (cr);
cairo_destroy (cr);
} }
void void
@ -172,23 +176,25 @@ wnck_draw_workspace (GtkWidget *widget,
{ {
int i; int i;
GdkRectangle workspace_rect; GdkRectangle workspace_rect;
GtkStateType state;
workspace_rect.x = x; workspace_rect.x = x;
workspace_rect.y = y; workspace_rect.y = y;
workspace_rect.width = width; workspace_rect.width = width;
workspace_rect.height = height; workspace_rect.height = height;
if (is_active) if (is_active)
gdk_draw_rectangle (drawable, state = GTK_STATE_SELECTED;
GTK_WIDGET (widget)->style->dark_gc[GTK_STATE_SELECTED],
TRUE,
x, y, width, height);
else if (workspace_background) else if (workspace_background)
state = GTK_STATE_PRELIGHT;
else
state = GTK_STATE_NORMAL;
if (workspace_background)
{ {
gdk_pixbuf_render_to_drawable (workspace_background, gdk_draw_pixbuf (drawable,
drawable, GTK_WIDGET (widget)->style->dark_gc[state],
GTK_WIDGET (widget)->style->dark_gc[GTK_STATE_SELECTED], workspace_background,
0, 0, 0, 0,
x, y, x, y,
-1, -1, -1, -1,
@ -196,11 +202,15 @@ wnck_draw_workspace (GtkWidget *widget,
0, 0); 0, 0);
} }
else else
gdk_draw_rectangle (drawable, {
GTK_WIDGET (widget)->style->dark_gc[GTK_STATE_NORMAL], cairo_t *cr;
TRUE,
x, y, width, height);
cr = gdk_cairo_create (widget->window);
gdk_cairo_set_source_color (cr, &widget->style->dark[state]);
cairo_rectangle (cr, x, y, width, height);
cairo_fill (cr);
cairo_destroy (cr);
}
i = 0; i = 0;
while (i < n_windows) while (i < n_windows)
@ -208,12 +218,14 @@ wnck_draw_workspace (GtkWidget *widget,
const WnckWindowDisplayInfo *win = &windows[i]; const WnckWindowDisplayInfo *win = &windows[i];
GdkRectangle winrect; GdkRectangle winrect;
get_window_rect (win, screen_width, screen_height, &workspace_rect, &winrect); get_window_rect (win, screen_width,
screen_height, &workspace_rect, &winrect);
draw_window (widget, draw_window (widget,
drawable, drawable,
win, win,
&winrect); &winrect,
state);
++i; ++i;
} }