From 5e567af8e0608ccd6db37d548ccb36098eda95c4 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Fri, 17 Jun 2022 20:19:19 +0800 Subject: [PATCH] Reduce code duplication when setting user time window * src/xterm.c (x_make_frame_visible): Use `x_update_frame_user_time_window'. --- src/xterm.c | 59 +++++++++++------------------------------------------ 1 file changed, 12 insertions(+), 47 deletions(-) diff --git a/src/xterm.c b/src/xterm.c index 9d5e1babf39..fe7b6ffe212 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -24795,56 +24795,21 @@ x_make_frame_visible (struct frame *f) #ifndef USE_GTK output = FRAME_X_OUTPUT (f); + x_update_frame_user_time_window (f); - if (!x_wm_supports (f, dpyinfo->Xatom_net_wm_user_time_window)) + /* It's been a while since I wrote that code... I don't + remember if it can leave `user_time_window' unset or not. */ + if (output->user_time_window != None) { - if (output->user_time_window == None) - output->user_time_window = FRAME_OUTER_WINDOW (f); - else if (output->user_time_window != FRAME_OUTER_WINDOW (f)) - { - XDestroyWindow (dpyinfo->display, - output->user_time_window); - XDeleteProperty (dpyinfo->display, - FRAME_OUTER_WINDOW (f), - dpyinfo->Xatom_net_wm_user_time_window); - output->user_time_window = FRAME_OUTER_WINDOW (f); - } - } - else - { - if (output->user_time_window == FRAME_OUTER_WINDOW (f) - || output->user_time_window == None) - { - XSetWindowAttributes attrs; - memset (&attrs, 0, sizeof attrs); - - output->user_time_window - = XCreateWindow (dpyinfo->display, FRAME_X_WINDOW (f), - -1, -1, 1, 1, 0, 0, InputOnly, - CopyFromParent, 0, &attrs); - - XDeleteProperty (dpyinfo->display, - FRAME_OUTER_WINDOW (f), - dpyinfo->Xatom_net_wm_user_time); - XChangeProperty (dpyinfo->display, - FRAME_OUTER_WINDOW (f), - dpyinfo->Xatom_net_wm_user_time_window, - XA_WINDOW, 32, PropModeReplace, - (unsigned char *) &output->user_time_window, - 1); - } + if (dpyinfo->last_user_time) + XChangeProperty (dpyinfo->display, output->user_time_window, + dpyinfo->Xatom_net_wm_user_time, + XA_CARDINAL, 32, PropModeReplace, + (unsigned char *) &dpyinfo->last_user_time, 1); + else + XDeleteProperty (dpyinfo->display, output->user_time_window, + dpyinfo->Xatom_net_wm_user_time); } - - if (dpyinfo->last_user_time) - XChangeProperty (dpyinfo->display, - output->user_time_window, - dpyinfo->Xatom_net_wm_user_time, - XA_CARDINAL, 32, PropModeReplace, - (unsigned char *) &dpyinfo->last_user_time, 1); - else - XDeleteProperty (dpyinfo->display, - output->user_time_window, - dpyinfo->Xatom_net_wm_user_time); #endif f->output_data.x->asked_for_visible = true; -- 2.39.2