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