frame: Start converting over to direct usage of MetaUIFrame

This commit is contained in:
Jasper St. Pierre 2014-12-31 22:09:23 -08:00
parent 2413e672c8
commit 8fdbae192a
5 changed files with 57 additions and 256 deletions

View File

@ -213,7 +213,7 @@ meta_window_destroy_frame (MetaWindow *window)
window->frame->rect.y + borders.invisible.top); window->frame->rect.y + borders.invisible.top);
meta_error_trap_pop (window->display); meta_error_trap_pop (window->display);
meta_ui_destroy_frame_window (window->screen->ui, frame->xwindow); meta_ui_frame_unmanage (frame->ui_frame);
meta_display_unregister_x_window (window->display, meta_display_unregister_x_window (window->display,
frame->xwindow); frame->xwindow);
@ -333,9 +333,7 @@ meta_frame_calc_borders (MetaFrame *frame,
{ {
if (!frame->borders_cached) if (!frame->borders_cached)
{ {
meta_ui_get_frame_borders (frame->window->screen->ui, meta_ui_frame_get_borders (frame->ui_frame, &frame->cached_borders);
frame->xwindow,
&frame->cached_borders);
frame->borders_cached = TRUE; frame->borders_cached = TRUE;
} }
@ -360,8 +358,7 @@ meta_frame_sync_to_window (MetaFrame *frame,
frame->rect.x + frame->rect.width, frame->rect.x + frame->rect.width,
frame->rect.y + frame->rect.height); frame->rect.y + frame->rect.height);
meta_ui_move_resize_frame (frame->window->screen->ui, meta_ui_frame_move_resize (frame->ui_frame,
frame->xwindow,
frame->rect.x, frame->rect.x,
frame->rect.y, frame->rect.y,
frame->rect.width, frame->rect.width,
@ -372,10 +369,8 @@ meta_frame_sync_to_window (MetaFrame *frame,
/* If we're interactively resizing the frame, repaint /* If we're interactively resizing the frame, repaint
* it immediately so we don't start to lag. * it immediately so we don't start to lag.
*/ */
if (frame->window->display->grab_window == if (frame->window->display->grab_window == frame->window)
frame->window) meta_ui_frame_repaint (frame->ui_frame);
meta_ui_repaint_frame (frame->window->screen->ui,
frame->xwindow);
} }
return need_resize; return need_resize;
@ -384,25 +379,20 @@ meta_frame_sync_to_window (MetaFrame *frame,
cairo_region_t * cairo_region_t *
meta_frame_get_frame_bounds (MetaFrame *frame) meta_frame_get_frame_bounds (MetaFrame *frame)
{ {
return meta_ui_get_frame_bounds (frame->window->screen->ui, return meta_ui_frame_get_bounds (frame->ui_frame, frame->rect.width, frame->rect.height);
frame->xwindow,
frame->rect.width,
frame->rect.height);
} }
void void
meta_frame_get_mask (MetaFrame *frame, meta_frame_get_mask (MetaFrame *frame,
cairo_t *cr) cairo_t *cr)
{ {
meta_ui_get_frame_mask (frame->window->screen->ui, frame->xwindow, meta_ui_frame_get_mask (frame->ui_frame, frame->rect.width, frame->rect.height, cr);
frame->rect.width, frame->rect.height, cr);
} }
void void
meta_frame_queue_draw (MetaFrame *frame) meta_frame_queue_draw (MetaFrame *frame)
{ {
meta_ui_queue_frame_draw (frame->window->screen->ui, meta_ui_frame_queue_draw (frame->ui_frame);
frame->xwindow);
} }
void void
@ -433,12 +423,12 @@ meta_frame_get_xwindow (MetaFrame *frame)
void void
meta_frame_update_style (MetaFrame *frame) meta_frame_update_style (MetaFrame *frame)
{ {
meta_ui_update_frame_style (frame->window->screen->ui, frame->xwindow); meta_ui_frame_update_style (frame->ui_frame);
} }
void void
meta_frame_update_title (MetaFrame *frame) meta_frame_update_title (MetaFrame *frame)
{ {
if (frame->window->title) if (frame->window->title)
meta_ui_set_frame_title (frame->window->screen->ui, frame->xwindow, frame->window->title); meta_ui_frame_set_title (frame->ui_frame, frame->window->title);
} }

View File

@ -244,11 +244,8 @@ meta_frames_destroy (GtkWidget *object)
/* Unmanage all frames */ /* Unmanage all frames */
for (tmp = winlist; tmp != NULL; tmp = tmp->next) for (tmp = winlist; tmp != NULL; tmp = tmp->next)
{ {
MetaUIFrame *frame; MetaUIFrame *frame = tmp->data;
meta_ui_frame_unmanage (frame);
frame = tmp->data;
meta_frames_unmanage_window (frames, frame->xwindow);
} }
g_slist_free (winlist); g_slist_free (winlist);
@ -549,18 +546,9 @@ meta_frames_manage_window (MetaFrames *frames,
} }
void void
meta_frames_unmanage_window (MetaFrames *frames, meta_ui_frame_unmanage (MetaUIFrame *frame)
Window xwindow)
{ {
MetaUIFrame *frame; MetaFrames *frames = frame->frames;
frame = g_hash_table_lookup (frames->frames, &xwindow);
if (!frame)
{
meta_warning ("Frame 0x%lx not managed, can't unmanage\n", xwindow);
return;
}
/* restore the cursor */ /* restore the cursor */
meta_core_set_screen_cursor (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), meta_core_set_screen_cursor (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
@ -586,18 +574,7 @@ meta_frames_unmanage_window (MetaFrames *frames,
g_free (frame); g_free (frame);
} }
static MetaUIFrame* void
meta_frames_lookup_window (MetaFrames *frames,
Window xwindow)
{
MetaUIFrame *frame;
frame = g_hash_table_lookup (frames->frames, &xwindow);
return frame;
}
static void
meta_ui_frame_get_borders (MetaUIFrame *frame, meta_ui_frame_get_borders (MetaUIFrame *frame,
MetaFrameBorders *borders) MetaFrameBorders *borders)
{ {
@ -626,21 +603,6 @@ meta_ui_frame_get_borders (MetaUIFrame *frame,
borders); borders);
} }
void
meta_frames_get_borders (MetaFrames *frames,
Window xwindow,
MetaFrameBorders *borders)
{
MetaUIFrame *frame;
frame = meta_frames_lookup_window (frames, xwindow);
if (frame == NULL)
meta_bug ("No such frame 0x%lx\n", xwindow);
meta_ui_frame_get_borders (frame, borders);
}
/* The client rectangle surrounds client window; it subtracts both /* The client rectangle surrounds client window; it subtracts both
* the visible and invisible borders from the frame window's size. * the visible and invisible borders from the frame window's size.
*/ */
@ -766,31 +728,19 @@ get_visible_region (MetaUIFrame *frame,
} }
cairo_region_t * cairo_region_t *
meta_frames_get_frame_bounds (MetaFrames *frames, meta_ui_frame_get_bounds (MetaUIFrame *frame,
Window xwindow, int window_width,
int window_width, int window_height)
int window_height)
{ {
MetaUIFrame *frame;
MetaFrameGeometry fgeom; MetaFrameGeometry fgeom;
frame = meta_frames_lookup_window (frames, xwindow);
g_return_val_if_fail (frame != NULL, NULL);
meta_frames_calc_geometry (frame, &fgeom); meta_frames_calc_geometry (frame, &fgeom);
return get_visible_region (frame, &fgeom, window_width, window_height); return get_visible_region (frame, &fgeom, window_width, window_height);
} }
void void
meta_frames_move_resize_frame (MetaFrames *frames, meta_ui_frame_move_resize (MetaUIFrame *frame,
Window xwindow, int x, int y, int width, int height)
int x,
int y,
int width,
int height)
{ {
MetaUIFrame *frame = meta_frames_lookup_window (frames, xwindow);
int old_width, old_height; int old_width, old_height;
old_width = gdk_window_get_width (frame->window); old_width = gdk_window_get_width (frame->window);
@ -803,27 +753,15 @@ meta_frames_move_resize_frame (MetaFrames *frames,
} }
void void
meta_frames_queue_draw (MetaFrames *frames, meta_ui_frame_queue_draw (MetaUIFrame *frame)
Window xwindow)
{ {
MetaUIFrame *frame;
frame = meta_frames_lookup_window (frames, xwindow);
invalidate_whole_window (frame); invalidate_whole_window (frame);
} }
void void
meta_frames_set_title (MetaFrames *frames, meta_ui_frame_set_title (MetaUIFrame *frame,
Window xwindow, const char *title)
const char *title)
{ {
MetaUIFrame *frame;
frame = meta_frames_lookup_window (frames, xwindow);
g_assert (frame);
g_free (frame->title); g_free (frame->title);
frame->title = g_strdup (title); frame->title = g_strdup (title);
@ -833,29 +771,15 @@ meta_frames_set_title (MetaFrames *frames,
} }
void void
meta_frames_update_frame_style (MetaFrames *frames, meta_ui_frame_update_style (MetaUIFrame *frame)
Window xwindow)
{ {
MetaUIFrame *frame;
frame = meta_frames_lookup_window (frames, xwindow);
g_assert (frame);
meta_frames_attach_style (frame); meta_frames_attach_style (frame);
invalidate_whole_window (frame); invalidate_whole_window (frame);
} }
void void
meta_frames_repaint_frame (MetaFrames *frames, meta_ui_frame_repaint (MetaUIFrame *frame)
Window xwindow)
{ {
MetaUIFrame *frame;
frame = meta_frames_lookup_window (frames, xwindow);
g_assert (frame);
/* repaint everything, so the other frame don't /* repaint everything, so the other frame don't
* lag behind if they are exposed * lag behind if they are exposed
*/ */
@ -876,6 +800,13 @@ redraw_control (MetaUIFrame *frame,
gdk_window_invalidate_rect (frame->window, rect, FALSE); gdk_window_invalidate_rect (frame->window, rect, FALSE);
} }
static MetaUIFrame*
meta_frames_lookup_window (MetaFrames *frames,
Window xwindow)
{
return g_hash_table_lookup (frames->frames, &xwindow);
}
static gboolean static gboolean
meta_frame_titlebar_event (MetaUIFrame *frame, meta_frame_titlebar_event (MetaUIFrame *frame,
GdkEventButton *event, GdkEventButton *event,
@ -1567,21 +1498,16 @@ get_visible_frame_border_region (MetaUIFrame *frame)
* @cr: Used to draw the resulting mask * @cr: Used to draw the resulting mask
*/ */
void void
meta_frames_get_mask (MetaFrames *frames, meta_ui_frame_get_mask (MetaUIFrame *frame,
Window xwindow, guint width,
guint width, guint height,
guint height, cairo_t *cr)
cairo_t *cr)
{ {
MetaUIFrame *frame = meta_frames_lookup_window (frames, xwindow);
MetaFrameBorders borders; MetaFrameBorders borders;
MetaFrameFlags flags; MetaFrameFlags flags;
if (frame == NULL)
meta_bug ("No such frame 0x%lx\n", xwindow);
meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
xwindow, frame->xwindow,
META_CORE_GET_FRAME_FLAGS, &flags, META_CORE_GET_FRAME_FLAGS, &flags,
META_CORE_GET_END); META_CORE_GET_END);

View File

@ -123,41 +123,32 @@ MetaFrames *meta_frames_new (int screen_number);
MetaUIFrame * meta_frames_manage_window (MetaFrames *frames, MetaUIFrame * meta_frames_manage_window (MetaFrames *frames,
Window xwindow, Window xwindow,
GdkWindow *window); GdkWindow *window);
void meta_frames_unmanage_window (MetaFrames *frames,
Window xwindow);
void meta_frames_set_title (MetaFrames *frames,
Window xwindow,
const char *title);
void meta_frames_update_frame_style (MetaFrames *frames, void meta_ui_frame_unmanage (MetaUIFrame *frame);
Window xwindow);
void meta_frames_repaint_frame (MetaFrames *frames, void meta_ui_frame_set_title (MetaUIFrame *frame,
Window xwindow); const char *title);
void meta_frames_get_borders (MetaFrames *frames, void meta_ui_frame_update_style (MetaUIFrame *frame);
Window xwindow,
MetaFrameBorders *borders);
cairo_region_t *meta_frames_get_frame_bounds (MetaFrames *frames, void meta_ui_frame_repaint (MetaUIFrame *frame);
Window xwindow,
int window_width,
int window_height);
void meta_frames_get_mask (MetaFrames *frames, void meta_ui_frame_get_borders (MetaUIFrame *frame,
Window xwindow, MetaFrameBorders *borders);
guint width,
guint height,
cairo_t *cr);
void meta_frames_move_resize_frame (MetaFrames *frames, cairo_region_t * meta_ui_frame_get_bounds (MetaUIFrame *frame,
Window xwindow, int window_width,
int x, int window_height);
int y,
int width, void meta_ui_frame_get_mask (MetaUIFrame *frame,
int height); guint width,
void meta_frames_queue_draw (MetaFrames *frames, guint height,
Window xwindow); cairo_t *cr);
void meta_ui_frame_move_resize (MetaUIFrame *frame,
int x, int y, int width, int height);
void meta_ui_frame_queue_draw (MetaUIFrame *frame);
Window meta_frames_get_moving_frame (MetaFrames *frames); Window meta_frames_get_moving_frame (MetaFrames *frames);

View File

@ -312,25 +312,6 @@ meta_ui_free (MetaUI *ui)
g_free (ui); g_free (ui);
} }
void
meta_ui_get_frame_mask (MetaUI *ui,
Window frame_xwindow,
guint width,
guint height,
cairo_t *cr)
{
meta_frames_get_mask (ui->frames, frame_xwindow, width, height, cr);
}
void
meta_ui_get_frame_borders (MetaUI *ui,
Window frame_xwindow,
MetaFrameBorders *borders)
{
meta_frames_get_borders (ui->frames, frame_xwindow,
borders);
}
static void static void
set_background_none (Display *xdisplay, set_background_none (Display *xdisplay,
Window xwindow) Window xwindow)
@ -413,24 +394,6 @@ meta_ui_create_frame (MetaUI *ui,
return meta_frames_manage_window (ui->frames, GDK_WINDOW_XID (window), window); return meta_frames_manage_window (ui->frames, GDK_WINDOW_XID (window), window);
} }
void
meta_ui_destroy_frame_window (MetaUI *ui,
Window xwindow)
{
meta_frames_unmanage_window (ui->frames, xwindow);
}
void
meta_ui_move_resize_frame (MetaUI *ui,
Window frame,
int x,
int y,
int width,
int height)
{
meta_frames_move_resize_frame (ui->frames, frame, x, y, width, height);
}
void void
meta_ui_map_frame (MetaUI *ui, meta_ui_map_frame (MetaUI *ui,
Window xwindow) Window xwindow)
@ -459,45 +422,6 @@ meta_ui_unmap_frame (MetaUI *ui,
gdk_window_hide (window); gdk_window_hide (window);
} }
void
meta_ui_update_frame_style (MetaUI *ui,
Window xwindow)
{
meta_frames_update_frame_style (ui->frames, xwindow);
}
void
meta_ui_repaint_frame (MetaUI *ui,
Window xwindow)
{
meta_frames_repaint_frame (ui->frames, xwindow);
}
cairo_region_t *
meta_ui_get_frame_bounds (MetaUI *ui,
Window xwindow,
int window_width,
int window_height)
{
return meta_frames_get_frame_bounds (ui->frames, xwindow,
window_width, window_height);
}
void
meta_ui_queue_frame_draw (MetaUI *ui,
Window xwindow)
{
meta_frames_queue_draw (ui->frames, xwindow);
}
void
meta_ui_set_frame_title (MetaUI *ui,
Window xwindow,
const char *title)
{
meta_frames_set_title (ui->frames, xwindow, title);
}
gboolean gboolean
meta_ui_window_should_not_cause_focus (Display *xdisplay, meta_ui_window_should_not_cause_focus (Display *xdisplay,
Window xwindow) Window xwindow)

View File

@ -49,15 +49,6 @@ void meta_ui_theme_get_frame_borders (MetaUI *ui,
MetaFrameType type, MetaFrameType type,
MetaFrameFlags flags, MetaFrameFlags flags,
MetaFrameBorders *borders); MetaFrameBorders *borders);
void meta_ui_get_frame_borders (MetaUI *ui,
Window frame_xwindow,
MetaFrameBorders *borders);
void meta_ui_get_frame_mask (MetaUI *ui,
Window frame_xwindow,
guint width,
guint height,
cairo_t *cr);
MetaUIFrame * meta_ui_create_frame (MetaUI *ui, MetaUIFrame * meta_ui_create_frame (MetaUI *ui,
Display *xdisplay, Display *xdisplay,
@ -68,8 +59,6 @@ MetaUIFrame * meta_ui_create_frame (MetaUI *ui,
gint height, gint height,
gint screen_no, gint screen_no,
gulong *create_serial); gulong *create_serial);
void meta_ui_destroy_frame_window (MetaUI *ui,
Window xwindow);
void meta_ui_move_resize_frame (MetaUI *ui, void meta_ui_move_resize_frame (MetaUI *ui,
Window frame, Window frame,
int x, int x,
@ -83,25 +72,6 @@ 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);
cairo_region_t *meta_ui_get_frame_bounds (MetaUI *ui,
Window xwindow,
int window_width,
int window_height);
void meta_ui_queue_frame_draw (MetaUI *ui,
Window xwindow);
void meta_ui_set_frame_title (MetaUI *ui,
Window xwindow,
const char *title);
void meta_ui_update_frame_style (MetaUI *ui,
Window window);
void meta_ui_repaint_frame (MetaUI *ui,
Window xwindow);
gboolean meta_ui_window_should_not_cause_focus (Display *xdisplay, gboolean meta_ui_window_should_not_cause_focus (Display *xdisplay,
Window xwindow); Window xwindow);