fix Java focus issues with ICCCM WM_TAKE_FOCUS patch (#874855)

- see http://code.google.com/p/xmonad/issues/detail?id=177
- refresh packaging to cabal-rpm-0.6.5
This commit is contained in:
Jens Petersen 2012-11-17 12:56:29 +09:00
parent 47c5aac56e
commit c569256716
2 changed files with 125 additions and 12 deletions

View File

@ -0,0 +1,105 @@
Mon Feb 22 06:45:12 PST 2010 Adam Vogt <vogt.adam@gmail.com>
* Resolve conflicts Geoff Reedy's window focus hack.
Sat Oct 10 16:19:07 PDT 2009 Geoff Reedy <geoff@programmer-monk.net>
* Give focus to windows that don't set the input hint
Sun Jun 21 22:19:11 PDT 2009 Geoff Reedy <geoff@programmer-monk.net>
* implement the ICCCM WM_TAKE_FOCUS protocol
Sun Jun 21 20:56:49 PDT 2009 Geoff Reedy <geoff@programmer-monk.net>
* track currently processing event
diff -rN -u old-xmonad/XMonad/Core.hs new-xmonad/XMonad/Core.hs
--- old-xmonad/XMonad/Core.hs 2012-11-14 22:40:50.637523085 -0800
+++ new-xmonad/XMonad/Core.hs 2012-11-14 22:40:50.649523104 -0800
@@ -26,7 +26,7 @@
runX, catchX, userCode, userCodeDef, io, catchIO, installSignalHandlers, uninstallSignalHandlers,
withDisplay, withWindowSet, isRoot, runOnWorkspaces,
getAtom, spawn, spawnPID, xfork, getXMonadDir, recompile, trace, whenJust, whenX,
- atom_WM_STATE, atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW, ManageHook, Query(..), runQuery
+ atom_WM_STATE, atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW, atom_WM_TAKE_FOCUS, ManageHook, Query(..), runQuery
) where
import XMonad.StackSet hiding (modify)
@@ -86,6 +86,8 @@
, mousePosition :: !(Maybe (Position, Position))
-- ^ position of the mouse according to
-- the event currently being processed
+ , currentEvent :: !(Maybe Event)
+ -- ^ event currently being processed
}
-- todo, better name
@@ -202,10 +204,11 @@
getAtom str = withDisplay $ \dpy -> io $ internAtom dpy str False
-- | Common non-predefined atoms
-atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW, atom_WM_STATE :: X Atom
+atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW, atom_WM_STATE, atom_WM_TAKE_FOCUS :: X Atom
atom_WM_PROTOCOLS = getAtom "WM_PROTOCOLS"
atom_WM_DELETE_WINDOW = getAtom "WM_DELETE_WINDOW"
atom_WM_STATE = getAtom "WM_STATE"
+atom_WM_TAKE_FOCUS = getAtom "WM_TAKE_FOCUS"
------------------------------------------------------------------------
-- LayoutClass handling. See particular instances in Operations.hs
diff -rN -u old-xmonad/XMonad/Main.hsc new-xmonad/XMonad/Main.hsc
--- old-xmonad/XMonad/Main.hsc 2012-11-14 22:40:50.636523083 -0800
+++ new-xmonad/XMonad/Main.hsc 2012-11-14 22:40:50.652523110 -0800
@@ -121,7 +121,8 @@
, keyActions = keys xmc xmc
, buttonActions = mouseBindings xmc xmc
, mouseFocused = False
- , mousePosition = Nothing }
+ , mousePosition = Nothing
+ , currentEvent = Nothing }
st = XState
{ windowset = initialWinset
@@ -163,7 +164,7 @@
prehandle e = let mouse = do guard (ev_event_type e `elem` evs)
return (fromIntegral (ev_x_root e)
,fromIntegral (ev_y_root e))
- in local (\c -> c { mousePosition = mouse }) (handleWithHook e)
+ in local (\c -> c { mousePosition = mouse, currentEvent = Just e }) (handleWithHook e)
evs = [ keyPress, keyRelease, enterNotify, leaveNotify
, buttonPress, buttonRelease]
diff -rN -u old-xmonad/XMonad/Operations.hs new-xmonad/XMonad/Operations.hs
--- old-xmonad/XMonad/Operations.hs 2012-11-14 22:40:50.630523074 -0800
+++ new-xmonad/XMonad/Operations.hs 2012-11-14 22:40:50.654523114 -0800
@@ -24,7 +24,7 @@
import Data.Maybe
import Data.Monoid (Endo(..))
import Data.List (nub, (\\), find)
-import Data.Bits ((.|.), (.&.), complement)
+import Data.Bits ((.|.), (.&.), complement, testBit)
import Data.Ratio
import qualified Data.Map as M
import qualified Data.Set as S
@@ -325,7 +325,27 @@
-- If we ungrab buttons on the root window, we lose our mouse bindings.
whenX (not <$> isRoot w) $ setButtonGrab False w
- io $ setInputFocus dpy w revertToPointerRoot 0
+
+ hints <- io $ getWMHints dpy w
+ protocols <- io $ getWMProtocols dpy w
+ wmprot <- atom_WM_PROTOCOLS
+ wmtf <- atom_WM_TAKE_FOCUS
+ currevt <- asks currentEvent
+ let inputHintSet = wmh_flags hints `testBit` inputHintBit
+
+ when ((inputHintSet && wmh_input hints) || (not inputHintSet)) $
+ io $ do setInputFocus dpy w revertToPointerRoot 0
+ when (wmtf `elem` protocols) $
+ io $ allocaXEvent $ \ev -> do
+ setEventType ev clientMessage
+ setClientMessageEvent ev w wmprot 32 wmtf $ maybe currentTime event_time currevt
+ sendEvent dpy w False noEventMask ev
+ where event_time ev =
+ if (ev_event_type ev) `elem` timedEvents then
+ ev_time ev
+ else
+ currentTime
+ timedEvents = [ keyPress, keyRelease, buttonPress, buttonRelease, enterNotify, leaveNotify, selectionRequest ]
------------------------------------------------------------------------
-- Message handling

View File

@ -1,10 +1,9 @@
# cabal2spec-0.25.2
# https://fedoraproject.org/wiki/Packaging:Haskell
# https://fedoraproject.org/wiki/PackagingDrafts/Haskell
%global pkg_name xmonad
%global common_summary xmonad tiling window manager
%global common_summary XMonad tiling window manager
%global common_description xmonad is a tiling window manager for X. Windows are arranged\
automatically to tile the screen without gaps or overlap, maximising\
@ -18,18 +17,12 @@ on several screens.
Name: %{pkg_name}
Version: 0.10
Release: 14%{?dist}
Release: 15%{?dist}
Summary: A tiling window manager
Group: User Interface/X
License: BSD
# BEGIN cabal2spec
URL: http://hackage.haskell.org/package/%{name}
Source0: http://hackage.haskell.org/packages/archive/%{name}/%{version}/%{name}-%{version}.tar.gz
ExclusiveArch: %{ghc_arches}
BuildRequires: ghc-Cabal-devel
BuildRequires: ghc-rpm-macros %{!?without_hscolour:hscolour}
# END cabal2spec
Source1: xmonad-session.desktop
Source2: xmonad-start
Source3: xmonad.desktop
@ -37,17 +30,25 @@ Source4: README.fedora
Source5: xmonad-gnome-session.desktop
Source6: xmonad.session
Source7: xmonad.hs
BuildRequires: desktop-file-utils
Patch1: xmonad-0.10-X11-1.6.patch
Patch2: xmonad-0.10-WM_TAKE_FOCUS-track-currently-processing-event.patch
BuildRequires: ghc-Cabal-devel
BuildRequires: ghc-rpm-macros
# Begin cabal-rpm deps:
BuildRequires: ghc-X11-devel
BuildRequires: ghc-containers-devel
BuildRequires: ghc-mtl-devel
BuildRequires: ghc-directory-devel
BuildRequires: ghc-extensible-exceptions-devel
BuildRequires: ghc-filepath-devel
BuildRequires: ghc-mtl-devel
BuildRequires: ghc-process-devel
BuildRequires: ghc-unix-devel
BuildRequires: ghc-utf8-string-devel
# End cabal-rpm deps
BuildRequires: desktop-file-utils
Requires: %{pkg_name}-basic = %{version}-%{release}
Requires: %{pkg_name}-config = %{version}-%{release}
Patch1: xmonad-0.10-X11-1.6.patch
%description
%{common_description}
@ -113,6 +114,7 @@ in a GNOME session.
%prep
%setup -q
%patch1 -p1 -b .orig
%patch2 -p1 -b .orig
cp -p %SOURCE4 .
@ -178,6 +180,12 @@ rm %{buildroot}%{_docdir}/%{name}-%{version}/LICENSE
%changelog
* Fri Nov 16 2012 Jens Petersen <petersen@redhat.com> - 0.10-15
- add upstream patches for ICCCM WM_TAKE_FOCUS protocol and
tracking currently processing event to fix focus for Java apps:
see http://code.google.com/p/xmonad/issues/detail?id=177 (#874855)
- update to cabal-rpm packaging
* Sun Jul 22 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.10-14
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild