LibreOffice Module vcl (master)  1
gtkdata.hxx
Go to the documentation of this file.
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 #define GLIB_DISABLE_DEPRECATION_WARNINGS
24 #include <gdk/gdk.h>
25 #include <gdk/gdkx.h>
26 #include <gtk/gtk.h>
27 
28 #include <com/sun/star/accessibility/XAccessibleContext.hpp>
29 #include <com/sun/star/accessibility/XAccessibleEventListener.hpp>
30 #include <unx/gendata.hxx>
31 #include <unx/saldisp.hxx>
32 #include <unx/gtk/gtksys.hxx>
33 #include <vcl/ptrstyle.hxx>
34 #include <osl/conditn.hxx>
35 #include <saltimer.hxx>
36 #include <o3tl/enumarray.hxx>
37 
38 #include <vector>
39 
40 namespace com::sun::star::accessibility { class XAccessibleEventListener; }
41 
42 class GtkSalDisplay;
44 
45 inline ::Window widget_get_xid(GtkWidget *widget)
46 {
47  return GDK_WINDOW_XID(gtk_widget_get_window(widget));
48 }
49 
50 class GtkSalTimer final : public SalTimer
51 {
52  struct SalGtkTimeoutSource *m_pTimeout;
53 public:
54  GtkSalTimer();
55  virtual ~GtkSalTimer() override;
56  virtual void Start( sal_uInt64 nMS ) override;
57  virtual void Stop() override;
58  bool Expired();
59 
61 };
62 
64  public ::cppu::WeakImplHelper< css::accessibility::XAccessibleEventListener >
65 {
66 
68 
69 public:
72  void attachRecursive(
73  const css::uno::Reference< css::accessibility::XAccessible >& xAccessible
74  );
75 
78  void attachRecursive(
79  const css::uno::Reference< css::accessibility::XAccessible >& xAccessible,
80  const css::uno::Reference< css::accessibility::XAccessibleContext >& xContext
81  );
82 
85  void attachRecursive(
86  const css::uno::Reference< css::accessibility::XAccessible >& xAccessible,
87  const css::uno::Reference< css::accessibility::XAccessibleContext >& xContext,
88  const css::uno::Reference< css::accessibility::XAccessibleStateSet >& xStateSet
89  );
90 
93  void detachRecursive(
94  const css::uno::Reference< css::accessibility::XAccessible >& xAccessible
95  );
96 
99  void detachRecursive(
100  const css::uno::Reference< css::accessibility::XAccessibleContext >& xContext
101  );
102 
105  void detachRecursive(
106  const css::uno::Reference< css::accessibility::XAccessibleContext >& xContext,
107  const css::uno::Reference< css::accessibility::XAccessibleStateSet >& xStateSet
108  );
109 
112  static css::uno::Reference< css::accessibility::XAccessible > getAccessible(const css::lang::EventObject& aEvent );
113 
114  // XEventListener
115  virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
116 
117  // XAccessibleEventListener
118  virtual void SAL_CALL notifyEvent( const css::accessibility::AccessibleEventObject& aEvent ) override;
119 };
120 
121 class GtkSalData final : public GenericUnixSalData
122 {
123  GSource* m_pUserEvent;
124  osl::Mutex m_aDispatchMutex;
125  osl::Condition m_aDispatchCondition;
126  std::exception_ptr m_aException;
127 
129 
130 public:
131  GtkSalData( SalInstance *pInstance );
132  virtual ~GtkSalData() override;
133 
135 
136  void Init();
137  virtual void Dispose() override;
138 
139  static void initNWF();
140  static void deInitNWF();
141 
144 
145  bool Yield( bool bWait, bool bHandleAllCurrentEvents );
146  inline GdkDisplay *GetGdkDisplay();
147 
148  virtual void ErrorTrapPush() override;
149  virtual bool ErrorTrapPop( bool bIgnoreError = true ) override;
150 
151  inline GtkSalDisplay *GetGtkDisplay() const;
152  void setException(const std::exception_ptr& exception) { m_aException = exception; }
153 };
154 
155 class GtkSalFrame;
156 
158 {
160  GdkDisplay* m_pGdkDisplay;
164 
165  GdkCursor* getFromSvg( OUString const & name, int nXHot, int nYHot );
166 
167 public:
168  GtkSalDisplay( GdkDisplay* pDisplay );
169  virtual ~GtkSalDisplay() override;
170 
171  GdkDisplay* GetGdkDisplay() const { return m_pGdkDisplay; }
172  bool IsX11Display() const { return m_bX11Display; }
173 
174  GtkSalSystem* getSystem() const { return m_pSys; }
175 
176  GtkWidget* findGtkWidgetForNativeHandle(sal_uIntPtr hWindow) const;
177 
178  virtual void deregisterFrame( SalFrame* pFrame ) override;
179  GdkCursor *getCursor( PointerStyle ePointerStyle );
180  virtual int CaptureMouse( SalFrame* pFrame );
181 
183  Size GetScreenSize( int nDisplayScreen );
184 
185  GdkFilterReturn filterGdkEvent( GdkXEvent* sys_event );
186  void startupNotificationCompleted() { m_bStartupCompleted = true; }
187 
188  void screenSizeChanged( GdkScreen const * );
189  void monitorsChanged( GdkScreen const * );
190 
191  virtual void TriggerUserEventProcessing() override;
192  virtual void TriggerAllUserEventsProcessed() override;
193 };
194 
196 {
197  return static_cast<GtkSalData*>(ImplGetSVData()->mpSalData);
198 }
199 inline GdkDisplay *GtkSalData::GetGdkDisplay()
200 {
201  return GetGtkDisplay()->GetGdkDisplay();
202 }
203 
205 {
206  return static_cast<GtkSalDisplay *>(GetDisplay());
207 }
208 
209 #endif // INCLUDED_VCL_INC_UNX_GTK_GTKDATA_HXX
210 
211 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void deregisterFrame(SalFrame *pFrame) override
static void initNWF()
osl::Condition m_aDispatchCondition
Definition: gtkdata.hxx:125
void TriggerUserEventProcessing()
SalX11Screen GetDisplayDefaultXScreen()
Definition: gtksys.hxx:34
SalData * mpSalData
Definition: svdata.hxx:382
o3tl::sorted_vector< css::uno::Reference< css::uno::XInterface > > m_aRefList
Definition: gtkdata.hxx:67
void screenSizeChanged(GdkScreen const *)
virtual ~GtkSalTimer() override
void TriggerAllUserEventsProcessed()
sal_uIntPtr sal_uLong
virtual ~GtkSalData() override
bool m_bStartupCompleted
Definition: gtkdata.hxx:162
GtkSalDisplay * GetGtkDisplay() const
Definition: gtkdata.hxx:204
SalX11Screen GetDefaultXScreen()
Definition: gtkdata.hxx:182
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
SalGenericDisplay * GetDisplay() const
Definition: gendata.hxx:60
virtual ~GtkSalDisplay() override
void startupNotificationCompleted()
Definition: gtkdata.hxx:186
static void deInitNWF()
void attachRecursive(const css::uno::Reference< css::accessibility::XAccessible > &xAccessible)
virtual void TriggerAllUserEventsProcessed() override
virtual void Stop() override
GdkDisplay * m_pGdkDisplay
Definition: gtkdata.hxx:160
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:74
GSource * m_pUserEvent
Definition: gtkdata.hxx:123
GtkSalData(SalInstance *pInstance)
GdkCursor * getFromSvg(OUString const &name, int nXHot, int nYHot)
inline::Window widget_get_xid(GtkWidget *widget)
Definition: gtkdata.hxx:45
GtkWidget * findGtkWidgetForNativeHandle(sal_uIntPtr hWindow) const
bool m_bX11Display
Definition: gtkdata.hxx:163
o3tl::enumarray< PointerStyle, GdkCursor * > m_aCursors
Definition: gtkdata.hxx:161
virtual void ErrorTrapPush() override
sal_uLong m_nTimeoutMS
Definition: gtkdata.hxx:60
GtkSalData * GetGtkSalData()
Definition: gtkdata.hxx:195
virtual void Start(sal_uInt64 nMS) override
GtkSalSystem * m_pSys
Definition: gtkdata.hxx:159
std::exception_ptr m_aException
Definition: gtkdata.hxx:126
void setException(const std::exception_ptr &exception)
Definition: gtkdata.hxx:152
void monitorsChanged(GdkScreen const *)
bool Expired()
GtkSalSystem * getSystem() const
Definition: gtkdata.hxx:174
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:112
bool IsX11Display() const
Definition: gtkdata.hxx:172
GdkDisplay * GetGdkDisplay()
Definition: gtkdata.hxx:199
static css::uno::Reference< css::accessibility::XAccessible > getAccessible(const css::lang::EventObject &aEvent)
DocumentFocusListener & GetDocumentFocusListener()
virtual void TriggerUserEventProcessing() override
virtual bool ErrorTrapPop(bool bIgnoreError=true) override
GdkCursor * getCursor(PointerStyle ePointerStyle)
GdkFilterReturn filterGdkEvent(GdkXEvent *sys_event)
PointerStyle
Definition: ptrstyle.hxx:25
rtl::Reference< DocumentFocusListener > m_xDocumentFocusListener
Definition: gtkdata.hxx:128
void Init()
virtual void Dispose() override
virtual int CaptureMouse(SalFrame *pFrame)
struct SalGtkTimeoutSource * m_pTimeout
Definition: gtkdata.hxx:52
GdkDisplay * GetGdkDisplay() const
Definition: gtkdata.hxx:171
bool Yield(bool bWait, bool bHandleAllCurrentEvents)
Size GetScreenSize(int nDisplayScreen)
osl::Mutex m_aDispatchMutex
Definition: gtkdata.hxx:124
GtkSalDisplay(GdkDisplay *pDisplay)
virtual void SAL_CALL notifyEvent(const css::accessibility::AccessibleEventObject &aEvent) override
void detachRecursive(const css::uno::Reference< css::accessibility::XAccessible > &xAccessible)