mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
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:
parent
b569dddc17
commit
a34944d341
@ -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.
|
||||||
|
@ -66,21 +66,38 @@ get_window_rect (const WnckWindowDisplayInfo *win,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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;
|
||||||
gdk_draw_rectangle (drawable,
|
GdkColor *color;
|
||||||
win->is_active ?
|
|
||||||
widget->style->bg_gc[GTK_STATE_SELECTED] :
|
is_active = win->is_active;
|
||||||
widget->style->bg_gc[GTK_STATE_NORMAL],
|
|
||||||
TRUE,
|
cr = gdk_cairo_create (drawable);
|
||||||
winrect->x + 1, winrect->y + 1,
|
cairo_rectangle (cr, winrect->x, winrect->y, winrect->width, winrect->height);
|
||||||
winrect->width - 2, winrect->height - 2);
|
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,
|
||||||
|
MAX (0, winrect->width - 2), MAX (0, winrect->height - 2));
|
||||||
|
cairo_fill (cr);
|
||||||
|
|
||||||
|
|
||||||
icon = win->icon;
|
icon = win->icon;
|
||||||
|
|
||||||
@ -103,7 +120,7 @@ draw_window (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
icon_w = gdk_pixbuf_get_width (icon);
|
icon_w = gdk_pixbuf_get_width (icon);
|
||||||
icon_h = gdk_pixbuf_get_height (icon);
|
icon_h = gdk_pixbuf_get_height (icon);
|
||||||
|
|
||||||
/* Give up. */
|
/* Give up. */
|
||||||
if (icon_w > (winrect->width - 2) ||
|
if (icon_w > (winrect->width - 2) ||
|
||||||
icon_h > (winrect->height - 2))
|
icon_h > (winrect->height - 2))
|
||||||
@ -116,44 +133,31 @@ 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,48 +176,56 @@ 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],
|
else if (workspace_background)
|
||||||
TRUE,
|
state = GTK_STATE_PRELIGHT;
|
||||||
x, y, width, height);
|
else
|
||||||
else if (workspace_background)
|
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,
|
||||||
GDK_RGB_DITHER_MAX,
|
GDK_RGB_DITHER_MAX,
|
||||||
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)
|
||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user