Check for _NET_WM_STATE_HIDDEN (rhbz#711739)

This commit is contained in:
Karel Klic 2011-11-23 12:10:49 +01:00
parent 26f5a25719
commit 782803e7d3
2 changed files with 181 additions and 1 deletions

173
emacs-wm-state-hidden.patch Normal file
View File

@ -0,0 +1,173 @@
diff -U0 emacs-23.3/src/ChangeLog.wm-state-hidden emacs-23.3/src/ChangeLog
--- emacs-23.3/src/ChangeLog.wm-state-hidden 2011-03-07 06:08:03.000000000 +0100
+++ emacs-23.3/src/ChangeLog 2011-11-23 11:49:57.053019839 +0100
@@ -1,0 +2,13 @@
+2011-10-30 Jan Djärv <jan.h.d@swipnet.se>
+
+ * xterm.h (x_display_info): Add Xatom_net_wm_state_hidden (Bug#9893).
+
+ * xterm.c: Declare x_handle_net_wm_state to return int.
+ (handle_one_xevent): Check if we are iconified but don't have
+ _NET_WM_STATE_HIDDEN. If do, treat as deiconify (Bug#9893).
+ (get_current_wm_state): Return non-zero if not hidden,
+ check for _NET_WM_STATE_HIDDEN (Bug#9893).
+ (do_ewmh_fullscreen): Ignore return value from get_current_wm_state.
+ (x_handle_net_wm_state): Return what get_current_wm_state returns.
+ (x_term_init): Initialize dpyinfo->Xatom_net_wm_state_hidden.
+
diff -up emacs-23.3/src/xterm.c.wm-state-hidden emacs-23.3/src/xterm.c
--- emacs-23.3/src/xterm.c.wm-state-hidden 2011-02-12 01:27:01.000000000 +0100
+++ emacs-23.3/src/xterm.c 2011-11-23 11:55:10.867096378 +0100
@@ -375,7 +375,7 @@ static void x_scroll_bar_report_motion P
enum scroll_bar_part *,
Lisp_Object *, Lisp_Object *,
unsigned long *));
-static void x_handle_net_wm_state P_ ((struct frame *, XPropertyEvent *));
+static int x_handle_net_wm_state P_ ((struct frame *, XPropertyEvent *));
static void x_check_fullscreen P_ ((struct frame *));
static void x_check_expected_move P_ ((struct frame *, int, int));
static void x_sync_with_move P_ ((struct frame *, int, int, int));
@@ -6121,7 +6121,19 @@ handle_one_xevent (dpyinfo, eventp, fini
last_user_time = event.xproperty.time;
f = x_top_window_to_frame (dpyinfo, event.xproperty.window);
if (f && event.xproperty.atom == dpyinfo->Xatom_net_wm_state)
- x_handle_net_wm_state (f, &event.xproperty);
+ if (x_handle_net_wm_state (f, &event.xproperty) && f->iconified)
+ {
+ /* Gnome shell does not iconify us when C-z is pressed. It hides
+ the frame. So if our state says we aren't hidden anymore,
+ treat is as deiconfied. */
+ if (! f->async_iconified)
+ SET_FRAME_GARBAGED (f);
+ f->async_visible = 1;
+ f->async_iconified = 0;
+ f->output_data.x->has_been_visible = 1;
+ inev.ie.kind = DEICONIFY_EVENT;
+ XSETFRAME (inev.ie.frame_or_window, f);
+ }
x_handle_property_notify (&event.xproperty);
xft_settings_event (dpyinfo, &event);
@@ -8573,9 +8585,10 @@ x_set_sticky (f, new_value, old_value)
/* Return the current _NET_WM_STATE.
SIZE_STATE is set to one of the FULLSCREEN_* values.
- STICKY is set to 1 if the sticky state is set, 0 if not. */
+ STICKY is set to 1 if the sticky state is set, 0 if not.
+ Return non-zero if we are not hidden, zero if we are. */
-static void
+static int
get_current_vm_state (struct frame *f,
Window window,
int *size_state,
@@ -8583,7 +8596,7 @@ get_current_vm_state (struct frame *f,
{
Atom actual_type;
unsigned long actual_size, bytes_remaining;
- int i, rc, actual_format;
+ int i, rc, actual_format, is_hidden = 0;
struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
long max_len = 65536;
Display *dpy = FRAME_X_DISPLAY (f);
@@ -8605,7 +8618,7 @@ get_current_vm_state (struct frame *f,
if (tmp_data) XFree (tmp_data);
x_uncatch_errors ();
UNBLOCK_INPUT;
- return;
+ return ! f->iconified;
}
x_uncatch_errors ();
@@ -8613,7 +8626,9 @@ get_current_vm_state (struct frame *f,
for (i = 0; i < actual_size; ++i)
{
Atom a = ((Atom*)tmp_data)[i];
- if (a == dpyinfo->Xatom_net_wm_state_maximized_horz)
+ if (a == dpyinfo->Xatom_net_wm_state_hidden)
+ is_hidden = 1;
+ else if (a == dpyinfo->Xatom_net_wm_state_maximized_horz)
{
if (*size_state == FULLSCREEN_HEIGHT)
*size_state = FULLSCREEN_MAXIMIZED;
@@ -8635,6 +8650,7 @@ get_current_vm_state (struct frame *f,
if (tmp_data) XFree (tmp_data);
UNBLOCK_INPUT;
+ return ! is_hidden;
}
/* Do fullscreen as specified in extended window manager hints */
@@ -8647,7 +8663,7 @@ do_ewmh_fullscreen (f)
Lisp_Object lval = get_frame_param (f, Qfullscreen);
int cur, dummy;
- get_current_vm_state (f, FRAME_OUTER_WINDOW (f), &cur, &dummy);
+ (void)get_current_vm_state (f, FRAME_OUTER_WINDOW (f), &cur, &dummy);
/* Some window managers don't say they support _NET_WM_STATE, but they do say
they support _NET_WM_STATE_FULLSCREEN. Try that also. */
@@ -8721,7 +8737,7 @@ XTfullscreen_hook (f)
}
-static void
+static int
x_handle_net_wm_state (f, event)
struct frame *f;
XPropertyEvent *event;
@@ -8729,10 +8745,10 @@ x_handle_net_wm_state (f, event)
int value = FULLSCREEN_NONE;
Lisp_Object lval;
int sticky = 0;
+ int not_hidden = get_current_vm_state (f, event->window, &value, &sticky);
- get_current_vm_state (f, event->window, &value, &sticky);
lval = Qnil;
- switch (value)
+ switch (value)
{
case FULLSCREEN_WIDTH:
lval = Qfullwidth;
@@ -8747,9 +8763,10 @@ x_handle_net_wm_state (f, event)
lval = Qmaximized;
break;
}
-
store_frame_param (f, Qfullscreen, lval);
store_frame_param (f, Qsticky, sticky ? Qt : Qnil);
+
+ return not_hidden;
}
/* Check if we need to resize the frame due to a fullscreen request.
@@ -9487,7 +9504,7 @@ x_iconify_frame (f)
if (!NILP (type))
x_bitmap_icon (f, type);
-#ifdef USE_GTK
+#if defined (USE_GTK)
if (FRAME_GTK_OUTER_WIDGET (f))
{
if (! FRAME_VISIBLE_P (f))
@@ -10518,6 +10535,8 @@ x_term_init (display_name, xrm_option, r
= XInternAtom (dpyinfo->display, "_NET_WM_STATE_MAXIMIZED_VERT", False);
dpyinfo->Xatom_net_wm_state_sticky
= XInternAtom (dpyinfo->display, "_NET_WM_STATE_STICKY", False);
+ dpyinfo->Xatom_net_wm_state_hidden
+ = XInternAtom (dpyinfo->display, "_NET_WM_STATE_HIDDEN", False);
dpyinfo->Xatom_net_window_type
= XInternAtom (dpyinfo->display, "_NET_WM_WINDOW_TYPE", False);
dpyinfo->Xatom_net_window_type_tooltip
diff -up emacs-23.3/src/xterm.h.wm-state-hidden emacs-23.3/src/xterm.h
--- emacs-23.3/src/xterm.h.wm-state-hidden 2011-01-08 18:45:14.000000000 +0100
+++ emacs-23.3/src/xterm.h 2011-11-23 11:56:01.219467181 +0100
@@ -365,7 +365,7 @@ struct x_display_info
/* Atoms dealing with EWMH (i.e. _NET_...) */
Atom Xatom_net_wm_state, Xatom_net_wm_state_fullscreen_atom,
Xatom_net_wm_state_maximized_horz, Xatom_net_wm_state_maximized_vert,
- Xatom_net_wm_state_sticky, Xatom_net_frame_extents;
+ Xatom_net_wm_state_sticky, Xatom_net_wm_state_hidden, Xatom_net_frame_extents;
/* XSettings atoms and windows. */
Atom Xatom_xsettings_sel, Xatom_xsettings_prop, Xatom_xsettings_mgr;

View File

@ -3,7 +3,7 @@ Summary: GNU Emacs text editor
Name: emacs Name: emacs
Epoch: 1 Epoch: 1
Version: 23.3 Version: 23.3
Release: 14%{?dist} Release: 15%{?dist}
License: GPLv3+ License: GPLv3+
URL: http://www.gnu.org/software/emacs/ URL: http://www.gnu.org/software/emacs/
Group: Applications/Editors Group: Applications/Editors
@ -32,6 +32,9 @@ Patch4: emacs-23.1-xdg.patch
Patch6: emacs-23.2-hideshow-comment.patch Patch6: emacs-23.2-hideshow-comment.patch
# rhbz#713600 # rhbz#713600
Patch7: emacs-spellchecker.patch Patch7: emacs-spellchecker.patch
# rhbz#711739
# http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/106247
Patch8: emacs-wm-state-hidden.patch
BuildRequires: atk-devel, cairo-devel, freetype-devel, fontconfig-devel, dbus-devel, giflib-devel, glibc-devel, gtk2-devel, libpng-devel BuildRequires: atk-devel, cairo-devel, freetype-devel, fontconfig-devel, dbus-devel, giflib-devel, glibc-devel, gtk2-devel, libpng-devel
BuildRequires: libjpeg-devel, libtiff-devel, libX11-devel, libXau-devel, libXdmcp-devel, libXrender-devel, libXt-devel BuildRequires: libjpeg-devel, libtiff-devel, libX11-devel, libXau-devel, libXdmcp-devel, libXrender-devel, libXt-devel
BuildRequires: libXpm-devel, ncurses-devel, xorg-x11-proto-devel, zlib-devel BuildRequires: libXpm-devel, ncurses-devel, xorg-x11-proto-devel, zlib-devel
@ -154,6 +157,7 @@ packages that add functionality to Emacs.
%patch4 -p1 -b .xdg %patch4 -p1 -b .xdg
%patch6 -p0 -b .hideshow-comment %patch6 -p0 -b .hideshow-comment
%patch7 -p1 -b .spellchecker %patch7 -p1 -b .spellchecker
%patch8 -p1 -b .wm-state-hidden
# Install site-lisp files # Install site-lisp files
cp %SOURCE7 %SOURCE10 site-lisp cp %SOURCE7 %SOURCE10 site-lisp
@ -433,6 +437,9 @@ update-desktop-database &> /dev/null || :
%dir %{_datadir}/emacs/site-lisp/site-start.d %dir %{_datadir}/emacs/site-lisp/site-start.d
%changelog %changelog
* Wed Nov 23 2011 Karel Klíč <kklic@redhat.com> - 1:23.3-15
- Check for _NET_WM_STATE_HIDDEN (rhbz#711739)
* Tue Nov 22 2011 Karel Klíč <kklic@redhat.com> - 1:23.3-14 * Tue Nov 22 2011 Karel Klíč <kklic@redhat.com> - 1:23.3-14
- Build Gtk+ version without gpm - Build Gtk+ version without gpm