diff options
author | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2016-08-18 18:54:38 +0300 |
---|---|---|
committer | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2016-08-18 19:05:19 +0300 |
commit | 2ee0ffbee0b52cb8fc3112906bea1eaa737559f7 (patch) | |
tree | 4b0276b21d5565933cdac49d6a81e8fbe5d4c975 | |
parent | dfa271fab6c2af18e7f0a320062fecb9a2bcb66c (diff) | |
download | metacity-2ee0ffbee0b52cb8fc3112906bea1eaa737559f7.tar.gz |
libmetacity: don't expose MetaButton struct
-rw-r--r-- | libmetacity/Makefile.am | 1 | ||||
-rw-r--r-- | libmetacity/meta-button-layout-private.h | 2 | ||||
-rw-r--r-- | libmetacity/meta-button-private.h | 22 | ||||
-rw-r--r-- | libmetacity/meta-button.c | 33 | ||||
-rw-r--r-- | libmetacity/meta-button.h | 21 | ||||
-rw-r--r-- | libmetacity/meta-theme.c | 14 | ||||
-rw-r--r-- | libmetacity/meta-theme.h | 5 | ||||
-rw-r--r-- | src/ui/frames.c | 34 |
8 files changed, 85 insertions, 47 deletions
diff --git a/libmetacity/Makefile.am b/libmetacity/Makefile.am index c26d310f..3620645f 100644 --- a/libmetacity/Makefile.am +++ b/libmetacity/Makefile.am @@ -3,6 +3,7 @@ NULL = lib_LTLIBRARIES = libmetacity.la libmetacity_la_SOURCES = \ + meta-button.c \ meta-button.h \ meta-button-layout.c \ meta-button-layout-private.h \ diff --git a/libmetacity/meta-button-layout-private.h b/libmetacity/meta-button-layout-private.h index 4926b1dc..d4397ef6 100644 --- a/libmetacity/meta-button-layout-private.h +++ b/libmetacity/meta-button-layout-private.h @@ -19,7 +19,7 @@ #ifndef META_BUTTON_LAYOUT_PRIVATE_H #define META_BUTTON_LAYOUT_PRIVATE_H -#include "meta-button.h" +#include "meta-button-private.h" G_BEGIN_DECLS diff --git a/libmetacity/meta-button-private.h b/libmetacity/meta-button-private.h index d6e2ec6d..f849e086 100644 --- a/libmetacity/meta-button-private.h +++ b/libmetacity/meta-button-private.h @@ -18,7 +18,7 @@ #ifndef META_BUTTON_PRIVATE_H #define META_BUTTON_PRIVATE_H -#include <glib.h> +#include "meta-button.h" G_BEGIN_DECLS @@ -47,6 +47,26 @@ typedef enum META_BUTTON_FUNCTION_LAST } MetaButtonFunction; +struct _MetaButton +{ + MetaButtonType type; + MetaButtonState state; + + /* The computed size of a button (really just a way of tying its visible + * and clickable areas together). The reason for two different rectangles + * here is Fitts' law & maximized windows; See bug #97703 for more details. + */ + struct { + /* The area where the button's image is drawn. */ + GdkRectangle visible; + + /* The area where the button can be activated by clicking */ + GdkRectangle clickable; + } rect; + + gboolean visible; +}; + G_END_DECLS #endif diff --git a/libmetacity/meta-button.c b/libmetacity/meta-button.c new file mode 100644 index 00000000..e3d4e769 --- /dev/null +++ b/libmetacity/meta-button.c @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2016 Alberts Muktupāvels + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "config.h" + +#include "meta-button-private.h" + +MetaButtonType +meta_button_get_type (MetaButton *button) +{ + return button->type; +} + +void +meta_button_get_event_rect (MetaButton *button, + GdkRectangle *rect) +{ + *rect = button->rect.clickable; +} diff --git a/libmetacity/meta-button.h b/libmetacity/meta-button.h index a087e147..9edf2753 100644 --- a/libmetacity/meta-button.h +++ b/libmetacity/meta-button.h @@ -48,25 +48,12 @@ typedef enum META_BUTTON_STATE_LAST } MetaButtonState; -typedef struct -{ - MetaButtonType type; - MetaButtonState state; - - /* The computed size of a button (really just a way of tying its visible - * and clickable areas together). The reason for two different rectangles - * here is Fitts' law & maximized windows; See bug #97703 for more details. - */ - struct { - /* The area where the button's image is drawn. */ - GdkRectangle visible; +typedef struct _MetaButton MetaButton; - /* The area where the button can be activated by clicking */ - GdkRectangle clickable; - } rect; +MetaButtonType meta_button_get_type (MetaButton *button); - gboolean visible; -} MetaButton; +void meta_button_get_event_rect (MetaButton *button, + GdkRectangle *rect); G_END_DECLS diff --git a/libmetacity/meta-theme.c b/libmetacity/meta-theme.c index 7084ef49..bd03f051 100644 --- a/libmetacity/meta-theme.c +++ b/libmetacity/meta-theme.c @@ -570,11 +570,10 @@ meta_theme_set_button_layout (MetaTheme *theme, theme->button_layout = meta_button_layout_new (button_layout, invert); } -gboolean -meta_theme_get_button (MetaTheme *theme, - gint x, - gint y, - MetaButton *button) +MetaButton * +meta_theme_get_button (MetaTheme *theme, + gint x, + gint y) { gint side; @@ -618,13 +617,12 @@ meta_theme_get_button (MetaTheme *theme, if (x >= rect.x && x < (rect.x + rect.width) && y >= rect.y && y < (rect.y + rect.height)) { - *button = *btn; - return TRUE; + return btn; } } } - return FALSE; + return NULL; } void diff --git a/libmetacity/meta-theme.h b/libmetacity/meta-theme.h index 4174ffe6..f3228d41 100644 --- a/libmetacity/meta-theme.h +++ b/libmetacity/meta-theme.h @@ -113,10 +113,9 @@ void meta_theme_set_button_layout (MetaTheme *theme, const gchar *button_layout, gboolean invert); -gboolean meta_theme_get_button (MetaTheme *theme, +MetaButton *meta_theme_get_button (MetaTheme *theme, gint x, - gint y, - MetaButton *button); + gint y); void meta_theme_set_composited (MetaTheme *theme, gboolean composited); diff --git a/src/ui/frames.c b/src/ui/frames.c index 3274142a..31fe269d 100644 --- a/src/ui/frames.c +++ b/src/ui/frames.c @@ -129,13 +129,12 @@ get_control (MetaFrames *frames, GdkRectangle client; MetaFrameBorders borders; MetaTheme *theme; - MetaButton button; + MetaButton *button; meta_frames_calc_geometry (frames, frame, &fgeom); get_client_rect (&fgeom, &client); borders = fgeom.borders; - theme = meta_ui_get_theme (); if (x < borders.invisible.left - borders.resize.left || y < borders.invisible.top - borders.resize.top || @@ -151,9 +150,12 @@ get_control (MetaFrames *frames, META_CORE_GET_FRAME_TYPE, &type, META_CORE_GET_END); - if (meta_theme_get_button (theme, x, y, &button)) + theme = meta_ui_get_theme (); + button = meta_theme_get_button (theme, x, y); + + if (button != NULL) { - switch (button.type) + switch (meta_button_get_type (button)) { case META_BUTTON_TYPE_CLOSE: return META_FRAME_CONTROL_DELETE; @@ -290,9 +292,7 @@ get_control_rect (MetaFrameControl control, { MetaButtonType type; MetaTheme *theme; - MetaButton button; - - type = META_BUTTON_TYPE_LAST; + MetaButton *button; switch (control) { @@ -356,22 +356,22 @@ get_control_rect (MetaFrameControl control, case META_FRAME_CONTROL_RESIZE_E: case META_FRAME_CONTROL_NONE: default: + type = META_BUTTON_TYPE_LAST; break; } + if (type == META_BUTTON_TYPE_LAST) + return FALSE; + theme = meta_ui_get_theme (); + button = meta_theme_get_button (theme, x, y); - if (type != META_BUTTON_TYPE_LAST && - meta_theme_get_button (theme, x, y, &button)) - { - if (type == button.type) - { - *rect = button.rect.clickable; - return TRUE; - } - } + if (button == NULL || meta_button_get_type (button) != type) + return FALSE; - return FALSE; + meta_button_get_event_rect (button, rect); + + return TRUE; } static void |