Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _VCL_GTKDATA_HXX
30 : : #define _VCL_GTKDATA_HXX
31 : :
32 : : #include <tools/prex.h>
33 : : #include <gdk/gdk.h>
34 : : #include <gdk/gdkx.h>
35 : : #include <gtk/gtk.h>
36 : : #include <tools/postx.h>
37 : :
38 : : #include <generic/gendata.hxx>
39 : : #include <unx/saldisp.hxx>
40 : : #include <unx/saldata.hxx>
41 : : #include <unx/gtk/gtksys.hxx>
42 : : #include <vcl/ptrstyle.hxx>
43 : : #include <osl/conditn.h>
44 : : #include "saltimer.hxx"
45 : :
46 : : #include <list>
47 : :
48 : : class GtkSalDisplay;
49 : :
50 : 0 : inline GdkWindow * widget_get_window(GtkWidget *widget)
51 : : {
52 : : #if GTK_CHECK_VERSION(3,0,0)
53 : : return gtk_widget_get_window(widget);
54 : : #else
55 : 0 : return widget->window;
56 : : #endif
57 : : }
58 : :
59 : 0 : inline XLIB_Window widget_get_xid(GtkWidget *widget)
60 : : {
61 : : #if GTK_CHECK_VERSION(3,0,0)
62 : : return GDK_WINDOW_XID(gtk_widget_get_window(widget));
63 : : #else
64 : 0 : return GDK_WINDOW_XWINDOW(widget->window);
65 : : #endif
66 : : }
67 : :
68 : 0 : inline void widget_set_can_focus(GtkWidget *widget, gboolean can_focus)
69 : : {
70 : : #if GTK_CHECK_VERSION(3,0,0)
71 : : return gtk_widget_set_can_focus(widget, can_focus);
72 : : #else
73 : 0 : if (can_focus)
74 : 0 : GTK_WIDGET_SET_FLAGS( widget, GTK_CAN_FOCUS );
75 : : else
76 : 0 : GTK_WIDGET_UNSET_FLAGS( widget, GTK_CAN_FOCUS );
77 : : #endif
78 : 0 : }
79 : :
80 : 0 : inline void widget_set_can_default(GtkWidget *widget, gboolean can_default)
81 : : {
82 : : #if GTK_CHECK_VERSION(3,0,0)
83 : : return gtk_widget_set_can_default(widget, can_default);
84 : : #else
85 : 0 : if (can_default)
86 : 0 : GTK_WIDGET_SET_FLAGS( widget, GTK_CAN_DEFAULT );
87 : : else
88 : 0 : GTK_WIDGET_UNSET_FLAGS( widget, GTK_CAN_DEFAULT );
89 : : #endif
90 : 0 : }
91 : :
92 : : class GtkSalTimer : public SalTimer
93 : : {
94 : : struct SalGtkTimeoutSource *m_pTimeout;
95 : : public:
96 : : GtkSalTimer();
97 : : ~GtkSalTimer();
98 : : virtual void Start( sal_uLong nMS );
99 : : virtual void Stop();
100 : : bool Expired();
101 : :
102 : : sal_uLong m_nTimeoutMS;
103 : : };
104 : :
105 : : class GtkData : public SalGenericData
106 : : {
107 : : GSource *m_pUserEvent;
108 : : oslMutex m_aDispatchMutex;
109 : : oslCondition m_aDispatchCondition;
110 : :
111 : : public:
112 : : GtkData( SalInstance *pInstance );
113 : : virtual ~GtkData();
114 : :
115 : : virtual void Init();
116 : : virtual void Dispose();
117 : :
118 : : virtual void initNWF();
119 : : virtual void deInitNWF();
120 : :
121 : : static gboolean userEventFn( gpointer data );
122 : :
123 : : virtual void PostUserEvent();
124 : : void Yield( bool bWait, bool bHandleAllCurrentEvents );
125 : : inline GdkDisplay *GetGdkDisplay();
126 : :
127 : : virtual void ErrorTrapPush();
128 : : virtual bool ErrorTrapPop( bool bIgnoreError );
129 : : };
130 : :
131 : : class GtkSalFrame;
132 : :
133 : : #if GTK_CHECK_VERSION(3,0,0)
134 : : class GtkSalDisplay : public SalGenericDisplay
135 : : #else
136 : : class GtkSalDisplay : public SalDisplay
137 : : #endif
138 : : {
139 : : GtkSalSystem* m_pSys;
140 : : GdkDisplay* m_pGdkDisplay;
141 : : GdkCursor *m_aCursors[ POINTER_COUNT ];
142 : : bool m_bStartupCompleted;
143 : : bool m_bX11Display;
144 : :
145 : : GdkCursor* getFromXBM( const unsigned char *pBitmap, const unsigned char *pMask,
146 : : int nWidth, int nHeight, int nXHot, int nYHot );
147 : : public:
148 : : GtkSalDisplay( GdkDisplay* pDisplay );
149 : : virtual ~GtkSalDisplay();
150 : :
151 : 0 : GdkDisplay* GetGdkDisplay() const { return m_pGdkDisplay; }
152 : 0 : bool IsX11Display() const { return m_bX11Display; }
153 : :
154 : 0 : GtkSalSystem* getSystem() const { return m_pSys; }
155 : :
156 : : virtual void deregisterFrame( SalFrame* pFrame );
157 : : GdkCursor *getCursor( PointerStyle ePointerStyle );
158 : : virtual int CaptureMouse( SalFrame* pFrame );
159 : :
160 : : int GetDefaultScreen() { return m_pSys->GetDisplayBuiltInScreen(); }
161 : 0 : SalX11Screen GetDefaultXScreen() { return m_pSys->GetDisplayDefaultXScreen(); }
162 : : Size GetScreenSize( int nDisplayScreen );
163 : 0 : int GetXScreenCount() { return m_pSys->GetDisplayXScreenCount(); }
164 : : #if GTK_CHECK_VERSION(3,0,0)
165 : : // int GetScreenCount() { return m_pSys->GetDisplayScreenCount(); }
166 : : #endif
167 : : #if !GTK_CHECK_VERSION(3,0,0)
168 : : virtual ScreenData *initScreen( SalX11Screen nXScreen ) const;
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();
179 : :
180 : : #if !GTK_CHECK_VERSION(3,0,0)
181 : : virtual long Dispatch( XEvent *pEvent );
182 : : #else
183 : : guint32 GetLastUserEventTime( bool /* b */ ) { return GDK_CURRENT_TIME; } // horrible hack
184 : : #endif
185 : : };
186 : :
187 : 0 : inline GtkData* GetGtkSalData()
188 : : {
189 : 0 : return (GtkData*)ImplGetSVData()->mpSalData;
190 : : }
191 : 0 : inline GdkDisplay *GtkData::GetGdkDisplay()
192 : : {
193 : 0 : return GetGtkDisplay()->GetGdkDisplay();
194 : : }
195 : : #if !GTK_CHECK_VERSION(3,0,0)
196 : : #endif
197 : :
198 : : #endif // _VCL_GTKDATA_HXX
199 : :
200 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|