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