From 9536eb17ed6204e2e67e4f6173c0118c1b80e94f Mon Sep 17 00:00:00 2001 From: Jan-Marek Glogowski Date: Wed, 14 Apr 2021 23:56:50 +0200 Subject: enum class X11ShowState Change-Id: I1e1f7f97bbb6d41f61a0ee9195cc84e0f680b741 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114115 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski --- vcl/inc/unx/salframe.h | 13 +++++--- vcl/unx/generic/app/wmadaptor.cxx | 4 +-- vcl/unx/generic/window/salframe.cxx | 62 ++++++++++++++++++------------------- 3 files changed, 41 insertions(+), 38 deletions(-) diff --git a/vcl/inc/unx/salframe.h b/vcl/inc/unx/salframe.h index 7bc7b8bc3167..0c56bc677d04 100644 --- a/vcl/inc/unx/salframe.h +++ b/vcl/inc/unx/salframe.h @@ -42,10 +42,13 @@ class SalI18N_InputContext; namespace vcl_sal { class WMAdaptor; class NetWMAdaptor; class GnomeWMAdaptor; } // X11SalFrame -#define SHOWSTATE_UNKNOWN -1 -#define SHOWSTATE_MINIMIZED 0 -#define SHOWSTATE_NORMAL 1 -#define SHOWSTATE_HIDDEN 2 +enum class X11ShowState +{ + Unknown = -1, + Minimized = 0, + Normal = 1, + Hidden = 2 +}; enum class WMWindowType { @@ -86,7 +89,7 @@ class X11SalFrame final : public SalFrame bool mbSendExtKeyModChange; ModKeyFlags mnExtKeyMod; - int nShowState_; // show state + X11ShowState nShowState_; // show state int nWidth_; // client width int nHeight_; // client height tools::Rectangle maRestorePosSize; diff --git a/vcl/unx/generic/app/wmadaptor.cxx b/vcl/unx/generic/app/wmadaptor.cxx index 41beceee1306..0b4c75e8b305 100644 --- a/vcl/unx/generic/app/wmadaptor.cxx +++ b/vcl/unx/generic/app/wmadaptor.cxx @@ -1151,7 +1151,7 @@ void NetWMAdaptor::setNetWMState( X11SalFrame* pFrame ) const * reset gravity hint to static gravity * (this should not move window according to ICCCM) */ - if( bHint && pFrame->nShowState_ != SHOWSTATE_UNKNOWN ) + if( bHint && pFrame->nShowState_ != X11ShowState::Unknown ) { hints.win_gravity = StaticGravity; XSetWMNormalHints( m_pDisplay, @@ -1239,7 +1239,7 @@ void GnomeWMAdaptor::setGnomeWMState( X11SalFrame* pFrame ) const * reset gravity hint to static gravity * (this should not move window according to ICCCM) */ - if( bHint && pFrame->nShowState_ != SHOWSTATE_UNKNOWN ) + if( bHint && pFrame->nShowState_ != X11ShowState::Unknown ) { hints.win_gravity = StaticGravity; XSetWMNormalHints( m_pDisplay, diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx index f0dfb480c0cb..f593e6d89a58 100644 --- a/vcl/unx/generic/window/salframe.cxx +++ b/vcl/unx/generic/window/salframe.cxx @@ -412,7 +412,7 @@ void X11SalFrame::Init( SalFrameStyleFlags nSalFrameStyle, SalX11Screen nXScreen ! (nSalFrameStyle & SalFrameStyleFlags::OWNERDRAWDECORATION) ) { - if( nShowState_ == SHOWSTATE_UNKNOWN ) + if( nShowState_ == X11ShowState::Unknown ) { w = 10; h = 10; @@ -631,7 +631,7 @@ void X11SalFrame::Init( SalFrameStyleFlags nSalFrameStyle, SalX11Screen nXScreen } } - nShowState_ = SHOWSTATE_UNKNOWN; + nShowState_ = X11ShowState::Unknown; bViewable_ = true; bMapped_ = false; nVisibility_ = VisibilityFullyObscured; @@ -830,7 +830,7 @@ X11SalFrame::X11SalFrame( SalFrame *pParent, SalFrameStyleFlags nSalFrameStyle, mbSendExtKeyModChange = false; mnExtKeyMod = ModKeyFlags::NONE; - nShowState_ = SHOWSTATE_UNKNOWN; + nShowState_ = X11ShowState::Unknown; nWidth_ = 0; nHeight_ = 0; nStyle_ = SalFrameStyleFlags::NONE; @@ -1192,7 +1192,7 @@ void X11SalFrame::Show( bool bVisible, bool bNoActivate ) } // update NET_WM_STATE which may have been deleted due to earlier Show(false) - if( nShowState_ == SHOWSTATE_HIDDEN ) + if( nShowState_ == X11ShowState::Hidden ) GetDisplay()->getWMAdaptor()->frameIsMapping( this ); /* @@ -1322,11 +1322,11 @@ void X11SalFrame::Show( bool bVisible, bool bNoActivate ) } } /* - * leave SHOWSTATE_UNKNOWN as this indicates first mapping + * leave X11ShowState::Unknown as this indicates first mapping * and is only reset int HandleSizeEvent */ - if( nShowState_ != SHOWSTATE_UNKNOWN ) - nShowState_ = SHOWSTATE_NORMAL; + if( nShowState_ != X11ShowState::Unknown ) + nShowState_ = X11ShowState::Normal; /* * plugged windows don't necessarily get the @@ -1365,7 +1365,7 @@ void X11SalFrame::Show( bool bVisible, bool bNoActivate ) else if( ! m_bXEmbed ) XUnmapWindow( GetXDisplay(), GetWindow() ); - nShowState_ = SHOWSTATE_HIDDEN; + nShowState_ = X11ShowState::Hidden; if( IsFloatGrabWindow() && nVisibleFloats ) { nVisibleFloats--; @@ -1383,8 +1383,8 @@ void X11SalFrame::ToTop( SalFrameToTop nFlags ) { if( ( nFlags & SalFrameToTop::RestoreWhenMin ) && ! ( nStyle_ & SalFrameStyleFlags::FLOAT ) - && nShowState_ != SHOWSTATE_HIDDEN - && nShowState_ != SHOWSTATE_UNKNOWN + && nShowState_ != X11ShowState::Hidden + && nShowState_ != X11ShowState::Unknown ) { GetDisplay()->getWMAdaptor()->frameIsMapping( this ); @@ -1521,7 +1521,7 @@ void X11SalFrame::Center( ) } } - if( mpParent && mpParent->nShowState_ == SHOWSTATE_NORMAL ) + if( mpParent && mpParent->nShowState_ == X11ShowState::Normal ) { if( maGeometry.nWidth >= mpParent->maGeometry.nWidth && maGeometry.nHeight >= mpParent->maGeometry.nHeight ) @@ -1755,7 +1755,7 @@ void X11SalFrame::SetWindowState( const SalFrameState *pState ) if (pState->mnState & WindowStateState::Maximized) { - nShowState_ = SHOWSTATE_NORMAL; + nShowState_ = X11ShowState::Normal; if( ! (pState->mnState & (WindowStateState::MaximizedHorz|WindowStateState::MaximizedVert) ) ) Maximize(); else @@ -1774,20 +1774,20 @@ void X11SalFrame::SetWindowState( const SalFrameState *pState ) if (pState->mnState & WindowStateState::Minimized) { - if (nShowState_ == SHOWSTATE_UNKNOWN) - nShowState_ = SHOWSTATE_NORMAL; + if (nShowState_ == X11ShowState::Unknown) + nShowState_ = X11ShowState::Normal; Minimize(); } if (pState->mnState & WindowStateState::Normal) { - if (nShowState_ != SHOWSTATE_NORMAL) + if (nShowState_ != X11ShowState::Normal) Restore(); } } bool X11SalFrame::GetWindowState( SalFrameState* pState ) { - if( SHOWSTATE_MINIMIZED == nShowState_ ) + if( X11ShowState::Minimized == nShowState_ ) pState->mnState = WindowStateState::Minimized; else pState->mnState = WindowStateState::Normal; @@ -1931,8 +1931,8 @@ void X11SalFrame::SetPosSize( const tools::Rectangle &rPosSize ) // popups (menu, help window, etc.) && (nStyle_ & (SalFrameStyleFlags::FLOAT|SalFrameStyleFlags::OWNERDRAWDECORATION) ) != SalFrameStyleFlags::FLOAT // shown, sizeable windows - && ( nShowState_ == SHOWSTATE_UNKNOWN || - nShowState_ == SHOWSTATE_HIDDEN || + && ( nShowState_ == X11ShowState::Unknown || + nShowState_ == X11ShowState::Hidden || ! ( nStyle_ & SalFrameStyleFlags::SIZEABLE ) ) ) @@ -1952,7 +1952,7 @@ void X11SalFrame::SetPosSize( const tools::Rectangle &rPosSize ) pHints->max_height = rPosSize.GetHeight(); pHints->flags |= PMinSize | PMaxSize; } - if( nShowState_ == SHOWSTATE_UNKNOWN || nShowState_ == SHOWSTATE_HIDDEN ) + if( nShowState_ == X11ShowState::Unknown || nShowState_ == X11ShowState::Hidden ) { pHints->flags |= PPosition | PWinGravity; pHints->x = values.x; @@ -2009,7 +2009,7 @@ void X11SalFrame::Minimize() if( IsSysChildWindow() ) return; - if( SHOWSTATE_UNKNOWN == nShowState_ || SHOWSTATE_HIDDEN == nShowState_ ) + if( X11ShowState::Unknown == nShowState_ || X11ShowState::Hidden == nShowState_ ) { SAL_WARN( "vcl", "X11SalFrame::Minimize on withdrawn window" ); return; @@ -2018,7 +2018,7 @@ void X11SalFrame::Minimize() if( XIconifyWindow( GetXDisplay(), GetShellWindow(), pDisplay_->GetDefaultXScreen().getXScreen() ) ) - nShowState_ = SHOWSTATE_MINIMIZED; + nShowState_ = X11ShowState::Minimized; } void X11SalFrame::Maximize() @@ -2026,11 +2026,11 @@ void X11SalFrame::Maximize() if( IsSysChildWindow() ) return; - if( SHOWSTATE_MINIMIZED == nShowState_ ) + if( X11ShowState::Minimized == nShowState_ ) { GetDisplay()->getWMAdaptor()->frameIsMapping( this ); XMapWindow( GetXDisplay(), GetShellWindow() ); - nShowState_ = SHOWSTATE_NORMAL; + nShowState_ = X11ShowState::Normal; } pDisplay_->getWMAdaptor()->maximizeFrame( this ); @@ -2041,17 +2041,17 @@ void X11SalFrame::Restore() if( IsSysChildWindow() ) return; - if( SHOWSTATE_UNKNOWN == nShowState_ || SHOWSTATE_HIDDEN == nShowState_ ) + if( X11ShowState::Unknown == nShowState_ || X11ShowState::Hidden == nShowState_ ) { SAL_INFO( "vcl", "X11SalFrame::Restore on withdrawn window" ); return; } - if( SHOWSTATE_MINIMIZED == nShowState_ ) + if( X11ShowState::Minimized == nShowState_ ) { GetDisplay()->getWMAdaptor()->frameIsMapping( this ); XMapWindow( GetXDisplay(), GetShellWindow() ); - nShowState_ = SHOWSTATE_NORMAL; + nShowState_ = X11ShowState::Normal; } pDisplay_->getWMAdaptor()->maximizeFrame( this, false, false ); @@ -3509,8 +3509,8 @@ bool X11SalFrame::HandleSizeEvent( XConfigureEvent *pEvent ) } // check size hints in first time SalFrame::Show - if( SHOWSTATE_UNKNOWN == nShowState_ && bMapped_ ) - nShowState_ = SHOWSTATE_NORMAL; + if( X11ShowState::Unknown == nShowState_ && bMapped_ ) + nShowState_ = X11ShowState::Normal; // Avoid a race condition where resizing this window to one size and shortly after that // to another size generates first size event with the old size and only after that @@ -3766,9 +3766,9 @@ bool X11SalFrame::HandleStateEvent( XPropertyEvent const *pEvent ) && 0 == bytes_after, "HandleStateEvent" ); if( *reinterpret_cast(prop) == NormalState ) - nShowState_ = SHOWSTATE_NORMAL; + nShowState_ = X11ShowState::Normal; else if( *reinterpret_cast(prop) == IconicState ) - nShowState_ = SHOWSTATE_MINIMIZED; + nShowState_ = X11ShowState::Minimized; XFree( prop ); return true; @@ -3893,7 +3893,7 @@ bool X11SalFrame::Dispatch( XEvent *pEvent ) case MapNotify: if( pEvent->xmap.window == GetShellWindow() ) { - if( nShowState_ == SHOWSTATE_HIDDEN ) + if( nShowState_ == X11ShowState::Hidden ) { /* * workaround for (at least) KWin 2.2.2 -- cgit