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>
* configure.in: post-release bump to 2.17.1.

View File

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