vcl/inc/unx/saldisp.hxx | 5 ++++- vcl/inc/unx/wmadaptor.hxx | 8 ++++++++ vcl/unx/generic/app/saldisp.cxx | 2 +- vcl/unx/generic/app/wmadaptor.cxx | 25 +++++++++++++++++++++++++ vcl/unx/generic/window/salframe.cxx | 13 +++++++++++-- 5 files changed, 49 insertions(+), 4 deletions(-)
New commits: commit e36099bdb5a9c15f728f3fac9a08c6ffb1dba699 Author: Katarina Behrens <katarina.behr...@cib.de> Date: Tue Nov 7 15:09:42 2017 +0100 tdf#48300 kde4+gen: bring forward the window with already opened doc Send _NET_ACTIVE_WINDOW message to the mapped frame with the timestamp of current X11 server time (the real timestamp, not CurrentTime constant, otherwise e.g. KWin focus stealing prevention would kick in) Reviewed-on: https://gerrit.libreoffice.org/44409 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de> (cherry picked from commit bb6a8dce405bd0fcd551c217c05a503e559dbf4d) Conflicts: vcl/inc/unx/wmadaptor.hxx Change-Id: I637e1c3548b874e7267f8fc71ffcca4b1a82a412 diff --git a/vcl/inc/unx/saldisp.hxx b/vcl/inc/unx/saldisp.hxx index f1776153fd2a..b7479c07626e 100644 --- a/vcl/inc/unx/saldisp.hxx +++ b/vcl/inc/unx/saldisp.hxx @@ -296,6 +296,7 @@ protected: void doDestruct(); void addXineramaScreenUnique( int i, long i_nX, long i_nY, long i_nWidth, long i_nHeight ); + Time GetEventTimeImpl( bool bAlwaysReget = false ) const; public: static bool BestOpenGLVisual(Display* pDisplay, int nScreen, XVisualInfo& rVI); static bool BestVisual(Display *pDisp, int nScreen, XVisualInfo &rVI); @@ -353,7 +354,9 @@ public: RenderEntryMap& GetRenderEntries( SalX11Screen nXScreen ) const { return getDataForScreen(nXScreen).m_aRenderData; } const Pair &GetResolution() const { return aResolution_; } sal_uLong GetMaxRequestSize() const { return nMaxRequestSize_; } - Time GetLastUserEventTime( bool bAlwaysReget = false ) const; + Time GetLastUserEventTime() const { return GetEventTimeImpl(); } + // this is an equivalent of gdk_x11_get_server_time() + Time GetX11ServerTime() const { return GetEventTimeImpl( true ); } bool XIfEventWithTimeout( XEvent*, XPointer, X_if_predicate ) const; SalXLib* GetXLib() const { return pXLib_; } diff --git a/vcl/inc/unx/wmadaptor.hxx b/vcl/inc/unx/wmadaptor.hxx index 177ca34780a1..83e6c338ad18 100644 --- a/vcl/inc/unx/wmadaptor.hxx +++ b/vcl/inc/unx/wmadaptor.hxx @@ -42,6 +42,7 @@ public: UTF8_STRING, // atoms for extended WM hints + NET_ACTIVE_WINDOW, NET_SUPPORTED, NET_SUPPORTING_WM_CHECK, NET_WM_NAME, @@ -309,6 +310,13 @@ public: * if reference frame is NULL the root window is used instead */ void changeReferenceFrame( X11SalFrame* pFrame, X11SalFrame* pReferenceFrame ) const; + + /* + * Requests the change of active window by sending + * _NET_ACTIVE_WINDOW message to the frame. The frame + * has to be mapped + */ + void activateWindow( X11SalFrame *pFrame, Time nTimestamp ); }; } // namespace diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx index ec5325066e04..c88763fc6b32 100644 --- a/vcl/unx/generic/app/saldisp.cxx +++ b/vcl/unx/generic/app/saldisp.cxx @@ -2349,7 +2349,7 @@ extern "C" } } -Time SalDisplay::GetLastUserEventTime( bool i_bAlwaysReget ) const +Time SalDisplay::GetEventTimeImpl( bool i_bAlwaysReget ) const { if( m_nLastUserEventTime == CurrentTime || i_bAlwaysReget ) { diff --git a/vcl/unx/generic/app/wmadaptor.cxx b/vcl/unx/generic/app/wmadaptor.cxx index 813465503308..0fe8755de2af 100644 --- a/vcl/unx/generic/app/wmadaptor.cxx +++ b/vcl/unx/generic/app/wmadaptor.cxx @@ -97,6 +97,7 @@ struct WMAdaptorProtocol static const WMAdaptorProtocol aProtocolTab[] = { { "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE", WMAdaptor::KDE_NET_WM_WINDOW_TYPE_OVERRIDE }, + { "_NET_ACTIVE_WINDOW", WMAdaptor::NET_ACTIVE_WINDOW }, { "_NET_CURRENT_DESKTOP", WMAdaptor::NET_CURRENT_DESKTOP }, { "_NET_NUMBER_OF_DESKTOPS", WMAdaptor::NET_NUMBER_OF_DESKTOPS }, { "_NET_WM_DESKTOP", WMAdaptor::NET_WM_DESKTOP }, @@ -2316,4 +2317,28 @@ void WMAdaptor::answerPing( X11SalFrame* i_pFrame, XClientMessageEvent* i_pEvent } } +void WMAdaptor::activateWindow( X11SalFrame *pFrame, Time nTimestamp ) +{ + if (pFrame->bMapped_) + { + XEvent aEvent; + + aEvent.xclient.type = ClientMessage; + aEvent.xclient.window = pFrame->GetShellWindow(); + aEvent.xclient.message_type = m_aWMAtoms[ NET_ACTIVE_WINDOW ]; + aEvent.xclient.format = 32; + aEvent.xclient.data.l[0] = 1; + aEvent.xclient.data.l[1] = nTimestamp; + aEvent.xclient.data.l[2] = None; + aEvent.xclient.data.l[3] = 0; + aEvent.xclient.data.l[4] = 0; + + XSendEvent( m_pDisplay, + m_pSalDisplay->GetRootWindow( pFrame->GetScreenNumber() ), + False, + SubstructureNotifyMask | SubstructureRedirectMask, + &aEvent ); + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx index b4263fa56b0e..1e55e15da4e1 100644 --- a/vcl/unx/generic/window/salframe.cxx +++ b/vcl/unx/generic/window/salframe.cxx @@ -1222,7 +1222,7 @@ void X11SalFrame::Show( bool bVisible, bool bNoActivate ) Time nUserTime = 0; if( ! bNoActivate && !(nStyle_ & SalFrameStyleFlags::OWNERDRAWDECORATION) ) - nUserTime = pDisplay_->GetLastUserEventTime( true ); + nUserTime = pDisplay_->GetX11ServerTime(); GetDisplay()->getWMAdaptor()->setUserTime( this, nUserTime ); if( ! bNoActivate && (nStyle_ & SalFrameStyleFlags::TOOLWINDOW) ) m_bSetFocusOnMap = true; @@ -1387,8 +1387,17 @@ void X11SalFrame::ToTop( SalFrameToTop nFlags ) && bMapped_ ) { if( m_bXEmbed ) + { askForXEmbedFocus( 0 ); - else + return; + } + + if ( nFlags & SalFrameToTop::GrabFocus ) + { + Time nTimestamp = pDisplay_->GetX11ServerTime(); + GetDisplay()->getWMAdaptor()->activateWindow( this, nTimestamp ); + } + else if ( nFlags & SalFrameToTop::GrabFocusOnly ) XSetInputFocus( GetXDisplay(), aToTopWindow, RevertToParent, CurrentTime ); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits