Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / vcl / inc / unx / gtk / gtkdata.hxx
blob8e8719a8a17413bcd64ae907a6ec0ccd8fa17da4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
23 #define GLIB_DISABLE_DEPRECATION_WARNINGS
24 #include <gdk/gdk.h>
25 #include <gdk/gdkx.h>
26 #include <gtk/gtk.h>
28 #include <unx/gendata.hxx>
29 #include <unx/saldisp.hxx>
30 #include <unx/gtk/gtksys.hxx>
31 #include <vcl/ptrstyle.hxx>
32 #include <osl/conditn.hxx>
33 #include "saltimer.hxx"
34 #include <o3tl/enumarray.hxx>
36 #include <list>
38 class GtkSalDisplay;
40 inline GdkWindow * widget_get_window(GtkWidget *widget)
42 #if GTK_CHECK_VERSION(3,0,0)
43 return gtk_widget_get_window(widget);
44 #else
45 return widget->window;
46 #endif
49 inline ::Window widget_get_xid(GtkWidget *widget)
51 #if GTK_CHECK_VERSION(3,0,0)
52 return GDK_WINDOW_XID(gtk_widget_get_window(widget));
53 #else
54 return GDK_WINDOW_XWINDOW(widget->window);
55 #endif
58 inline void widget_set_can_focus(GtkWidget *widget, gboolean can_focus)
60 #if GTK_CHECK_VERSION(3,0,0)
61 return gtk_widget_set_can_focus(widget, can_focus);
62 #else
63 if (can_focus)
64 GTK_WIDGET_SET_FLAGS( widget, GTK_CAN_FOCUS );
65 else
66 GTK_WIDGET_UNSET_FLAGS( widget, GTK_CAN_FOCUS );
67 #endif
70 inline void widget_set_can_default(GtkWidget *widget, gboolean can_default)
72 #if GTK_CHECK_VERSION(3,0,0)
73 return gtk_widget_set_can_default(widget, can_default);
74 #else
75 if (can_default)
76 GTK_WIDGET_SET_FLAGS( widget, GTK_CAN_DEFAULT );
77 else
78 GTK_WIDGET_UNSET_FLAGS( widget, GTK_CAN_DEFAULT );
79 #endif
82 class GtkSalTimer : public SalTimer
84 struct SalGtkTimeoutSource *m_pTimeout;
85 public:
86 GtkSalTimer();
87 virtual ~GtkSalTimer() override;
88 virtual void Start( sal_uLong nMS ) override;
89 virtual void Stop() override;
90 bool Expired();
92 sal_uLong m_nTimeoutMS;
95 class GtkData : public SalGenericData
97 GSource* m_pUserEvent;
98 osl::Mutex m_aDispatchMutex;
99 osl::Condition m_aDispatchCondition;
100 css::uno::Any m_aException;
101 bool blockIdleTimeout;
103 public:
104 GtkData( SalInstance *pInstance );
105 virtual ~GtkData() override;
107 void Init();
108 virtual void Dispose() override;
110 static void initNWF();
111 static void deInitNWF();
113 static gboolean userEventFn( gpointer data );
115 void PostUserEvent();
116 SalYieldResult Yield( bool bWait, bool bHandleAllCurrentEvents );
117 inline GdkDisplay *GetGdkDisplay();
119 virtual void ErrorTrapPush() override;
120 virtual bool ErrorTrapPop( bool bIgnoreError = true ) override;
122 inline GtkSalDisplay *GetGtkDisplay() const;
123 bool BlockIdleTimeout() const { return blockIdleTimeout; }
124 void setException(const css::uno::Any& rException) { m_aException = rException; }
127 class GtkSalFrame;
129 #if GTK_CHECK_VERSION(3,0,0)
130 class GtkSalDisplay : public SalGenericDisplay
131 #else
132 class GtkSalDisplay : public SalDisplay
133 #endif
135 GtkSalSystem* m_pSys;
136 GdkDisplay* m_pGdkDisplay;
137 o3tl::enumarray<PointerStyle, GdkCursor*> m_aCursors;
138 bool m_bStartupCompleted;
139 bool m_bX11Display;
141 GdkCursor* getFromXBM( const unsigned char *pBitmap, const unsigned char *pMask,
142 int nWidth, int nHeight, int nXHot, int nYHot );
143 public:
144 GtkSalDisplay( GdkDisplay* pDisplay );
145 virtual ~GtkSalDisplay() override;
147 GdkDisplay* GetGdkDisplay() const { return m_pGdkDisplay; }
148 bool IsX11Display() const { return m_bX11Display; }
150 GtkSalSystem* getSystem() const { return m_pSys; }
152 virtual void deregisterFrame( SalFrame* pFrame ) override;
153 GdkCursor *getCursor( PointerStyle ePointerStyle );
154 #if GTK_CHECK_VERSION(3,0,0)
155 virtual int CaptureMouse( SalFrame* pFrame );
156 #else
157 virtual int CaptureMouse( SalFrame* pFrame ) override;
158 #endif
160 SalX11Screen GetDefaultXScreen() { return m_pSys->GetDisplayDefaultXScreen(); }
161 Size GetScreenSize( int nDisplayScreen );
162 int GetXScreenCount() { return m_pSys->GetDisplayXScreenCount(); }
163 #if GTK_CHECK_VERSION(3,0,0)
164 // int GetScreenCount() { return m_pSys->GetDisplayScreenCount(); }
165 #else
166 virtual ScreenData *initScreen( SalX11Screen nXScreen ) const override;
167 #endif
169 GdkFilterReturn filterGdkEvent( GdkXEvent* sys_event );
170 void startupNotificationCompleted() { m_bStartupCompleted = true; }
172 void screenSizeChanged( GdkScreen* );
173 void monitorsChanged( GdkScreen* );
175 virtual void PostUserEvent() override;
177 #if !GTK_CHECK_VERSION(3,0,0)
178 virtual bool Dispatch( XEvent *pEvent ) override;
179 #endif
180 #if GTK_CHECK_VERSION(3,0,0)
181 void RefreshMenusUnity();
182 #endif
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: */