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 <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>
35 
36 #include <vector>
37 
38 namespace com { namespace sun { namespace star { namespace accessibility { class XAccessibleEventListener; } } } }
39 
40 class GtkSalDisplay;
41 class DocumentFocusListener;
42 
43 inline GdkWindow * widget_get_window(GtkWidget *widget)
44 {
45  return gtk_widget_get_window(widget);
46 }
47 
48 inline ::Window widget_get_xid(GtkWidget *widget)
49 {
50  return GDK_WINDOW_XID(gtk_widget_get_window(widget));
51 }
52 
53 inline void widget_set_can_focus(GtkWidget *widget, gboolean can_focus)
54 {
55  return gtk_widget_set_can_focus(widget, can_focus);
56 }
57 
58 inline void widget_set_can_default(GtkWidget *widget, gboolean can_default)
59 {
60  return gtk_widget_set_can_default(widget, can_default);
61 }
62 
63 class GtkSalTimer final : public SalTimer
64 {
65  struct SalGtkTimeoutSource *m_pTimeout;
66 public:
67  GtkSalTimer();
68  virtual ~GtkSalTimer() override;
69  virtual void Start( sal_uInt64 nMS ) override;
70  virtual void Stop() override;
71  bool Expired();
72 
74 };
75 
77 {
78  GSource* m_pUserEvent;
79  osl::Mutex m_aDispatchMutex;
80  osl::Condition m_aDispatchCondition;
81  std::exception_ptr m_aException;
82 
83  css::uno::Reference<css::accessibility::XAccessibleEventListener> m_xDocumentFocusListener;
84  DocumentFocusListener * m_pDocumentFocusListener;
85 
86 public:
87  GtkSalData( SalInstance *pInstance );
88  virtual ~GtkSalData() override;
89 
90  DocumentFocusListener & GetDocumentFocusListener();
91 
92  void Init();
93  virtual void Dispose() override;
94 
95  static void initNWF();
96  static void deInitNWF();
97 
100 
101  bool Yield( bool bWait, bool bHandleAllCurrentEvents );
102  inline GdkDisplay *GetGdkDisplay();
103 
104  virtual void ErrorTrapPush() override;
105  virtual bool ErrorTrapPop( bool bIgnoreError = true ) override;
106 
107  inline GtkSalDisplay *GetGtkDisplay() const;
108  void setException(const std::exception_ptr& exception) { m_aException = exception; }
109 };
110 
111 class GtkSalFrame;
112 
114 {
116  GdkDisplay* const m_pGdkDisplay;
120 
121  GdkCursor* getFromSvg( OUString const & name, int nXHot, int nYHot );
122 
123 public:
124  GtkSalDisplay( GdkDisplay* pDisplay );
125  virtual ~GtkSalDisplay() override;
126 
127  GdkDisplay* GetGdkDisplay() const { return m_pGdkDisplay; }
128  bool IsX11Display() const { return m_bX11Display; }
129 
130  GtkSalSystem* getSystem() const { return m_pSys; }
131 
132  GtkWidget* findGtkWidgetForNativeHandle(sal_uIntPtr hWindow) const;
133 
134  virtual void deregisterFrame( SalFrame* pFrame ) override;
135  GdkCursor *getCursor( PointerStyle ePointerStyle );
136  virtual int CaptureMouse( SalFrame* pFrame );
137 
139  Size GetScreenSize( int nDisplayScreen );
140 
141  GdkFilterReturn filterGdkEvent( GdkXEvent* sys_event );
142  void startupNotificationCompleted() { m_bStartupCompleted = true; }
143 
144  void screenSizeChanged( GdkScreen const * );
145  void monitorsChanged( GdkScreen const * );
146 
147  virtual void TriggerUserEventProcessing() override;
148  virtual void TriggerAllUserEventsProcessed() override;
149 };
150 
152 {
153  return static_cast<GtkSalData*>(ImplGetSVData()->mpSalData);
154 }
155 inline GdkDisplay *GtkSalData::GetGdkDisplay()
156 {
157  return GetGtkDisplay()->GetGdkDisplay();
158 }
159 
161 {
162  return static_cast<GtkSalDisplay *>(GetDisplay());
163 }
164 
165 #endif // INCLUDED_VCL_INC_UNX_GTK_GTKDATA_HXX
166 
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void deregisterFrame(SalFrame *pFrame) override
static void initNWF()
osl::Condition m_aDispatchCondition
Definition: gtkdata.hxx:80
void TriggerUserEventProcessing()
SalX11Screen GetDisplayDefaultXScreen()
Definition: gtksys.hxx:36
SalData * mpSalData
Definition: svdata.hxx:335
void screenSizeChanged(GdkScreen const *)
virtual ~GtkSalTimer() override
void TriggerAllUserEventsProcessed()
css::uno::Reference< css::accessibility::XAccessibleEventListener > m_xDocumentFocusListener
Definition: gtkdata.hxx:83
sal_uIntPtr sal_uLong
virtual ~GtkSalData() override
bool m_bStartupCompleted
Definition: gtkdata.hxx:118
GtkSalDisplay * GetGtkDisplay() const
Definition: gtkdata.hxx:160
SalX11Screen GetDefaultXScreen()
Definition: gtkdata.hxx:138
SalGenericDisplay * GetDisplay() const
Definition: gendata.hxx:60
virtual ~GtkSalDisplay() override
void startupNotificationCompleted()
Definition: gtkdata.hxx:142
static void deInitNWF()
void widget_set_can_focus(GtkWidget *widget, gboolean can_focus)
Definition: gtkdata.hxx:53
GdkWindow * widget_get_window(GtkWidget *widget)
Definition: gtkdata.hxx:43
DocumentFocusListener * m_pDocumentFocusListener
Definition: gtkdata.hxx:84
virtual void TriggerAllUserEventsProcessed() override
virtual void Stop() override
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:67
GSource * m_pUserEvent
Definition: gtkdata.hxx:78
GtkSalData(SalInstance *pInstance)
GdkCursor * getFromSvg(OUString const &name, int nXHot, int nYHot)
GdkDisplay *const m_pGdkDisplay
Definition: gtkdata.hxx:116
inline::Window widget_get_xid(GtkWidget *widget)
Definition: gtkdata.hxx:48
GtkWidget * findGtkWidgetForNativeHandle(sal_uIntPtr hWindow) const
bool m_bX11Display
Definition: gtkdata.hxx:119
o3tl::enumarray< PointerStyle, GdkCursor * > m_aCursors
Definition: gtkdata.hxx:117
virtual void ErrorTrapPush() override
sal_uLong m_nTimeoutMS
Definition: gtkdata.hxx:73
GtkSalData * GetGtkSalData()
Definition: gtkdata.hxx:151
virtual void Start(sal_uInt64 nMS) override
GtkSalSystem * m_pSys
Definition: gtkdata.hxx:115
std::exception_ptr m_aException
Definition: gtkdata.hxx:81
void setException(const std::exception_ptr &exception)
Definition: gtkdata.hxx:108
void monitorsChanged(GdkScreen const *)
bool Expired()
GtkSalSystem * getSystem() const
Definition: gtkdata.hxx:130
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:112
bool IsX11Display() const
Definition: gtkdata.hxx:128
GdkDisplay * GetGdkDisplay()
Definition: gtkdata.hxx:155
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
void Init()
virtual void Dispose() override
virtual int CaptureMouse(SalFrame *pFrame)
struct SalGtkTimeoutSource * m_pTimeout
Definition: gtkdata.hxx:65
GdkDisplay * GetGdkDisplay() const
Definition: gtkdata.hxx:127
bool Yield(bool bWait, bool bHandleAllCurrentEvents)
Size GetScreenSize(int nDisplayScreen)
void widget_set_can_default(GtkWidget *widget, gboolean can_default)
Definition: gtkdata.hxx:58
osl::Mutex m_aDispatchMutex
Definition: gtkdata.hxx:79
GtkSalDisplay(GdkDisplay *pDisplay)