From 8fdbae192a7e150b67090aee2d2059c0669b313e Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 31 Dec 2014 22:09:23 -0800 Subject: [PATCH] frame: Start converting over to direct usage of MetaUIFrame --- src/core/frame.c | 30 ++++------- src/ui/frames.c | 128 ++++++++++------------------------------------- src/ui/frames.h | 49 ++++++++---------- src/ui/ui.c | 76 ---------------------------- src/ui/ui.h | 30 ----------- 5 files changed, 57 insertions(+), 256 deletions(-) diff --git a/src/core/frame.c b/src/core/frame.c index 41934d744..529a7c655 100644 --- a/src/core/frame.c +++ b/src/core/frame.c @@ -213,7 +213,7 @@ meta_window_destroy_frame (MetaWindow *window) window->frame->rect.y + borders.invisible.top); 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, frame->xwindow); @@ -333,9 +333,7 @@ meta_frame_calc_borders (MetaFrame *frame, { if (!frame->borders_cached) { - meta_ui_get_frame_borders (frame->window->screen->ui, - frame->xwindow, - &frame->cached_borders); + meta_ui_frame_get_borders (frame->ui_frame, &frame->cached_borders); frame->borders_cached = TRUE; } @@ -360,8 +358,7 @@ meta_frame_sync_to_window (MetaFrame *frame, frame->rect.x + frame->rect.width, frame->rect.y + frame->rect.height); - meta_ui_move_resize_frame (frame->window->screen->ui, - frame->xwindow, + meta_ui_frame_move_resize (frame->ui_frame, frame->rect.x, frame->rect.y, frame->rect.width, @@ -372,10 +369,8 @@ meta_frame_sync_to_window (MetaFrame *frame, /* If we're interactively resizing the frame, repaint * it immediately so we don't start to lag. */ - if (frame->window->display->grab_window == - frame->window) - meta_ui_repaint_frame (frame->window->screen->ui, - frame->xwindow); + if (frame->window->display->grab_window == frame->window) + meta_ui_frame_repaint (frame->ui_frame); } return need_resize; @@ -384,25 +379,20 @@ meta_frame_sync_to_window (MetaFrame *frame, cairo_region_t * meta_frame_get_frame_bounds (MetaFrame *frame) { - return meta_ui_get_frame_bounds (frame->window->screen->ui, - frame->xwindow, - frame->rect.width, - frame->rect.height); + return meta_ui_frame_get_bounds (frame->ui_frame, frame->rect.width, frame->rect.height); } void meta_frame_get_mask (MetaFrame *frame, cairo_t *cr) { - meta_ui_get_frame_mask (frame->window->screen->ui, frame->xwindow, - frame->rect.width, frame->rect.height, cr); + meta_ui_frame_get_mask (frame->ui_frame, frame->rect.width, frame->rect.height, cr); } void meta_frame_queue_draw (MetaFrame *frame) { - meta_ui_queue_frame_draw (frame->window->screen->ui, - frame->xwindow); + meta_ui_frame_queue_draw (frame->ui_frame); } void @@ -433,12 +423,12 @@ meta_frame_get_xwindow (MetaFrame *frame) void 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 meta_frame_update_title (MetaFrame *frame) { 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); } diff --git a/src/ui/frames.c b/src/ui/frames.c index 095bb97c6..32f172b52 100644 --- a/src/ui/frames.c +++ b/src/ui/frames.c @@ -244,11 +244,8 @@ meta_frames_destroy (GtkWidget *object) /* Unmanage all frames */ for (tmp = winlist; tmp != NULL; tmp = tmp->next) { - MetaUIFrame *frame; - - frame = tmp->data; - - meta_frames_unmanage_window (frames, frame->xwindow); + MetaUIFrame *frame = tmp->data; + meta_ui_frame_unmanage (frame); } g_slist_free (winlist); @@ -549,18 +546,9 @@ meta_frames_manage_window (MetaFrames *frames, } void -meta_frames_unmanage_window (MetaFrames *frames, - Window xwindow) +meta_ui_frame_unmanage (MetaUIFrame *frame) { - MetaUIFrame *frame; - - frame = g_hash_table_lookup (frames->frames, &xwindow); - - if (!frame) - { - meta_warning ("Frame 0x%lx not managed, can't unmanage\n", xwindow); - return; - } + MetaFrames *frames = frame->frames; /* restore the cursor */ 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); } -static MetaUIFrame* -meta_frames_lookup_window (MetaFrames *frames, - Window xwindow) -{ - MetaUIFrame *frame; - - frame = g_hash_table_lookup (frames->frames, &xwindow); - - return frame; -} - -static void +void meta_ui_frame_get_borders (MetaUIFrame *frame, MetaFrameBorders *borders) { @@ -626,21 +603,6 @@ meta_ui_frame_get_borders (MetaUIFrame *frame, 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 visible and invisible borders from the frame window's size. */ @@ -766,31 +728,19 @@ get_visible_region (MetaUIFrame *frame, } cairo_region_t * -meta_frames_get_frame_bounds (MetaFrames *frames, - Window xwindow, - int window_width, - int window_height) +meta_ui_frame_get_bounds (MetaUIFrame *frame, + int window_width, + int window_height) { - MetaUIFrame *frame; MetaFrameGeometry fgeom; - - frame = meta_frames_lookup_window (frames, xwindow); - g_return_val_if_fail (frame != NULL, NULL); - meta_frames_calc_geometry (frame, &fgeom); - return get_visible_region (frame, &fgeom, window_width, window_height); } void -meta_frames_move_resize_frame (MetaFrames *frames, - Window xwindow, - int x, - int y, - int width, - int height) +meta_ui_frame_move_resize (MetaUIFrame *frame, + int x, int y, int width, int height) { - MetaUIFrame *frame = meta_frames_lookup_window (frames, xwindow); int old_width, old_height; old_width = gdk_window_get_width (frame->window); @@ -803,27 +753,15 @@ meta_frames_move_resize_frame (MetaFrames *frames, } void -meta_frames_queue_draw (MetaFrames *frames, - Window xwindow) +meta_ui_frame_queue_draw (MetaUIFrame *frame) { - MetaUIFrame *frame; - - frame = meta_frames_lookup_window (frames, xwindow); - invalidate_whole_window (frame); } void -meta_frames_set_title (MetaFrames *frames, - Window xwindow, - const char *title) +meta_ui_frame_set_title (MetaUIFrame *frame, + const char *title) { - MetaUIFrame *frame; - - frame = meta_frames_lookup_window (frames, xwindow); - - g_assert (frame); - g_free (frame->title); frame->title = g_strdup (title); @@ -833,29 +771,15 @@ meta_frames_set_title (MetaFrames *frames, } void -meta_frames_update_frame_style (MetaFrames *frames, - Window xwindow) +meta_ui_frame_update_style (MetaUIFrame *frame) { - MetaUIFrame *frame; - - frame = meta_frames_lookup_window (frames, xwindow); - - g_assert (frame); - meta_frames_attach_style (frame); invalidate_whole_window (frame); } void -meta_frames_repaint_frame (MetaFrames *frames, - Window xwindow) +meta_ui_frame_repaint (MetaUIFrame *frame) { - MetaUIFrame *frame; - - frame = meta_frames_lookup_window (frames, xwindow); - - g_assert (frame); - /* repaint everything, so the other frame don't * lag behind if they are exposed */ @@ -876,6 +800,13 @@ redraw_control (MetaUIFrame *frame, 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 meta_frame_titlebar_event (MetaUIFrame *frame, GdkEventButton *event, @@ -1567,21 +1498,16 @@ get_visible_frame_border_region (MetaUIFrame *frame) * @cr: Used to draw the resulting mask */ void -meta_frames_get_mask (MetaFrames *frames, - Window xwindow, - guint width, - guint height, - cairo_t *cr) +meta_ui_frame_get_mask (MetaUIFrame *frame, + guint width, + guint height, + cairo_t *cr) { - MetaUIFrame *frame = meta_frames_lookup_window (frames, xwindow); MetaFrameBorders borders; MetaFrameFlags flags; - if (frame == NULL) - meta_bug ("No such frame 0x%lx\n", xwindow); - meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), - xwindow, + frame->xwindow, META_CORE_GET_FRAME_FLAGS, &flags, META_CORE_GET_END); diff --git a/src/ui/frames.h b/src/ui/frames.h index de9853b3d..534c6acc9 100644 --- a/src/ui/frames.h +++ b/src/ui/frames.h @@ -123,41 +123,32 @@ MetaFrames *meta_frames_new (int screen_number); MetaUIFrame * meta_frames_manage_window (MetaFrames *frames, Window xwindow, 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, - Window xwindow); +void meta_ui_frame_unmanage (MetaUIFrame *frame); -void meta_frames_repaint_frame (MetaFrames *frames, - Window xwindow); +void meta_ui_frame_set_title (MetaUIFrame *frame, + const char *title); -void meta_frames_get_borders (MetaFrames *frames, - Window xwindow, - MetaFrameBorders *borders); +void meta_ui_frame_update_style (MetaUIFrame *frame); -cairo_region_t *meta_frames_get_frame_bounds (MetaFrames *frames, - Window xwindow, - int window_width, - int window_height); +void meta_ui_frame_repaint (MetaUIFrame *frame); -void meta_frames_get_mask (MetaFrames *frames, - Window xwindow, - guint width, - guint height, - cairo_t *cr); +void meta_ui_frame_get_borders (MetaUIFrame *frame, + MetaFrameBorders *borders); -void meta_frames_move_resize_frame (MetaFrames *frames, - Window xwindow, - int x, - int y, - int width, - int height); -void meta_frames_queue_draw (MetaFrames *frames, - Window xwindow); +cairo_region_t * meta_ui_frame_get_bounds (MetaUIFrame *frame, + int window_width, + int window_height); + +void meta_ui_frame_get_mask (MetaUIFrame *frame, + guint width, + guint height, + 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); diff --git a/src/ui/ui.c b/src/ui/ui.c index 880d7f445..22fb0878e 100644 --- a/src/ui/ui.c +++ b/src/ui/ui.c @@ -312,25 +312,6 @@ meta_ui_free (MetaUI *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 set_background_none (Display *xdisplay, Window xwindow) @@ -413,24 +394,6 @@ meta_ui_create_frame (MetaUI *ui, 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 meta_ui_map_frame (MetaUI *ui, Window xwindow) @@ -459,45 +422,6 @@ meta_ui_unmap_frame (MetaUI *ui, 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 meta_ui_window_should_not_cause_focus (Display *xdisplay, Window xwindow) diff --git a/src/ui/ui.h b/src/ui/ui.h index 33d364abf..5c34410f8 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -49,15 +49,6 @@ void meta_ui_theme_get_frame_borders (MetaUI *ui, MetaFrameType type, MetaFrameFlags flags, 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, Display *xdisplay, @@ -68,8 +59,6 @@ MetaUIFrame * meta_ui_create_frame (MetaUI *ui, gint height, gint screen_no, gulong *create_serial); -void meta_ui_destroy_frame_window (MetaUI *ui, - Window xwindow); void meta_ui_move_resize_frame (MetaUI *ui, Window frame, int x, @@ -83,25 +72,6 @@ void meta_ui_map_frame (MetaUI *ui, void meta_ui_unmap_frame (MetaUI *ui, 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, Window xwindow);