Skip to content

Commit daa2a8a

Browse files
committed
window/x11: Use G_DECLARE_DERIVABLE_TYPE()
This removes the MetaWindowX11::priv pointer. It is replaced with a meta_window_x11_get_private() helper function, and another method to get the client rect without going through MetaWindowX11Private.
1 parent 613c4a0 commit daa2a8a

File tree

5 files changed

+47
-41
lines changed

5 files changed

+47
-41
lines changed

src/ui/frames.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ meta_ui_frame_calc_geometry (MetaUIFrame *frame,
421421
MetaFrameType type;
422422
MetaButtonLayout button_layout;
423423
MetaWindowX11 *window_x11 = META_WINDOW_X11 (frame->meta_window);
424-
MetaWindowX11Private *priv = window_x11->priv;
424+
MetaRectangle client_rect;
425425

426426
flags = meta_frame_get_flags (frame->meta_window->frame);
427427
type = meta_window_get_frame_type (frame->meta_window);
@@ -430,13 +430,15 @@ meta_ui_frame_calc_geometry (MetaUIFrame *frame,
430430

431431
meta_prefs_get_button_layout (&button_layout);
432432

433+
client_rect = meta_window_x11_get_client_rect (window_x11);
434+
433435
meta_theme_calc_geometry (meta_theme_get_default (),
434436
frame->style_info,
435437
type,
436438
frame->text_height,
437439
flags,
438-
priv->client_rect.width,
439-
priv->client_rect.height,
440+
client_rect.width,
441+
client_rect.height,
440442
&button_layout,
441443
fgeom);
442444
}
@@ -1657,7 +1659,7 @@ meta_ui_frame_paint (MetaUIFrame *frame,
16571659
int button_type = -1;
16581660
MetaButtonLayout button_layout;
16591661
MetaWindowX11 *window_x11 = META_WINDOW_X11 (frame->meta_window);
1660-
MetaWindowX11Private *priv = window_x11->priv;
1662+
MetaRectangle client_rect;
16611663

16621664
for (i = 0; i < META_BUTTON_TYPE_LAST; i++)
16631665
button_states[i] = META_BUTTON_STATE_NORMAL;
@@ -1695,13 +1697,15 @@ meta_ui_frame_paint (MetaUIFrame *frame,
16951697

16961698
meta_prefs_get_button_layout (&button_layout);
16971699

1700+
client_rect = meta_window_x11_get_client_rect (window_x11);
1701+
16981702
meta_theme_draw_frame (meta_theme_get_default (),
16991703
frame->style_info,
17001704
cr,
17011705
type,
17021706
flags,
1703-
priv->client_rect.width,
1704-
priv->client_rect.height,
1707+
client_rect.width,
1708+
client_rect.height,
17051709
frame->text_layout,
17061710
frame->text_height,
17071711
&button_layout,

src/x11/window-props.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ reload_net_wm_window_type (MetaWindow *window,
249249
{
250250
MetaX11Display *x11_display = window->display->x11_display;
251251
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
252-
MetaWindowX11Private *priv = window_x11->priv;
252+
MetaWindowX11Private *priv = meta_window_x11_get_private (window_x11);
253253

254254
if (value->type != META_PROP_VALUE_INVALID)
255255
{
@@ -291,7 +291,7 @@ reload_icon (MetaWindow *window,
291291
Atom atom)
292292
{
293293
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
294-
MetaWindowX11Private *priv = window_x11->priv;
294+
MetaWindowX11Private *priv = meta_window_x11_get_private (window_x11);
295295

296296
meta_icon_cache_property_changed (&priv->icon_cache,
297297
window->display->x11_display,
@@ -596,7 +596,7 @@ set_window_title (MetaWindow *window,
596596
const char *title)
597597
{
598598
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
599-
MetaWindowX11Private *priv = window_x11->priv;
599+
MetaWindowX11Private *priv = meta_window_x11_get_private (window_x11);
600600

601601
char *new_title = NULL;
602602

@@ -619,7 +619,7 @@ reload_net_wm_name (MetaWindow *window,
619619
gboolean initial)
620620
{
621621
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
622-
MetaWindowX11Private *priv = window_x11->priv;
622+
MetaWindowX11Private *priv = meta_window_x11_get_private (window_x11);
623623

624624
if (value->type != META_PROP_VALUE_INVALID)
625625
{
@@ -644,7 +644,7 @@ reload_wm_name (MetaWindow *window,
644644
gboolean initial)
645645
{
646646
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
647-
MetaWindowX11Private *priv = window_x11->priv;
647+
MetaWindowX11Private *priv = meta_window_x11_get_private (window_x11);
648648

649649
if (priv->using_net_wm_name)
650650
{
@@ -784,7 +784,7 @@ reload_net_wm_state (MetaWindow *window,
784784
{
785785
MetaX11Display *x11_display = window->display->x11_display;
786786
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
787-
MetaWindowX11Private *priv = window_x11->priv;
787+
MetaWindowX11Private *priv = meta_window_x11_get_private (window_x11);
788788

789789
int i;
790790

@@ -1656,7 +1656,7 @@ reload_wm_hints (MetaWindow *window,
16561656
gboolean initial)
16571657
{
16581658
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
1659-
MetaWindowX11Private *priv = window_x11->priv;
1659+
MetaWindowX11Private *priv = meta_window_x11_get_private (window_x11);
16601660
Window old_group_leader;
16611661
gboolean urgent;
16621662

src/x11/window-x11-private.h

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,12 @@
2525

2626
#include "core/window-private.h"
2727
#include "x11/iconcache.h"
28+
#include "x11/window-x11.h"
2829

2930
G_BEGIN_DECLS
3031

3132
typedef struct _MetaWindowX11Private MetaWindowX11Private;
3233

33-
struct _MetaWindowX11Class
34-
{
35-
MetaWindowClass parent_class;
36-
37-
void (*freeze_commits) (MetaWindow *window);
38-
void (*thaw_commits) (MetaWindow *window);
39-
gboolean (*always_update_shape) (MetaWindow *window);
40-
};
41-
42-
struct _MetaWindowX11
43-
{
44-
MetaWindow parent;
45-
46-
MetaWindowX11Private *priv;
47-
};
48-
4934
struct _MetaWindowX11Private
5035
{
5136
/* TRUE if the client forced these on */
@@ -81,6 +66,8 @@ struct _MetaWindowX11Private
8166
gboolean thaw_after_paint;
8267
};
8368

69+
MetaWindowX11Private * meta_window_x11_get_private (MetaWindowX11 *window_x11);
70+
8471
G_END_DECLS
8572

8673
#endif

src/x11/window-x11.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ meta_window_x11_maybe_focus_delayed (MetaWindow *window,
7373
static void
7474
meta_window_x11_init (MetaWindowX11 *window_x11)
7575
{
76-
window_x11->priv = meta_window_x11_get_instance_private (window_x11);
76+
}
77+
78+
MetaWindowX11Private *
79+
meta_window_x11_get_private (MetaWindowX11 *window_x11)
80+
{
81+
return meta_window_x11_get_instance_private (window_x11);
7782
}
7883

7984
static void
@@ -4133,3 +4138,11 @@ meta_window_x11_surface_rect_to_client_rect (MetaWindow *window,
41334138
client_rect->width -= borders.total.left + borders.total.right;
41344139
client_rect->height -= borders.total.top + borders.total.bottom;
41354140
}
4141+
4142+
MetaRectangle
4143+
meta_window_x11_get_client_rect (MetaWindowX11 *window_x11)
4144+
{
4145+
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
4146+
4147+
return priv->client_rect;
4148+
}

src/x11/window-x11.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,24 @@
2525

2626
#include <X11/Xlib.h>
2727

28+
#include "core/window-private.h"
2829
#include "meta/compositor.h"
2930
#include "meta/window.h"
3031

3132
G_BEGIN_DECLS
3233

33-
#define META_TYPE_WINDOW_X11 (meta_window_x11_get_type())
34-
#define META_WINDOW_X11(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_WINDOW_X11, MetaWindowX11))
35-
#define META_WINDOW_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_WINDOW_X11, MetaWindowX11Class))
36-
#define META_IS_WINDOW_X11(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_WINDOW_X11))
37-
#define META_IS_WINDOW_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_WINDOW_X11))
38-
#define META_WINDOW_X11_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_WINDOW_X11, MetaWindowX11Class))
34+
#define META_TYPE_WINDOW_X11 (meta_window_x11_get_type())
35+
G_DECLARE_DERIVABLE_TYPE (MetaWindowX11, meta_window_x11,
36+
META, WINDOW_X11, MetaWindow)
3937

40-
GType meta_window_x11_get_type (void);
38+
struct _MetaWindowX11Class
39+
{
40+
MetaWindowClass parent_class;
4141

42-
typedef struct _MetaWindowX11 MetaWindowX11;
43-
typedef struct _MetaWindowX11Class MetaWindowX11Class;
44-
45-
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaWindowX11, g_object_unref)
42+
void (*freeze_commits) (MetaWindow *window);
43+
void (*thaw_commits) (MetaWindow *window);
44+
gboolean (*always_update_shape) (MetaWindow *window);
45+
};
4646

4747
MetaWindow * meta_window_x11_new (MetaDisplay *display,
4848
Window xwindow,
@@ -95,4 +95,6 @@ void meta_window_x11_surface_rect_to_frame_rect (MetaWindow *window,
9595
void meta_window_x11_surface_rect_to_client_rect (MetaWindow *window,
9696
MetaRectangle *surface_rect,
9797
MetaRectangle *client_rect);
98+
99+
MetaRectangle meta_window_x11_get_client_rect (MetaWindowX11 *window_x11);
98100
#endif

0 commit comments

Comments
 (0)