LCOV - code coverage report
Current view: top level - libreoffice/vcl/inc/unx - wmadaptor.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 17 0.0 %
Date: 2012-12-27 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef _VCL_WMADAPTOR_HXX_
      21             : #define _VCL_WMADAPTOR_HXX_
      22             : 
      23             : #include <tools/string.hxx>
      24             : #include <tools/gen.hxx>
      25             : #ifndef _PREX_H
      26             : #include <tools/prex.h>
      27             : #include <X11/Xlib.h>
      28             : #include <tools/postx.h>
      29             : #endif
      30             : #include <vclpluginapi.h>
      31             : #include <vector>
      32             : 
      33             : class SalDisplay;
      34             : class X11SalFrame;
      35             : 
      36             : namespace vcl_sal {
      37             : 
      38             : class VCLPLUG_GEN_PUBLIC WMAdaptor
      39             : {
      40             : public:
      41             :     enum WMAtom {
      42             :         // atoms for types
      43             :         UTF8_STRING,
      44             : 
      45             :         // atoms for extended WM hints
      46             :         NET_SUPPORTED,
      47             :         NET_SUPPORTING_WM_CHECK,
      48             :         NET_WM_NAME,
      49             :         NET_WM_DESKTOP,
      50             :         NET_WM_ICON_NAME,
      51             :         NET_WM_PID,
      52             :         NET_WM_PING,
      53             :         NET_WM_STATE,
      54             :         NET_WM_STATE_MAXIMIZED_HORZ,
      55             :         NET_WM_STATE_MAXIMIZED_VERT,
      56             :         NET_WM_STATE_MODAL,
      57             :         NET_WM_STATE_SHADED,
      58             :         NET_WM_STATE_SKIP_PAGER,
      59             :         NET_WM_STATE_SKIP_TASKBAR,
      60             :         NET_WM_STATE_STAYS_ON_TOP,
      61             :         NET_WM_STATE_STICKY,
      62             :         NET_WM_STATE_FULLSCREEN,
      63             :         NET_WM_STRUT,
      64             :         NET_WM_STRUT_PARTIAL,
      65             :         NET_WM_USER_TIME,
      66             :         NET_WM_WINDOW_TYPE,
      67             :         NET_WM_WINDOW_TYPE_DESKTOP,
      68             :         NET_WM_WINDOW_TYPE_DIALOG,
      69             :         NET_WM_WINDOW_TYPE_DOCK,
      70             :         NET_WM_WINDOW_TYPE_MENU,
      71             :         NET_WM_WINDOW_TYPE_NORMAL,
      72             :         NET_WM_WINDOW_TYPE_TOOLBAR,
      73             :         KDE_NET_WM_WINDOW_TYPE_OVERRIDE,
      74             :         NET_WM_WINDOW_TYPE_SPLASH,
      75             :         NET_WM_WINDOW_TYPE_UTILITY,
      76             :         NET_NUMBER_OF_DESKTOPS,
      77             :         NET_CURRENT_DESKTOP,
      78             :         NET_WORKAREA,
      79             : 
      80             :         // atoms for Gnome WM hints
      81             :         WIN_SUPPORTING_WM_CHECK,
      82             :         WIN_PROTOCOLS,
      83             :         WIN_WORKSPACE_COUNT,
      84             :         WIN_WORKSPACE,
      85             :         WIN_LAYER,
      86             :         WIN_STATE,
      87             :         WIN_HINTS,
      88             :         WIN_APP_STATE,
      89             :         WIN_EXPANDED_SIZE,
      90             :         WIN_ICONS,
      91             :         WIN_WORKSPACE_NAMES,
      92             :         WIN_CLIENT_LIST,
      93             : 
      94             :         // atoms for general WM hints
      95             :         WM_STATE,
      96             :         MOTIF_WM_HINTS,
      97             :         WM_PROTOCOLS,
      98             :         WM_DELETE_WINDOW,
      99             :         WM_TAKE_FOCUS,
     100             :         WM_CLIENT_LEADER,
     101             :         WM_COMMAND,
     102             :         WM_LOCALE_NAME,
     103             :         WM_TRANSIENT_FOR,
     104             : 
     105             :         // special atoms
     106             :         SAL_QUITEVENT,
     107             :         SAL_USEREVENT,
     108             :         SAL_EXTTEXTEVENT,
     109             :         SAL_GETTIMEEVENT,
     110             :         DTWM_IS_RUNNING,
     111             :         VCL_SYSTEM_SETTINGS,
     112             :         XSETTINGS,
     113             :         XEMBED,
     114             :         XEMBED_INFO,
     115             :         NetAtomMax
     116             :     };
     117             : 
     118             :     /*
     119             :      *  flags for frame decoration
     120             :      */
     121             :     static const int decoration_Title           = 0x00000001;
     122             :     static const int decoration_Border      = 0x00000002;
     123             :     static const int decoration_Resize      = 0x00000004;
     124             :     static const int decoration_MinimizeBtn = 0x00000008;
     125             :     static const int decoration_MaximizeBtn = 0x00000010;
     126             :     static const int decoration_CloseBtn        = 0x00000020;
     127             :     static const int decoration_All         = 0x10000000;
     128             : 
     129             :     /*
     130             :      *  window type
     131             :      */
     132             :     enum WMWindowType
     133             :     {
     134             :         windowType_Normal,
     135             :         windowType_ModalDialogue,
     136             :         windowType_ModelessDialogue,
     137             :         windowType_Utility,
     138             :         windowType_Splash,
     139             :         windowType_Toolbar,
     140             :         windowType_Dock
     141             :     };
     142             : 
     143             : protected:
     144             :     SalDisplay*             m_pSalDisplay;      // Display to use
     145             :     Display*                m_pDisplay;         // X Display of SalDisplay
     146             :     String                  m_aWMName;
     147             :     Atom                    m_aWMAtoms[ NetAtomMax];
     148             :     int                     m_nDesktops;
     149             :     bool                    m_bEqualWorkAreas;
     150             :     ::std::vector< Rectangle >
     151             :                             m_aWMWorkAreas;
     152             :     bool                    m_bTransientBehaviour;
     153             :     bool                    m_bEnableAlwaysOnTopWorks;
     154             :     bool                    m_bLegacyPartialFullscreen;
     155             :     int                     m_nWinGravity;
     156             :     int                     m_nInitWinGravity;
     157             :     bool                    m_bWMshouldSwitchWorkspace;
     158             :     bool                    m_bWMshouldSwitchWorkspaceInit;
     159             : 
     160             :     WMAdaptor( SalDisplay * )
     161             : ;
     162             :     void initAtoms();
     163             :     bool getNetWmName();
     164             : 
     165             :     /*
     166             :      *  returns whether this instance is useful
     167             :      *  only useful for createWMAdaptor
     168             :      */
     169             :     virtual bool isValid() const;
     170             : 
     171             :     bool getWMshouldSwitchWorkspace() const;
     172             : public:
     173             :     virtual ~WMAdaptor();
     174             : 
     175             :     /*
     176             :      *  creates a vaild WMAdaptor instance for the SalDisplay
     177             :      */
     178             :     static WMAdaptor* createWMAdaptor( SalDisplay* );
     179             : 
     180             :     /*
     181             :      *  may return an empty string if the window manager could
     182             :      *  not be identified.
     183             :      */
     184           0 :     const String& getWindowManagerName() const
     185           0 :     { return m_aWMName; }
     186             : 
     187             :     /*
     188             :      *  gets the number of workareas
     189             :      */
     190             :     int getWorkAreaCount() const
     191             :     { return m_aWMWorkAreas.size(); }
     192             : 
     193             :     /*
     194             :      * gets the current work area/desktop number: [0,m_nDesktops[ or -1 if unknown
     195             :      */
     196             :     int getCurrentWorkArea() const;
     197             :     /*
     198             :      * gets the workarea the specified window is on (or -1)
     199             :      */
     200             :     int getWindowWorkArea( XLIB_Window aWindow ) const;
     201             :     /*
     202             :      *  gets the specified workarea
     203             :      */
     204           0 :     const Rectangle& getWorkArea( int n ) const
     205           0 :     { return m_aWMWorkAreas[n]; }
     206             : 
     207             :     /*
     208             :      * attemp to switch the desktop to a certain workarea
     209             :      * if bConsiderWM is true, then on some WMs the call will not result in any action
     210             :      */
     211             :     void switchToWorkArea( int nWorkArea, bool bConsiderWM = true ) const;
     212             : 
     213             :     /*
     214             :      *  sets window title
     215             :      */
     216             :     virtual void setWMName( X11SalFrame* pFrame, const String& rWMName ) const;
     217             : 
     218             :     /*
     219             :      * set NET_WM_PID
     220             :      */
     221             :     virtual void setPID( X11SalFrame* pFrame ) const;
     222             : 
     223             :     /*
     224             :      * set WM_CLIENT_MACHINE
     225             :      */
     226             :     virtual void setClientMachine( X11SalFrame* pFrame ) const;
     227             : 
     228             :     virtual void answerPing( X11SalFrame*, XClientMessageEvent* ) const;
     229             : 
     230             :     /*
     231             :      *  maximizes frame
     232             :      *  maximization can be toggled in either direction
     233             :      *  to get the original position and size
     234             :      *  use maximizeFrame( pFrame, false, false )
     235             :      */
     236             :     virtual void maximizeFrame( X11SalFrame* pFrame, bool bHorizontal = true, bool bVertical = true ) const;
     237             :     /*
     238             :      *  start/stop fullscreen mode on a frame
     239             :      */
     240             :     virtual void showFullScreen( X11SalFrame* pFrame, bool bFullScreen ) const;
     241             :     /*
     242             :      *  tell whether legacy partial full screen handling is necessary
     243             :      *  see #i107249#: NET_WM_STATE_FULLSCREEN is not well defined, but de facto
     244             :      *  modern WM's interpret it the "right" way, namely they make "full screen"
     245             :      *  taking twin view or Xinerama into accound and honor the positioning hints
     246             :      *  to see which screen actually was meant to use for fullscreen.
     247             :      */
     248           0 :     bool isLegacyPartialFullscreen() const
     249           0 :     { return m_bLegacyPartialFullscreen; }
     250             :     /*
     251             :      * set window struts
     252             :      */
     253             :     virtual void setFrameStruts( X11SalFrame*pFrame,
     254             :                                  int left, int right, int top, int bottom,
     255             :                                  int left_start_y, int left_end_y,
     256             :                                  int right_start_y, int right_end_y,
     257             :                                  int top_start_x, int top_end_x,
     258             :                                  int bottom_start_x, int bottom_end_x ) const;
     259             :     /*
     260             :      * set _NET_WM_USER_TIME property, if NetWM
     261             :      */
     262             :     virtual void setUserTime( X11SalFrame* i_pFrame, long i_nUserTime ) const;
     263             : 
     264             :     /*
     265             :      *  tells whether fullscreen mode is supported by WM
     266             :      */
     267           0 :     bool supportsFullScreen() const { return m_aWMAtoms[ NET_WM_STATE_FULLSCREEN ] != 0; }
     268             : 
     269             :     /*
     270             :      *  shade/unshade frame
     271             :      */
     272             :     virtual void shade( X11SalFrame* pFrame, bool bToShaded ) const;
     273             : 
     274             :     /*
     275             :      *  set hints what decoration is needed;
     276             :      *  must be called before showing the frame
     277             :      */
     278             :     virtual void setFrameTypeAndDecoration( X11SalFrame* pFrame, WMWindowType eType, int nDecorationFlags, X11SalFrame* pTransientFrame = NULL ) const;
     279             : 
     280             :     /*
     281             :      *  tells whether there is WM support for splash screens
     282             :      */
     283           0 :     bool supportsSplash() const { return m_aWMAtoms[ NET_WM_WINDOW_TYPE_SPLASH ] != 0; }
     284             : 
     285             :     /*
     286             :      *  tells whteher there is WM support for NET_WM_WINDOW_TYPE_TOOLBAR
     287             :      */
     288             :     bool supportsToolbar() const { return m_aWMAtoms[ NET_WM_WINDOW_TYPE_TOOLBAR ] != 0; }
     289             : 
     290             :     /*
     291             :      *  enables always on top or equivalent if possible
     292             :      */
     293             :     virtual void enableAlwaysOnTop( X11SalFrame* pFrame, bool bEnable ) const;
     294             : 
     295             :     /*
     296             :      *  tells whether enableAlwaysOnTop actually works with this WM
     297             :      */
     298           0 :     bool isAlwaysOnTopOK() const { return m_bEnableAlwaysOnTopWorks; }
     299             : 
     300             :     /*
     301             :      *  handle WM messages (especially WM state changes)
     302             :      */
     303             :     virtual int handlePropertyNotify( X11SalFrame* pFrame, XPropertyEvent* pEvent ) const;
     304             : 
     305             :     /*
     306             :      * called by SalFrame::Show: time to update state properties
     307             :      */
     308             :     virtual void frameIsMapping( X11SalFrame* ) const;
     309             : 
     310             :     /*
     311             :      *  gets a WM atom
     312             :      */
     313           0 :     Atom getAtom( WMAtom eAtom ) const
     314           0 :     { return m_aWMAtoms[ eAtom ]; }
     315             : 
     316           0 :     int getPositionWinGravity () const
     317           0 :     { return m_nWinGravity; }
     318           0 :     int getInitWinGravity() const
     319           0 :     { return m_nInitWinGravity; }
     320             : 
     321             :     /*
     322             :      *  expected behaviour is that the WM will not allow transient
     323             :      *  windows to get stacked behind the windows they are transient for
     324             :      */
     325           0 :     bool isTransientBehaviourAsExpected() const
     326           0 :     { return m_bTransientBehaviour; }
     327             : 
     328             :     /*
     329             :      *  changes the transient hint of a window to reference frame
     330             :      *  if reference frame is NULL the root window is used instead
     331             :      */
     332             :     void changeReferenceFrame( X11SalFrame* pFrame, X11SalFrame* pReferenceFrame ) const;
     333             : };
     334             : 
     335             : } // namespace
     336             : 
     337             : #endif
     338             : 
     339             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10