LCOV - code coverage report
Current view: top level - vcl/inc/unx/gtk - gtkdata.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 15 27 55.6 %
Date: 2015-06-13 12:38:46 Functions: 10 14 71.4 %
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 INCLUDED_VCL_INC_UNX_GTK_GTKDATA_HXX
      21             : #define INCLUDED_VCL_INC_UNX_GTK_GTKDATA_HXX
      22             : 
      23             : #include <prex.h>
      24             : #define GLIB_DISABLE_DEPRECATION_WARNINGS
      25             : #include <gdk/gdk.h>
      26             : #include <gdk/gdkx.h>
      27             : #include <gtk/gtk.h>
      28             : #include <postx.h>
      29             : 
      30             : #include <generic/gendata.hxx>
      31             : #include <unx/saldisp.hxx>
      32             : #include <unx/saldata.hxx>
      33             : #include <unx/gtk/gtksys.hxx>
      34             : #include <vcl/ptrstyle.hxx>
      35             : #include <osl/conditn.h>
      36             : #include "saltimer.hxx"
      37             : #include <o3tl/enumarray.hxx>
      38             : 
      39             : #include <list>
      40             : 
      41             : class GtkSalDisplay;
      42             : 
      43         256 : inline GdkWindow * widget_get_window(GtkWidget *widget)
      44             : {
      45             : #if GTK_CHECK_VERSION(3,0,0)
      46             :     return gtk_widget_get_window(widget);
      47             : #else
      48         256 :     return widget->window;
      49             : #endif
      50             : }
      51             : 
      52          74 : inline ::Window widget_get_xid(GtkWidget *widget)
      53             : {
      54             : #if GTK_CHECK_VERSION(3,0,0)
      55             :     return GDK_WINDOW_XID(gtk_widget_get_window(widget));
      56             : #else
      57          74 :     return GDK_WINDOW_XWINDOW(widget->window);
      58             : #endif
      59             : }
      60             : 
      61           0 : inline void widget_set_can_focus(GtkWidget *widget, gboolean can_focus)
      62             : {
      63             : #if GTK_CHECK_VERSION(3,0,0)
      64             :     return gtk_widget_set_can_focus(widget, can_focus);
      65             : #else
      66           0 :     if (can_focus)
      67           0 :         GTK_WIDGET_SET_FLAGS( widget, GTK_CAN_FOCUS );
      68             :     else
      69           0 :         GTK_WIDGET_UNSET_FLAGS( widget, GTK_CAN_FOCUS );
      70             : #endif
      71           0 : }
      72             : 
      73           0 : inline void widget_set_can_default(GtkWidget *widget, gboolean can_default)
      74             : {
      75             : #if GTK_CHECK_VERSION(3,0,0)
      76             :     return gtk_widget_set_can_default(widget, can_default);
      77             : #else
      78           0 :     if (can_default)
      79           0 :         GTK_WIDGET_SET_FLAGS( widget, GTK_CAN_DEFAULT );
      80             :     else
      81           0 :         GTK_WIDGET_UNSET_FLAGS( widget, GTK_CAN_DEFAULT );
      82             : #endif
      83           0 : }
      84             : 
      85             : class GtkSalTimer : public SalTimer
      86             : {
      87             :     struct SalGtkTimeoutSource *m_pTimeout;
      88             : public:
      89             :     GtkSalTimer();
      90             :     virtual ~GtkSalTimer();
      91             :     virtual void Start( sal_uLong nMS ) SAL_OVERRIDE;
      92             :     virtual void Stop() SAL_OVERRIDE;
      93             :     bool         Expired();
      94             : 
      95             :     sal_uLong    m_nTimeoutMS;
      96             : };
      97             : 
      98             : class GtkData : public SalGenericData
      99             : {
     100             :     GSource *m_pUserEvent;
     101             :     oslMutex m_aDispatchMutex;
     102             :     oslCondition m_aDispatchCondition;
     103             :     bool blockIdleTimeout;
     104             : 
     105             : public:
     106             :     GtkData( SalInstance *pInstance );
     107             :     virtual ~GtkData();
     108             : 
     109             :     void Init();
     110             :     virtual void Dispose() SAL_OVERRIDE;
     111             : 
     112             :     static void initNWF();
     113             :     static void deInitNWF();
     114             : 
     115             :     static gboolean userEventFn( gpointer data );
     116             : 
     117             :     void PostUserEvent();
     118             :     void Yield( bool bWait, bool bHandleAllCurrentEvents );
     119             :     inline GdkDisplay *GetGdkDisplay();
     120             : 
     121             :     virtual void ErrorTrapPush() SAL_OVERRIDE;
     122             :     virtual bool ErrorTrapPop( bool bIgnoreError ) SAL_OVERRIDE;
     123             : 
     124             :     inline GtkSalDisplay *GetGtkDisplay() const;
     125           0 :     bool BlockIdleTimeout() const { return blockIdleTimeout; }
     126             : };
     127             : 
     128             : class GtkSalFrame;
     129             : 
     130             : #if GTK_CHECK_VERSION(3,0,0)
     131             : class GtkSalDisplay : public SalGenericDisplay
     132             : #else
     133             : class GtkSalDisplay : public SalDisplay
     134             : #endif
     135             : {
     136             :     GtkSalSystem*                   m_pSys;
     137             :     GdkDisplay*                     m_pGdkDisplay;
     138             :     o3tl::enumarray<PointerStyle, GdkCursor*> m_aCursors;
     139             :     bool                            m_bStartupCompleted;
     140             :     bool                            m_bX11Display;
     141             : 
     142             :     GdkCursor* getFromXBM( const unsigned char *pBitmap, const unsigned char *pMask,
     143             :                            int nWidth, int nHeight, int nXHot, int nYHot );
     144             : public:
     145             :              GtkSalDisplay( GdkDisplay* pDisplay );
     146             :     virtual ~GtkSalDisplay();
     147             : 
     148           1 :     GdkDisplay* GetGdkDisplay() const { return m_pGdkDisplay; }
     149          58 :     bool        IsX11Display() const { return m_bX11Display; }
     150             : 
     151          25 :     GtkSalSystem* getSystem() const { return m_pSys; }
     152             : 
     153             :     virtual void deregisterFrame( SalFrame* pFrame ) SAL_OVERRIDE;
     154             :     GdkCursor *getCursor( PointerStyle ePointerStyle );
     155             : #if GTK_CHECK_VERSION(3,0,0)
     156             :     virtual int CaptureMouse( SalFrame* pFrame );
     157             : #else
     158             :     virtual int CaptureMouse( SalFrame* pFrame ) SAL_OVERRIDE;
     159             : #endif
     160             : 
     161             :     int          GetDefaultScreen() { return m_pSys->GetDisplayBuiltInScreen(); }
     162          16 :     SalX11Screen GetDefaultXScreen() { return m_pSys->GetDisplayDefaultXScreen(); }
     163             :     Size         GetScreenSize( int nDisplayScreen );
     164           3 :     int          GetXScreenCount() { return m_pSys->GetDisplayXScreenCount(); }
     165             : #if GTK_CHECK_VERSION(3,0,0)
     166             : //    int          GetScreenCount() { return m_pSys->GetDisplayScreenCount(); }
     167             : #else
     168             :     virtual ScreenData *initScreen( SalX11Screen nXScreen ) const SAL_OVERRIDE;
     169             : #endif
     170             : 
     171             :     GdkFilterReturn filterGdkEvent( GdkXEvent* sys_event,
     172             :                                     GdkEvent* event );
     173           0 :     void startupNotificationCompleted() { m_bStartupCompleted = true; }
     174             : 
     175             :     void screenSizeChanged( GdkScreen* );
     176             :     void monitorsChanged( GdkScreen* );
     177             : 
     178             :     virtual void PostUserEvent() SAL_OVERRIDE;
     179             : 
     180             : #if !GTK_CHECK_VERSION(3,0,0)
     181             :     virtual bool Dispatch( XEvent *pEvent ) SAL_OVERRIDE;
     182             : #endif
     183             : };
     184             : 
     185         396 : inline GtkData* GetGtkSalData()
     186             : {
     187         396 :     return static_cast<GtkData*>(ImplGetSVData()->mpSalData);
     188             : }
     189           1 : inline GdkDisplay *GtkData::GetGdkDisplay()
     190             : {
     191           1 :     return GetGtkDisplay()->GetGdkDisplay();
     192             : }
     193             : 
     194         341 : GtkSalDisplay *GtkData::GetGtkDisplay() const
     195             : {
     196         341 :     return static_cast<GtkSalDisplay *>(GetDisplay());
     197             : }
     198             : 
     199             : #endif // INCLUDED_VCL_INC_UNX_GTK_GTKDATA_HXX
     200             : 
     201             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11