mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
separate code to draw frame from the expose_event handler, so in principle
2002-01-27 Havoc Pennington <hp@pobox.com> * src/frames.c: separate code to draw frame from the expose_event handler, so in principle we can draw the frame to a pixmap, but this isn't used yet.
This commit is contained in:
parent
d34cc4a683
commit
855d19cc0a
@ -1,3 +1,9 @@
|
|||||||
|
2002-01-27 Havoc Pennington <hp@pobox.com>
|
||||||
|
|
||||||
|
* src/frames.c: separate code to draw frame from the
|
||||||
|
expose_event handler, so in principle we can draw the
|
||||||
|
frame to a pixmap, but this isn't used yet.
|
||||||
|
|
||||||
2002-01-22 Hasbullah Bin Pit <sebol@ikhlas.com>
|
2002-01-22 Hasbullah Bin Pit <sebol@ikhlas.com>
|
||||||
|
|
||||||
* configure.in: Added Malay (ms)to ALL_LINGUAS.
|
* configure.in: Added Malay (ms)to ALL_LINGUAS.
|
||||||
|
18
src/frame.c
18
src/frame.c
@ -256,19 +256,6 @@ meta_frame_calc_geometry (MetaFrame *frame,
|
|||||||
*geomp = geom;
|
*geomp = geom;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
set_background_none (MetaFrame *frame,
|
|
||||||
int resize_gravity)
|
|
||||||
{
|
|
||||||
XSetWindowAttributes attrs;
|
|
||||||
|
|
||||||
attrs.background_pixmap = None;
|
|
||||||
XChangeWindowAttributes (frame->window->display->xdisplay,
|
|
||||||
frame->xwindow,
|
|
||||||
CWBackPixmap,
|
|
||||||
&attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_frame_sync_to_window (MetaFrame *frame,
|
meta_frame_sync_to_window (MetaFrame *frame,
|
||||||
int resize_gravity,
|
int resize_gravity,
|
||||||
@ -286,7 +273,10 @@ meta_frame_sync_to_window (MetaFrame *frame,
|
|||||||
|
|
||||||
/* set bg to none to avoid flicker */
|
/* set bg to none to avoid flicker */
|
||||||
if (need_resize)
|
if (need_resize)
|
||||||
set_background_none (frame, resize_gravity);
|
meta_ui_unflicker_frame_bg (frame->window->screen->ui,
|
||||||
|
frame->xwindow,
|
||||||
|
frame->rect.width,
|
||||||
|
frame->rect.height);
|
||||||
|
|
||||||
if (need_move && need_resize)
|
if (need_move && need_resize)
|
||||||
XMoveResizeWindow (frame->window->display->xdisplay,
|
XMoveResizeWindow (frame->window->display->xdisplay,
|
||||||
|
119
src/frames.c
119
src/frames.c
@ -73,7 +73,10 @@ static gboolean meta_frames_client_event (GtkWidget *widget,
|
|||||||
static gboolean meta_frames_window_state_event (GtkWidget *widget,
|
static gboolean meta_frames_window_state_event (GtkWidget *widget,
|
||||||
GdkEventWindowState *event);
|
GdkEventWindowState *event);
|
||||||
|
|
||||||
|
static void meta_frames_paint_to_drawable (MetaFrames *frames,
|
||||||
|
MetaUIFrame *frame,
|
||||||
|
GdkDrawable *drawable,
|
||||||
|
GdkRectangle *area);
|
||||||
|
|
||||||
static void meta_frames_calc_geometry (MetaFrames *frames,
|
static void meta_frames_calc_geometry (MetaFrames *frames,
|
||||||
MetaUIFrame *frame,
|
MetaUIFrame *frame,
|
||||||
@ -590,6 +593,44 @@ meta_frames_reset_bg (MetaFrames *frames,
|
|||||||
gtk_style_set_background (widget->style, frame->window, GTK_STATE_NORMAL);
|
gtk_style_set_background (widget->style, frame->window, GTK_STATE_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_background_none (Display *xdisplay,
|
||||||
|
Window xwindow)
|
||||||
|
{
|
||||||
|
XSetWindowAttributes attrs;
|
||||||
|
|
||||||
|
attrs.background_pixmap = None;
|
||||||
|
XChangeWindowAttributes (xdisplay, xwindow,
|
||||||
|
CWBackPixmap, &attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_frames_unflicker_bg (MetaFrames *frames,
|
||||||
|
Window xwindow,
|
||||||
|
int target_width,
|
||||||
|
int target_height)
|
||||||
|
{
|
||||||
|
GtkWidget *widget;
|
||||||
|
MetaUIFrame *frame;
|
||||||
|
|
||||||
|
widget = GTK_WIDGET (frames);
|
||||||
|
|
||||||
|
frame = meta_frames_lookup_window (frames, xwindow);
|
||||||
|
g_return_if_fail (frame != NULL);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
pixmap = gdk_pixmap_new (frame->window,
|
||||||
|
width, height,
|
||||||
|
-1);
|
||||||
|
|
||||||
|
/* Oops, no way to get the background here */
|
||||||
|
|
||||||
|
meta_frames_paint_to_drawable (frames, frame, pixmap);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
set_background_none (gdk_display, frame->xwindow);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_frames_queue_draw (MetaFrames *frames,
|
meta_frames_queue_draw (MetaFrames *frames,
|
||||||
Window xwindow)
|
Window xwindow)
|
||||||
@ -1393,6 +1434,7 @@ meta_frames_get_pixmap_for_control (MetaFrames *frames,
|
|||||||
static void
|
static void
|
||||||
draw_control_bg (MetaFrames *frames,
|
draw_control_bg (MetaFrames *frames,
|
||||||
MetaUIFrame *frame,
|
MetaUIFrame *frame,
|
||||||
|
GdkDrawable *drawable,
|
||||||
MetaFrameControl control,
|
MetaFrameControl control,
|
||||||
MetaFrameGeometry *fgeom)
|
MetaFrameGeometry *fgeom)
|
||||||
{
|
{
|
||||||
@ -1436,7 +1478,7 @@ draw_control_bg (MetaFrames *frames,
|
|||||||
if (rect == NULL)
|
if (rect == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gtk_paint_box (widget->style, frame->window,
|
gtk_paint_box (widget->style, drawable,
|
||||||
GTK_STATE_ACTIVE,
|
GTK_STATE_ACTIVE,
|
||||||
GTK_SHADOW_IN, NULL,
|
GTK_SHADOW_IN, NULL,
|
||||||
widget, "button",
|
widget, "button",
|
||||||
@ -1450,10 +1492,6 @@ meta_frames_expose_event (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
MetaUIFrame *frame;
|
MetaUIFrame *frame;
|
||||||
MetaFrames *frames;
|
MetaFrames *frames;
|
||||||
MetaFrameGeometry fgeom;
|
|
||||||
MetaFrameFlags flags;
|
|
||||||
int width, height;
|
|
||||||
GtkBorder inner;
|
|
||||||
|
|
||||||
frames = META_FRAMES (widget);
|
frames = META_FRAMES (widget);
|
||||||
|
|
||||||
@ -1468,32 +1506,51 @@ meta_frames_expose_event (GtkWidget *widget,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
meta_frames_paint_to_drawable (frames, frame, frame->window, &event->area);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
meta_frames_paint_to_drawable (MetaFrames *frames,
|
||||||
|
MetaUIFrame *frame,
|
||||||
|
GdkDrawable *drawable,
|
||||||
|
GdkRectangle *area)
|
||||||
|
{
|
||||||
|
GtkWidget *widget;
|
||||||
|
MetaFrameGeometry fgeom;
|
||||||
|
MetaFrameFlags flags;
|
||||||
|
int width, height;
|
||||||
|
GtkBorder inner;
|
||||||
|
|
||||||
|
widget = GTK_WIDGET (frames);
|
||||||
|
|
||||||
meta_frames_calc_geometry (frames, frame, &fgeom);
|
meta_frames_calc_geometry (frames, frame, &fgeom);
|
||||||
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
flags = meta_core_get_frame_flags (gdk_display, frame->xwindow);
|
||||||
width = fgeom.width;
|
width = fgeom.width;
|
||||||
height = fgeom.height;
|
height = fgeom.height;
|
||||||
|
|
||||||
/* Black line around outside to give definition */
|
/* Black line around outside to give definition */
|
||||||
gdk_draw_rectangle (frame->window,
|
gdk_draw_rectangle (drawable,
|
||||||
widget->style->black_gc,
|
widget->style->black_gc,
|
||||||
FALSE,
|
FALSE,
|
||||||
0, 0, width - 1, height - 1);
|
0, 0, width - 1, height - 1);
|
||||||
|
|
||||||
/* Light GC on top/left edges */
|
/* Light GC on top/left edges */
|
||||||
gdk_draw_line (frame->window,
|
gdk_draw_line (drawable,
|
||||||
widget->style->light_gc[GTK_STATE_NORMAL],
|
widget->style->light_gc[GTK_STATE_NORMAL],
|
||||||
1, 1,
|
1, 1,
|
||||||
1, height - 2);
|
1, height - 2);
|
||||||
gdk_draw_line (frame->window,
|
gdk_draw_line (drawable,
|
||||||
widget->style->light_gc[GTK_STATE_NORMAL],
|
widget->style->light_gc[GTK_STATE_NORMAL],
|
||||||
1, 1,
|
1, 1,
|
||||||
width - 2, 1);
|
width - 2, 1);
|
||||||
/* Dark on bottom/right */
|
/* Dark on bottom/right */
|
||||||
gdk_draw_line (frame->window,
|
gdk_draw_line (drawable,
|
||||||
widget->style->dark_gc[GTK_STATE_NORMAL],
|
widget->style->dark_gc[GTK_STATE_NORMAL],
|
||||||
width - 2, 1,
|
width - 2, 1,
|
||||||
width - 2, height - 2);
|
width - 2, height - 2);
|
||||||
gdk_draw_line (frame->window,
|
gdk_draw_line (drawable,
|
||||||
widget->style->dark_gc[GTK_STATE_NORMAL],
|
widget->style->dark_gc[GTK_STATE_NORMAL],
|
||||||
1, height - 2,
|
1, height - 2,
|
||||||
width - 2, height - 2);
|
width - 2, height - 2);
|
||||||
@ -1502,7 +1559,7 @@ meta_frames_expose_event (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
/* Black line around inside while we have focus */
|
/* Black line around inside while we have focus */
|
||||||
|
|
||||||
gdk_draw_rectangle (frame->window,
|
gdk_draw_rectangle (drawable,
|
||||||
widget->style->black_gc,
|
widget->style->black_gc,
|
||||||
FALSE,
|
FALSE,
|
||||||
fgeom.left_width - 1,
|
fgeom.left_width - 1,
|
||||||
@ -1511,7 +1568,7 @@ meta_frames_expose_event (GtkWidget *widget,
|
|||||||
height - fgeom.bottom_height - fgeom.top_height + 1);
|
height - fgeom.bottom_height - fgeom.top_height + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->area.y < fgeom.top_height &&
|
if (area->y < fgeom.top_height &&
|
||||||
fgeom.title_rect.width > 0 && fgeom.title_rect.height > 0)
|
fgeom.title_rect.width > 0 && fgeom.title_rect.height > 0)
|
||||||
{
|
{
|
||||||
GdkRectangle clip;
|
GdkRectangle clip;
|
||||||
@ -1547,7 +1604,7 @@ meta_frames_expose_event (GtkWidget *widget,
|
|||||||
if (gradient != NULL)
|
if (gradient != NULL)
|
||||||
{
|
{
|
||||||
gdk_pixbuf_render_to_drawable (gradient,
|
gdk_pixbuf_render_to_drawable (gradient,
|
||||||
frame->window,
|
drawable,
|
||||||
widget->style->bg_gc[GTK_STATE_SELECTED],
|
widget->style->bg_gc[GTK_STATE_SELECTED],
|
||||||
0, 0,
|
0, 0,
|
||||||
fgeom.title_rect.x,
|
fgeom.title_rect.x,
|
||||||
@ -1562,7 +1619,7 @@ meta_frames_expose_event (GtkWidget *widget,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Fallback to plain selection color */
|
/* Fallback to plain selection color */
|
||||||
gdk_draw_rectangle (frame->window,
|
gdk_draw_rectangle (drawable,
|
||||||
widget->style->bg_gc[GTK_STATE_SELECTED],
|
widget->style->bg_gc[GTK_STATE_SELECTED],
|
||||||
TRUE,
|
TRUE,
|
||||||
fgeom.title_rect.x,
|
fgeom.title_rect.x,
|
||||||
@ -1630,7 +1687,7 @@ meta_frames_expose_event (GtkWidget *widget,
|
|||||||
if (gdk_rectangle_intersect (&clip, &pixbuf_rect, &draw_rect))
|
if (gdk_rectangle_intersect (&clip, &pixbuf_rect, &draw_rect))
|
||||||
{
|
{
|
||||||
gdk_pixbuf_render_to_drawable_alpha (icon,
|
gdk_pixbuf_render_to_drawable_alpha (icon,
|
||||||
frame->window,
|
drawable,
|
||||||
draw_rect.x - pixbuf_rect.x,
|
draw_rect.x - pixbuf_rect.x,
|
||||||
draw_rect.y - pixbuf_rect.y,
|
draw_rect.y - pixbuf_rect.y,
|
||||||
draw_rect.x, draw_rect.y,
|
draw_rect.x, draw_rect.y,
|
||||||
@ -1643,7 +1700,7 @@ meta_frames_expose_event (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gdk_draw_layout (frame->window,
|
gdk_draw_layout (drawable,
|
||||||
layout_gc,
|
layout_gc,
|
||||||
x, y,
|
x, y,
|
||||||
frame->layout);
|
frame->layout);
|
||||||
@ -1655,9 +1712,10 @@ meta_frames_expose_event (GtkWidget *widget,
|
|||||||
|
|
||||||
if (fgeom.close_rect.width > 0 && fgeom.close_rect.height > 0)
|
if (fgeom.close_rect.width > 0 && fgeom.close_rect.height > 0)
|
||||||
{
|
{
|
||||||
draw_control_bg (frames, frame, META_FRAME_CONTROL_DELETE, &fgeom);
|
draw_control_bg (frames, frame, drawable,
|
||||||
|
META_FRAME_CONTROL_DELETE, &fgeom);
|
||||||
|
|
||||||
draw_control (frames, frame->window,
|
draw_control (frames, drawable,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
META_FRAME_CONTROL_DELETE,
|
META_FRAME_CONTROL_DELETE,
|
||||||
fgeom.close_rect.x + inner.left,
|
fgeom.close_rect.x + inner.left,
|
||||||
@ -1675,9 +1733,9 @@ meta_frames_expose_event (GtkWidget *widget,
|
|||||||
else
|
else
|
||||||
ctrl = META_FRAME_CONTROL_MAXIMIZE;
|
ctrl = META_FRAME_CONTROL_MAXIMIZE;
|
||||||
|
|
||||||
draw_control_bg (frames, frame, ctrl, &fgeom);
|
draw_control_bg (frames, frame, drawable, ctrl, &fgeom);
|
||||||
|
|
||||||
draw_control (frames, frame->window,
|
draw_control (frames, drawable,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
ctrl,
|
ctrl,
|
||||||
fgeom.max_rect.x + inner.left,
|
fgeom.max_rect.x + inner.left,
|
||||||
@ -1688,9 +1746,10 @@ meta_frames_expose_event (GtkWidget *widget,
|
|||||||
|
|
||||||
if (fgeom.min_rect.width > 0 && fgeom.min_rect.height > 0)
|
if (fgeom.min_rect.width > 0 && fgeom.min_rect.height > 0)
|
||||||
{
|
{
|
||||||
draw_control_bg (frames, frame, META_FRAME_CONTROL_MINIMIZE, &fgeom);
|
draw_control_bg (frames, frame, drawable,
|
||||||
|
META_FRAME_CONTROL_MINIMIZE, &fgeom);
|
||||||
|
|
||||||
draw_control (frames, frame->window,
|
draw_control (frames, drawable,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
META_FRAME_CONTROL_MINIMIZE,
|
META_FRAME_CONTROL_MINIMIZE,
|
||||||
fgeom.min_rect.x + inner.left,
|
fgeom.min_rect.x + inner.left,
|
||||||
@ -1702,9 +1761,9 @@ meta_frames_expose_event (GtkWidget *widget,
|
|||||||
if (fgeom.spacer_rect.width > 0 && fgeom.spacer_rect.height > 0)
|
if (fgeom.spacer_rect.width > 0 && fgeom.spacer_rect.height > 0)
|
||||||
{
|
{
|
||||||
gtk_paint_vline (widget->style,
|
gtk_paint_vline (widget->style,
|
||||||
frame->window,
|
drawable,
|
||||||
GTK_STATE_NORMAL,
|
GTK_STATE_NORMAL,
|
||||||
&event->area,
|
area,
|
||||||
widget,
|
widget,
|
||||||
"metacity_frame_spacer",
|
"metacity_frame_spacer",
|
||||||
fgeom.spacer_rect.y,
|
fgeom.spacer_rect.y,
|
||||||
@ -1718,7 +1777,9 @@ meta_frames_expose_event (GtkWidget *widget,
|
|||||||
#define ARROW_WIDTH 7
|
#define ARROW_WIDTH 7
|
||||||
#define ARROW_HEIGHT 5
|
#define ARROW_HEIGHT 5
|
||||||
|
|
||||||
draw_control_bg (frames, frame, META_FRAME_CONTROL_MENU, &fgeom);
|
draw_control_bg (frames, frame,
|
||||||
|
drawable,
|
||||||
|
META_FRAME_CONTROL_MENU, &fgeom);
|
||||||
|
|
||||||
x = fgeom.menu_rect.x;
|
x = fgeom.menu_rect.x;
|
||||||
y = fgeom.menu_rect.y;
|
y = fgeom.menu_rect.y;
|
||||||
@ -1726,18 +1787,16 @@ meta_frames_expose_event (GtkWidget *widget,
|
|||||||
y += (fgeom.menu_rect.height - ARROW_HEIGHT) / 2;
|
y += (fgeom.menu_rect.height - ARROW_HEIGHT) / 2;
|
||||||
|
|
||||||
gtk_paint_arrow (widget->style,
|
gtk_paint_arrow (widget->style,
|
||||||
frame->window,
|
drawable,
|
||||||
GTK_STATE_NORMAL,
|
GTK_STATE_NORMAL,
|
||||||
GTK_SHADOW_OUT,
|
GTK_SHADOW_OUT,
|
||||||
&event->area,
|
area,
|
||||||
widget,
|
widget,
|
||||||
"metacity_menu_button",
|
"metacity_menu_button",
|
||||||
GTK_ARROW_DOWN,
|
GTK_ARROW_DOWN,
|
||||||
TRUE,
|
TRUE,
|
||||||
x, y, ARROW_WIDTH, ARROW_HEIGHT);
|
x, y, ARROW_WIDTH, ARROW_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -113,6 +113,10 @@ void meta_frames_get_geometry (MetaFrames *frames,
|
|||||||
|
|
||||||
void meta_frames_reset_bg (MetaFrames *frames,
|
void meta_frames_reset_bg (MetaFrames *frames,
|
||||||
Window xwindow);
|
Window xwindow);
|
||||||
|
void meta_frames_unflicker_bg (MetaFrames *frames,
|
||||||
|
Window xwindow,
|
||||||
|
int target_width,
|
||||||
|
int target_height);
|
||||||
|
|
||||||
void meta_frames_queue_draw (MetaFrames *frames,
|
void meta_frames_queue_draw (MetaFrames *frames,
|
||||||
Window xwindow);
|
Window xwindow);
|
||||||
|
10
src/ui.c
10
src/ui.c
@ -188,6 +188,16 @@ meta_ui_unmap_frame (MetaUI *ui,
|
|||||||
gdk_window_hide (window);
|
gdk_window_hide (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_ui_unflicker_frame_bg (MetaUI *ui,
|
||||||
|
Window xwindow,
|
||||||
|
int target_width,
|
||||||
|
int target_height)
|
||||||
|
{
|
||||||
|
meta_frames_unflicker_bg (ui->frames, xwindow,
|
||||||
|
target_width, target_height);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
meta_ui_reset_frame_bg (MetaUI *ui,
|
meta_ui_reset_frame_bg (MetaUI *ui,
|
||||||
Window xwindow)
|
Window xwindow)
|
||||||
|
4
src/ui.h
4
src/ui.h
@ -66,6 +66,10 @@ void meta_ui_map_frame (MetaUI *ui,
|
|||||||
void meta_ui_unmap_frame (MetaUI *ui,
|
void meta_ui_unmap_frame (MetaUI *ui,
|
||||||
Window xwindow);
|
Window xwindow);
|
||||||
|
|
||||||
|
void meta_ui_unflicker_frame_bg (MetaUI *ui,
|
||||||
|
Window xwindow,
|
||||||
|
int target_width,
|
||||||
|
int target_height);
|
||||||
void meta_ui_reset_frame_bg (MetaUI *ui,
|
void meta_ui_reset_frame_bg (MetaUI *ui,
|
||||||
Window xwindow);
|
Window xwindow);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user