[gtk/wip/matthiasc/popup5: 89/118] x11: Remove useless checks
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/matthiasc/popup5: 89/118] x11: Remove useless checks
- Date: Sun, 5 May 2019 17:46:40 +0000 (UTC)
commit c30cf67404d6d021510239fd6bdf52819e1d53a9
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Apr 22 13:16:55 2019 +0000
x11: Remove useless checks
All surfaces are toplevels now, no need
to check for this all over the place.
gdk/x11/gdksurface-x11.c | 203 ++++++++++++++---------------------------------
1 file changed, 59 insertions(+), 144 deletions(-)
---
diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c
index 9854406cb2..9403b8c93a 100644
--- a/gdk/x11/gdksurface-x11.c
+++ b/gdk/x11/gdksurface-x11.c
@@ -107,10 +107,6 @@ static void set_wm_name (GdkDisplay *display,
const gchar *name);
static void move_to_current_desktop (GdkSurface *surface);
-#define SURFACE_IS_TOPLEVEL(surface) \
- (GDK_SURFACE_TYPE (surface) == GDK_SURFACE_TOPLEVEL || \
- GDK_SURFACE_TYPE (surface) == GDK_SURFACE_TEMP)
-
/* Return whether time1 is considered later than time2 as far as xserver
* time is concerned. Accounts for wraparound.
*/
@@ -135,9 +131,6 @@ _gdk_x11_surface_get_toplevel (GdkSurface *surface)
g_return_val_if_fail (GDK_IS_SURFACE (surface), NULL);
- if (!SURFACE_IS_TOPLEVEL (surface))
- return NULL;
-
impl = GDK_X11_SURFACE (surface);
if (!impl->toplevel)
@@ -203,13 +196,9 @@ set_sync_counter(Display *display,
void
gdk_x11_surface_pre_damage (GdkSurface *surface)
{
- GdkSurface *toplevel_surface = surface;
GdkX11Surface *impl;
- if (!toplevel_surface || !SURFACE_IS_TOPLEVEL (toplevel_surface))
- return;
-
- impl = GDK_X11_SURFACE (toplevel_surface);
+ impl = GDK_X11_SURFACE (surface);
if (impl->toplevel->in_frame &&
impl->toplevel->current_counter_value % 2 == 0)
@@ -281,9 +270,6 @@ gdk_x11_surface_predict_presentation_time (GdkSurface *surface)
gint64 presentation_time;
gint64 refresh_interval;
- if (!SURFACE_IS_TOPLEVEL (surface))
- return;
-
clock = gdk_surface_get_frame_clock (surface);
timings = gdk_frame_clock_get_current_timings (clock);
@@ -328,8 +314,7 @@ gdk_x11_surface_begin_frame (GdkSurface *surface,
impl = GDK_X11_SURFACE (surface);
- if (!SURFACE_IS_TOPLEVEL (surface) ||
- impl->toplevel->extended_update_counter == None)
+ if (impl->toplevel->extended_update_counter == None)
return;
impl->toplevel->in_frame = TRUE;
@@ -369,8 +354,7 @@ gdk_x11_surface_end_frame (GdkSurface *surface)
impl = GDK_X11_SURFACE (surface);
- if (!SURFACE_IS_TOPLEVEL (surface) ||
- impl->toplevel->extended_update_counter == None ||
+ if (impl->toplevel->extended_update_counter == None ||
!impl->toplevel->in_frame)
return;
@@ -447,7 +431,7 @@ gdk_x11_surface_finalize (GObject *object)
impl = GDK_X11_SURFACE (object);
- if (SURFACE_IS_TOPLEVEL (impl) && impl->toplevel->in_frame)
+ if (impl->toplevel->in_frame)
unhook_surface_changed (GDK_SURFACE (impl));
_gdk_x11_surface_grab_check_destroy (GDK_SURFACE (impl));
@@ -771,7 +755,7 @@ connect_frame_clock (GdkSurface *surface)
GdkX11Surface *impl;
impl = GDK_X11_SURFACE (surface);
- if (SURFACE_IS_TOPLEVEL (surface) && !impl->frame_clock_connected)
+ if (!impl->frame_clock_connected)
{
GdkFrameClock *frame_clock = gdk_surface_get_frame_clock (surface);
@@ -815,10 +799,7 @@ _gdk_x11_display_create_surface (GdkDisplay *display,
display_x11 = GDK_X11_DISPLAY (display);
x11_screen = GDK_X11_SCREEN (display_x11->screen);
- if (parent)
- xparent = GDK_SURFACE_XID (parent);
- else
- xparent = GDK_SCREEN_XROOTWIN (x11_screen);
+ xparent = GDK_SCREEN_XROOTWIN (x11_screen);
frame_clock = _gdk_frame_clock_idle_new ();
@@ -899,24 +880,15 @@ _gdk_x11_display_create_surface (GdkDisplay *display,
g_object_ref (surface);
_gdk_x11_display_add_window (x11_screen->display, &impl->xid, surface);
- switch (GDK_SURFACE_TYPE (surface))
- {
- case GDK_SURFACE_TOPLEVEL:
- case GDK_SURFACE_TEMP:
- gdk_surface_set_title (surface, get_default_title ());
-
- class_hint = XAllocClassHint ();
- class_hint->res_name = (char *) g_get_prgname ();
- class_hint->res_class = (char *) display_x11->program_class;
- XSetClassHint (xdisplay, impl->xid, class_hint);
- XFree (class_hint);
+ gdk_surface_set_title (surface, get_default_title ());
- setup_toplevel_window (surface, x11_screen);
- break;
+ class_hint = XAllocClassHint ();
+ class_hint->res_name = (char *) g_get_prgname ();
+ class_hint->res_class = (char *) display_x11->program_class;
+ XSetClassHint (xdisplay, impl->xid, class_hint);
+ XFree (class_hint);
- default:
- break;
- }
+ setup_toplevel_window (surface, x11_screen);
gdk_x11_event_source_select_events ((GdkEventSource *) display_x11->event_source,
GDK_SURFACE_XID (surface), GDK_ALL_EVENTS_MASK,
@@ -1207,17 +1179,14 @@ gdk_x11_surface_show (GdkSurface *surface, gboolean already_mapped)
if (!already_mapped)
set_initial_hints (surface);
- if (SURFACE_IS_TOPLEVEL (surface))
- {
- display = gdk_surface_get_display (surface);
- display_x11 = GDK_X11_DISPLAY (display);
- toplevel = _gdk_x11_surface_get_toplevel (surface);
+ display = gdk_surface_get_display (surface);
+ display_x11 = GDK_X11_DISPLAY (display);
+ toplevel = _gdk_x11_surface_get_toplevel (surface);
- if (toplevel->user_time != 0 &&
- display_x11->user_time != 0 &&
- XSERVER_TIME_IS_LATER (display_x11->user_time, toplevel->user_time))
- gdk_x11_surface_set_user_time (surface, display_x11->user_time);
- }
+ if (toplevel->user_time != 0 &&
+ display_x11->user_time != 0 &&
+ XSERVER_TIME_IS_LATER (display_x11->user_time, toplevel->user_time))
+ gdk_x11_surface_set_user_time (surface, display_x11->user_time);
XMapWindow (xdisplay, xwindow);
@@ -1256,22 +1225,7 @@ gdk_x11_surface_hide (GdkSurface *surface)
_gdk_x11_surface_grab_check_unmap (surface,
NextRequest (GDK_SURFACE_XDISPLAY (surface)));
- /* You can't simply unmap toplevel surfaces. */
- switch (surface->surface_type)
- {
- case GDK_SURFACE_TOPLEVEL:
- case GDK_SURFACE_TEMP: /* ? */
- gdk_x11_surface_withdraw (surface);
- return;
-
- default:
- break;
- }
-
- _gdk_surface_clear_update_area (surface);
-
- XUnmapWindow (GDK_SURFACE_XDISPLAY (surface),
- GDK_SURFACE_XID (surface));
+ gdk_x11_surface_withdraw (surface);
}
static inline void
@@ -1587,8 +1541,7 @@ gdk_x11_surface_focus (GdkSurface *surface,
g_return_if_fail (GDK_IS_SURFACE (surface));
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
display = GDK_SURFACE_DISPLAY (surface);
@@ -1637,8 +1590,7 @@ gdk_x11_surface_set_type_hint (GdkSurface *surface,
GdkDisplay *display;
Atom atom;
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
display = gdk_surface_get_display (surface);
@@ -1711,8 +1663,7 @@ gdk_x11_surface_get_type_hint (GdkSurface *surface)
g_return_val_if_fail (GDK_IS_SURFACE (surface), GDK_SURFACE_TYPE_HINT_NORMAL);
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return GDK_SURFACE_TYPE_HINT_NORMAL;
type = GDK_SURFACE_TYPE_HINT_NORMAL;
@@ -1798,8 +1749,7 @@ static void
gdk_x11_surface_set_modal_hint (GdkSurface *surface,
gboolean modal)
{
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
surface->modal_hint = modal;
@@ -1824,8 +1774,7 @@ gdk_x11_surface_set_skip_taskbar_hint (GdkSurface *surface,
{
GdkToplevelX11 *toplevel;
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
toplevel = _gdk_x11_surface_get_toplevel (surface);
@@ -1851,8 +1800,7 @@ gdk_x11_surface_set_skip_pager_hint (GdkSurface *surface,
{
GdkToplevelX11 *toplevel;
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
toplevel = _gdk_x11_surface_get_toplevel (surface);
@@ -1878,8 +1826,7 @@ gdk_x11_surface_set_urgency_hint (GdkSurface *surface,
{
GdkToplevelX11 *toplevel;
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
toplevel = _gdk_x11_surface_get_toplevel (surface);
@@ -1897,8 +1844,7 @@ gdk_x11_surface_set_geometry_hints (GdkSurface *surface,
XSizeHints size_hints;
GdkToplevelX11 *toplevel;
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
toplevel = _gdk_x11_surface_get_toplevel (surface);
@@ -2020,8 +1966,7 @@ gdk_surface_get_geometry_hints (GdkSurface *surface,
*geom_mask = 0;
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
impl = GDK_X11_SURFACE (surface);
@@ -2169,8 +2114,7 @@ gdk_x11_surface_set_title (GdkSurface *surface,
g_return_if_fail (title != NULL);
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
display = gdk_surface_get_display (surface);
@@ -2202,8 +2146,7 @@ gdk_x11_surface_set_startup_id (GdkSurface *surface,
display = gdk_surface_get_display (surface);
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
if (startup_id)
@@ -2220,8 +2163,7 @@ static void
gdk_x11_surface_set_transient_for (GdkSurface *surface,
GdkSurface *parent)
{
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
/* XSetTransientForHint() doesn't allow unsetting, so do it manually */
@@ -2552,8 +2494,7 @@ gdk_x11_surface_set_accept_focus (GdkSurface *surface,
{
surface->accept_focus = accept_focus;
- if (!GDK_SURFACE_DESTROYED (surface) &&
- SURFACE_IS_TOPLEVEL (surface))
+ if (!GDK_SURFACE_DESTROYED (surface))
update_wm_hints (surface, FALSE);
}
}
@@ -2568,9 +2509,8 @@ gdk_x11_surface_set_focus_on_map (GdkSurface *surface,
{
surface->focus_on_map = focus_on_map;
- if ((!GDK_SURFACE_DESTROYED (surface)) &&
- (!surface->focus_on_map) &&
- SURFACE_IS_TOPLEVEL (surface))
+ if (!GDK_SURFACE_DESTROYED (surface) &&
+ !surface->focus_on_map)
gdk_x11_surface_set_user_time (surface, 0);
}
}
@@ -2603,8 +2543,7 @@ gdk_x11_surface_set_user_time (GdkSurface *surface,
glong timestamp_long = (glong)timestamp;
Window xid;
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
display = gdk_surface_get_display (surface);
@@ -2655,9 +2594,6 @@ gdk_x11_surface_set_utf8_property (GdkSurface *surface,
{
GdkDisplay *display;
- if (!SURFACE_IS_TOPLEVEL (surface))
- return;
-
display = gdk_surface_get_display (surface);
if (value != NULL)
@@ -2846,8 +2782,7 @@ gdk_x11_surface_set_icon_list (GdkSurface *surface,
GdkDisplay *display;
gint i, n;
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
display = gdk_surface_get_display (surface);
@@ -2928,8 +2863,7 @@ gdk_x11_surface_set_icon_name (GdkSurface *surface,
{
GdkDisplay *display;
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
display = gdk_surface_get_display (surface);
@@ -2963,8 +2897,7 @@ gdk_x11_surface_set_icon_name (GdkSurface *surface,
static void
gdk_x11_surface_iconify (GdkSurface *surface)
{
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
if (GDK_SURFACE_IS_MAPPED (surface))
@@ -2988,8 +2921,7 @@ gdk_x11_surface_iconify (GdkSurface *surface)
static void
gdk_x11_surface_deiconify (GdkSurface *surface)
{
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
if (GDK_SURFACE_IS_MAPPED (surface))
@@ -3014,8 +2946,7 @@ gdk_x11_surface_deiconify (GdkSurface *surface)
static void
gdk_x11_surface_stick (GdkSurface *surface)
{
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
if (GDK_SURFACE_IS_MAPPED (surface))
@@ -3062,8 +2993,7 @@ gdk_x11_surface_stick (GdkSurface *surface)
static void
gdk_x11_surface_unstick (GdkSurface *surface)
{
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
if (GDK_SURFACE_IS_MAPPED (surface))
@@ -3088,8 +3018,7 @@ gdk_x11_surface_unstick (GdkSurface *surface)
static void
gdk_x11_surface_maximize (GdkSurface *surface)
{
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
if (GDK_SURFACE_IS_MAPPED (surface))
@@ -3105,8 +3034,7 @@ gdk_x11_surface_maximize (GdkSurface *surface)
static void
gdk_x11_surface_unmaximize (GdkSurface *surface)
{
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
if (GDK_SURFACE_IS_MAPPED (surface))
@@ -3122,8 +3050,7 @@ gdk_x11_surface_unmaximize (GdkSurface *surface)
static void
gdk_x11_surface_apply_fullscreen_mode (GdkSurface *surface)
{
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
/* _NET_WM_FULLSCREEN_MONITORS gives an indication to the window manager as
@@ -3214,8 +3141,7 @@ gdk_x11_surface_apply_fullscreen_mode (GdkSurface *surface)
static void
gdk_x11_surface_fullscreen (GdkSurface *surface)
{
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
if (GDK_SURFACE_IS_MAPPED (surface))
@@ -3241,8 +3167,7 @@ gdk_x11_surface_fullscreen_on_monitor (GdkSurface *surface,
{
GdkRectangle geom;
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
gdk_monitor_get_geometry (monitor, &geom);
@@ -3255,8 +3180,7 @@ gdk_x11_surface_fullscreen_on_monitor (GdkSurface *surface,
static void
gdk_x11_surface_unfullscreen (GdkSurface *surface)
{
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
if (GDK_SURFACE_IS_MAPPED (surface))
@@ -3276,8 +3200,7 @@ gdk_x11_surface_set_keep_above (GdkSurface *surface,
{
g_return_if_fail (GDK_IS_SURFACE (surface));
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
if (GDK_SURFACE_IS_MAPPED (surface))
@@ -3301,8 +3224,7 @@ gdk_x11_surface_set_keep_below (GdkSurface *surface, gboolean setting)
{
g_return_if_fail (GDK_IS_SURFACE (surface));
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
if (GDK_SURFACE_IS_MAPPED (surface))
@@ -3326,8 +3248,7 @@ gdk_x11_surface_get_group (GdkSurface *surface)
{
GdkToplevelX11 *toplevel;
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return NULL;
toplevel = _gdk_x11_surface_get_toplevel (surface);
@@ -3353,8 +3274,7 @@ gdk_x11_surface_set_group (GdkSurface *surface,
g_return_if_fail (leader == NULL || GDK_IS_SURFACE (leader));
if (GDK_SURFACE_DESTROYED (surface) ||
- (leader != NULL && GDK_SURFACE_DESTROYED (leader)) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ (leader != NULL && GDK_SURFACE_DESTROYED (leader)))
return;
toplevel = _gdk_x11_surface_get_toplevel (surface);
@@ -3459,8 +3379,7 @@ gdk_x11_surface_set_decorations (GdkSurface *surface,
{
MotifWmHints hints;
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
/* initialize to zero to avoid writing uninitialized data to socket */
@@ -3478,8 +3397,7 @@ gdk_x11_surface_get_decorations(GdkSurface *surface,
MotifWmHints *hints;
gboolean result = FALSE;
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return FALSE;
hints = gdk_surface_get_mwm_hints (surface);
@@ -3507,8 +3425,7 @@ gdk_x11_surface_set_functions (GdkSurface *surface,
g_return_if_fail (GDK_IS_SURFACE (surface));
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
/* initialize to zero to avoid writing uninitialized data to socket */
@@ -4292,8 +4209,7 @@ gdk_x11_surface_begin_resize_drag (GdkSurface *surface,
{
int root_x, root_y;
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
gdk_x11_surface_get_root_coords (surface, x, y, &root_x, &root_y);
@@ -4316,7 +4232,7 @@ gdk_x11_surface_begin_move_drag (GdkSurface *surface,
int root_x, root_y;
gint direction;
- if (GDK_SURFACE_DESTROYED (surface) || !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
if (button == 0)
@@ -4363,8 +4279,7 @@ gdk_x11_surface_set_opacity (GdkSurface *surface,
g_return_if_fail (GDK_IS_SURFACE (surface));
- if (GDK_SURFACE_DESTROYED (surface) ||
- !SURFACE_IS_TOPLEVEL (surface))
+ if (GDK_SURFACE_DESTROYED (surface))
return;
display = gdk_surface_get_display (surface);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]