1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_INC_UNX_GTK_GTKDATA_HXX
21 #define INCLUDED_VCL_INC_UNX_GTK_GTKDATA_HXX
24 #define GLIB_DISABLE_DEPRECATION_WARNINGS
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>
43 inline GdkWindow
* widget_get_window(GtkWidget
*widget
)
45 #if GTK_CHECK_VERSION(3,0,0)
46 return gtk_widget_get_window(widget
);
48 return widget
->window
;
52 inline ::Window
widget_get_xid(GtkWidget
*widget
)
54 #if GTK_CHECK_VERSION(3,0,0)
55 return GDK_WINDOW_XID(gtk_widget_get_window(widget
));
57 return GDK_WINDOW_XWINDOW(widget
->window
);
61 inline void widget_set_can_focus(GtkWidget
*widget
, gboolean can_focus
)
63 #if GTK_CHECK_VERSION(3,0,0)
64 return gtk_widget_set_can_focus(widget
, can_focus
);
67 GTK_WIDGET_SET_FLAGS( widget
, GTK_CAN_FOCUS
);
69 GTK_WIDGET_UNSET_FLAGS( widget
, GTK_CAN_FOCUS
);
73 inline void widget_set_can_default(GtkWidget
*widget
, gboolean can_default
)
75 #if GTK_CHECK_VERSION(3,0,0)
76 return gtk_widget_set_can_default(widget
, can_default
);
79 GTK_WIDGET_SET_FLAGS( widget
, GTK_CAN_DEFAULT
);
81 GTK_WIDGET_UNSET_FLAGS( widget
, GTK_CAN_DEFAULT
);
85 class GtkSalTimer
: public SalTimer
87 struct SalGtkTimeoutSource
*m_pTimeout
;
90 virtual ~GtkSalTimer();
91 virtual void Start( sal_uLong nMS
) SAL_OVERRIDE
;
92 virtual void Stop() SAL_OVERRIDE
;
95 sal_uLong m_nTimeoutMS
;
98 class GtkData
: public SalGenericData
100 GSource
*m_pUserEvent
;
101 oslMutex m_aDispatchMutex
;
102 oslCondition m_aDispatchCondition
;
103 bool blockIdleTimeout
;
106 GtkData( SalInstance
*pInstance
);
110 virtual void Dispose() SAL_OVERRIDE
;
112 static void initNWF();
113 static void deInitNWF();
115 static gboolean
userEventFn( gpointer data
);
117 void PostUserEvent();
118 void Yield( bool bWait
, bool bHandleAllCurrentEvents
);
119 inline GdkDisplay
*GetGdkDisplay();
121 virtual void ErrorTrapPush() SAL_OVERRIDE
;
122 virtual bool ErrorTrapPop( bool bIgnoreError
) SAL_OVERRIDE
;
124 inline GtkSalDisplay
*GetGtkDisplay() const;
125 bool BlockIdleTimeout() const { return blockIdleTimeout
; }
130 #if GTK_CHECK_VERSION(3,0,0)
131 class GtkSalDisplay
: public SalGenericDisplay
133 class GtkSalDisplay
: public SalDisplay
136 GtkSalSystem
* m_pSys
;
137 GdkDisplay
* m_pGdkDisplay
;
138 o3tl::enumarray
<PointerStyle
, GdkCursor
*> m_aCursors
;
139 bool m_bStartupCompleted
;
142 GdkCursor
* getFromXBM( const unsigned char *pBitmap
, const unsigned char *pMask
,
143 int nWidth
, int nHeight
, int nXHot
, int nYHot
);
145 GtkSalDisplay( GdkDisplay
* pDisplay
);
146 virtual ~GtkSalDisplay();
148 GdkDisplay
* GetGdkDisplay() const { return m_pGdkDisplay
; }
149 bool IsX11Display() const { return m_bX11Display
; }
151 GtkSalSystem
* getSystem() const { return m_pSys
; }
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
);
158 virtual int CaptureMouse( SalFrame
* pFrame
) SAL_OVERRIDE
;
161 int GetDefaultScreen() { return m_pSys
->GetDisplayBuiltInScreen(); }
162 SalX11Screen
GetDefaultXScreen() { return m_pSys
->GetDisplayDefaultXScreen(); }
163 Size
GetScreenSize( int nDisplayScreen
);
164 int GetXScreenCount() { return m_pSys
->GetDisplayXScreenCount(); }
165 #if GTK_CHECK_VERSION(3,0,0)
166 // int GetScreenCount() { return m_pSys->GetDisplayScreenCount(); }
168 virtual ScreenData
*initScreen( SalX11Screen nXScreen
) const SAL_OVERRIDE
;
171 GdkFilterReturn
filterGdkEvent( GdkXEvent
* sys_event
,
173 void startupNotificationCompleted() { m_bStartupCompleted
= true; }
175 void screenSizeChanged( GdkScreen
* );
176 void monitorsChanged( GdkScreen
* );
178 virtual void PostUserEvent() SAL_OVERRIDE
;
180 #if !GTK_CHECK_VERSION(3,0,0)
181 virtual bool Dispatch( XEvent
*pEvent
) SAL_OVERRIDE
;
185 inline GtkData
* GetGtkSalData()
187 return static_cast<GtkData
*>(ImplGetSVData()->mpSalData
);
189 inline GdkDisplay
*GtkData::GetGdkDisplay()
191 return GetGtkDisplay()->GetGdkDisplay();
194 GtkSalDisplay
*GtkData::GetGtkDisplay() const
196 return static_cast<GtkSalDisplay
*>(GetDisplay());
199 #endif // INCLUDED_VCL_INC_UNX_GTK_GTKDATA_HXX
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */