LibreOffice Module vcl (master)  1
gtkframe.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_GTKFRAME_HXX
21 #define INCLUDED_VCL_INC_UNX_GTK_GTKFRAME_HXX
22 
23 #include <cairo.h>
24 #include <gdk/gdk.h>
25 #include <gtk/gtk.h>
26 #if !GTK_CHECK_VERSION(4,0,0)
27 #include <gtk/gtkx.h>
28 #endif
29 #include <gdk/gdkkeysyms.h>
30 
31 #include <salframe.hxx>
32 #include <vcl/idle.hxx>
33 #include <vcl/sysdata.hxx>
34 #include <unx/saltype.h>
36 
37 #include <tools/link.hxx>
38 
39 #include <com/sun/star/awt/XTopWindow.hpp>
40 #include <com/sun/star/datatransfer/DataFlavor.hpp>
41 #include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
42 #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp>
43 
44 #include <list>
45 #include <vector>
46 
47 #include <config_dbus.h>
48 #include <config_gio.h>
49 
50 #include <headless/svpgdi.hxx>
51 
52 #include "gtkdata.hxx"
53 
54 class GtkSalGraphics;
56 
57 typedef sal_uIntPtr GdkNativeWindow;
58 class GtkInstDropTarget;
59 class GtkInstDragSource;
60 class GtkDnDTransferable;
61 
62 class GtkSalMenu;
63 
64 struct VclToGtkHelper;
65 
66 class GtkSalFrame final : public SalFrame
67 {
68  struct IMHandler
69  {
70 
71 #if !GTK_CHECK_VERSION(4, 0, 0)
72  // Not all GTK Input Methods swallow key release
73  // events. Since they swallow the key press events and we
74  // are left with the key release events, we need to
75  // manually swallow those. To do this, we keep a list of
76  // the previous 10 key press events in each GtkSalFrame
77  // and when we get a key release that matches one of the
78  // key press events in our list, we swallow it.
80  {
81  GdkWindow *window;
82  gint8 send_event;
83  guint32 time;
84  guint state;
85  guint keyval;
87  guint8 group;
88 
89  PreviousKeyPress (GdkEventKey *event)
90  : window (nullptr),
91  send_event (0),
92  time (0),
93  state (0),
94  keyval (0),
95  hardware_keycode (0),
96  group (0)
97  {
98  if (event)
99  {
100  window = event->window;
101  send_event = event->send_event;
102  time = event->time;
103  state = event->state;
104  keyval = event->keyval;
105  hardware_keycode = event->hardware_keycode;
106  group = event->group;
107  }
108  }
109 
111  : window( rPrev.window ),
112  send_event( rPrev.send_event ),
113  time( rPrev.time ),
114  state( rPrev.state ),
115  keyval( rPrev.keyval ),
116  hardware_keycode( rPrev.hardware_keycode ),
117  group( rPrev.group )
118  {}
119 
120  bool operator== (GdkEventKey const *event) const
121  {
122  return (event != nullptr)
123  && (event->window == window)
124  && (event->send_event == send_event)
125  // ignore non-Gdk state bits, e.g., these used by IBus
126  && ((event->state & GDK_MODIFIER_MASK) == (state & GDK_MODIFIER_MASK))
127  && (event->keyval == keyval)
128  && (event->hardware_keycode == hardware_keycode)
129  && (event->group == group)
130  && (event->time - time < 300)
131  ;
132  }
133  };
134 #endif
135 
137 #if !GTK_CHECK_VERSION(4, 0, 0)
138  std::list< PreviousKeyPress > m_aPrevKeyPresses;
139 #endif
140  int m_nPrevKeyPresses; // avoid using size()
141  GtkIMContext* m_pIMContext;
145  std::vector< ExtTextInputAttr > m_aInputFlags;
146 
148  ~IMHandler();
149 
150  void createIMContext();
151  void deleteIMContext();
152  void updateIMSpotLocation();
153  void endExtTextInput( EndExtTextInputFlags nFlags );
154 #if !GTK_CHECK_VERSION(4, 0, 0)
155  bool handleKeyEvent( GdkEventKey* pEvent );
156 #endif
157  void focusChanged( bool bFocusIn );
158 
159  void doCallEndExtTextInput();
160  void sendEmptyCommit();
161 
162  static void signalIMCommit( GtkIMContext*, gchar*, gpointer );
163  static gboolean signalIMDeleteSurrounding( GtkIMContext*, gint, gint, gpointer );
164  static void signalIMPreeditChanged( GtkIMContext*, gpointer );
165  static void signalIMPreeditEnd( GtkIMContext*, gpointer );
166  static void signalIMPreeditStart( GtkIMContext*, gpointer );
167  static gboolean signalIMRetrieveSurrounding( GtkIMContext*, gpointer );
168  };
169  friend struct IMHandler;
170 
172 
174  GtkWidget* m_pWindow;
175  GtkHeaderBar* m_pHeaderBar;
176  GtkGrid* m_pTopLevelGrid;
177 #if !GTK_CHECK_VERSION(4, 0, 0)
178  GtkEventBox* m_pEventBox;
179  GtkFixed* m_pFixedContainer;
180  GtkFixed* m_pDrawingArea;
181 #else
182  GtkOverlay* m_pOverlay;
183  GtkFixed* m_pFixedContainer;
184  GtkDrawingArea* m_pDrawingArea;
185  GtkEventControllerKey* m_pKeyController;
186  gulong m_nSettingChangedSignalId;
187 #endif
188 #if !GTK_CHECK_VERSION(4, 0, 0)
189  GdkWindow* m_pForeignParent;
191  GdkWindow* m_pForeignTopLevel;
193 #endif
196  std::list< GtkSalFrame* > m_aChildren;
199  std::unique_ptr<GtkSalGraphics> m_pGraphics;
210  OUString m_sWMClass;
211 
212  std::unique_ptr<IMHandler> m_pIMHandler;
213 
217 
218  OUString m_aTooltip;
225  cairo_region_t* m_pRegion;
230 
232 
233 #if ENABLE_DBUS && ENABLE_GIO
234  private:
235  friend void on_registrar_available (GDBusConnection*, const gchar*, const gchar*, gpointer);
236  friend void on_registrar_unavailable (GDBusConnection*, const gchar*, gpointer);
237 #endif
239 
240  void Init( SalFrame* pParent, SalFrameStyleFlags nStyle );
241  void Init( SystemParentData* pSysData );
242  void InitCommon();
243  void InvalidateGraphics();
244 
245  // signals
246 #if !GTK_CHECK_VERSION(4, 0, 0)
247  static gboolean signalButton( GtkWidget*, GdkEventButton*, gpointer );
248  static void signalStyleUpdated(GtkWidget*, gpointer);
249 #else
250  static void signalStyleUpdated(GtkWidget*, const gchar* pSetting, pointer);
251 #endif
252  void DrawingAreaResized(GtkWidget* pWidget, int nWidth, int nHeight);
253  void DrawingAreaDraw(cairo_t *cr);
254 #if !GTK_CHECK_VERSION(4, 0, 0)
255  static gboolean signalDraw( GtkWidget*, cairo_t *cr, gpointer );
256  static void sizeAllocated(GtkWidget*, GdkRectangle *pAllocation, gpointer frame);
257 #else
258  static void signalDraw(GtkDrawingArea*, cairo_t *cr, int width, int height, gpointer);
259  static void sizeAllocated(GtkWidget*, int nWidth, int nHeight, gpointer frame);
260 #endif
261  static void signalRealize(GtkWidget*, gpointer frame);
262  static gboolean signalTooltipQuery(GtkWidget*, gint x, gint y,
263  gboolean keyboard_mode, GtkTooltip *tooltip,
264  gpointer frame);
265 #if GTK_CHECK_VERSION(4, 0, 0)
266  static GdkDragAction signalDragMotion(GtkDropTargetAsync *dest, GdkDrop *drop, double x, double y, gpointer frame);
267  static void signalDragLeave(GtkDropTargetAsync *dest, GdkDrop *drop, gpointer frame);
268  static gboolean signalDragDrop(GtkDropTargetAsync* context, GdkDrop* drop, double x, double y, gpointer frame);
269 
270  static void signalDragFailed(GdkDrag* drag, GdkDragCancelReason reason, gpointer frame);
271  static void signalDragDelete(GdkDrag* drag, gpointer frame);
272  static void signalDragEnd(GdkDrag* drag, gpointer frame);
273 #else
274  static gboolean signalDragMotion(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
275  guint time, gpointer frame);
276  static gboolean signalDragDrop(GtkWidget* widget, GdkDragContext *context, gint x, gint y,
277  guint time, gpointer frame);
278  static void signalDragDropReceived(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
279  GtkSelectionData *data, guint ttype, guint time, gpointer frame);
280  static void signalDragLeave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer frame);
281 
282  static gboolean signalDragFailed(GtkWidget *widget, GdkDragContext *context, GtkDragResult result, gpointer frame);
283  static void signalDragDelete(GtkWidget *widget, GdkDragContext *context, gpointer frame);
284  static void signalDragEnd(GtkWidget *widget, GdkDragContext *context, gpointer frame);
285  static void signalDragDataGet(GtkWidget* widget, GdkDragContext* context, GtkSelectionData *data, guint info,
286  guint time, gpointer frame);
287 
288 #endif
289  static void gestureSwipe(GtkGestureSwipe* gesture, gdouble velocity_x, gdouble velocity_y, gpointer frame);
290  static void gestureLongPress(GtkGestureLongPress* gesture, gdouble x, gdouble y, gpointer frame);
291  bool DrawingAreaButton(SalEvent nEventType, int nEventX, int nEventY, int nButton, guint32 nTime, guint nState);
292 #if GTK_CHECK_VERSION(4, 0, 0)
293  static void gesturePressed(GtkGestureClick* gesture, int n_press, gdouble x, gdouble y, gpointer frame);
294  static void gestureReleased(GtkGestureClick* gesture, int n_press, gdouble x, gdouble y, gpointer frame);
295  void gestureButton(GtkGestureClick* gesture, SalEvent nEventType, gdouble x, gdouble y);
296 #endif
297  void DrawingAreaFocusInOut(SalEvent nEventType);
298 #if GTK_CHECK_VERSION(4, 0, 0)
299  static void signalFocusEnter(GtkEventControllerFocus* pController, gpointer frame);
300  static void signalFocusLeave(GtkEventControllerFocus* pController, gpointer frame);
301 #else
302  static gboolean signalFocus( GtkWidget*, GdkEventFocus*, gpointer );
303 #endif
304 #if !GTK_CHECK_VERSION(4, 0, 0)
305  static void signalSetFocus(GtkWindow* pWindow, GtkWidget* pWidget, gpointer frame);
306 #else
307  static void signalSetFocus(GtkWindow* pWindow, GParamSpec* pSpec, gpointer frame);
308 #endif
309  void WindowMap();
310  void WindowUnmap();
311  bool WindowCloseRequest();
312  void DrawingAreaMotion(int nEventX, int nEventY, guint32 nTime, guint nState);
313  void DrawingAreaCrossing(SalEvent nEventType, int nEventX, int nEventY, guint32 nTime, guint nState);
314  void DrawingAreaScroll(double delta_x, double delta_y, int nEventX, int nEventY, guint32 nTime, guint nState);
315 #if GTK_CHECK_VERSION(4, 0, 0)
316  bool DrawingAreaKey(GtkEventControllerKey* pController, SalEvent nEventType, guint keyval, guint keycode, guint nState);
317 
318  static void signalMap(GtkWidget*, gpointer);
319  static void signalUnmap(GtkWidget*, gpointer);
320 
321  static gboolean signalDelete(GtkWidget*, gpointer);
322 
323  static void signalMotion(GtkEventControllerMotion *controller, double x, double y, gpointer);
324 
325  static gboolean signalScroll(GtkEventControllerScroll* pController, double delta_x, double delta_y, gpointer);
326 
327  static void signalEnter(GtkEventControllerMotion *controller, double x, double y, gpointer);
328  static void signalLeave(GtkEventControllerMotion *controller, gpointer);
329 
330  static gboolean signalKeyPressed(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer);
331  static gboolean signalKeyReleased(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer);
332 
333  static void signalWindowState(GdkToplevel*, GParamSpec*, gpointer);
334 #else
335  static gboolean signalMap( GtkWidget*, GdkEvent*, gpointer );
336  static gboolean signalUnmap( GtkWidget*, GdkEvent*, gpointer );
337 
338  static gboolean signalDelete( GtkWidget*, GdkEvent*, gpointer );
339 
340  static gboolean signalMotion( GtkWidget*, GdkEventMotion*, gpointer );
341 
342  static gboolean signalScroll( GtkWidget*, GdkEvent*, gpointer );
343 
344  static gboolean signalCrossing( GtkWidget*, GdkEventCrossing*, gpointer );
345 
346  static gboolean signalKey( GtkWidget*, GdkEventKey*, gpointer );
347 
348  static gboolean signalWindowState( GtkWidget*, GdkEvent*, gpointer );
349 #endif
350 #if !GTK_CHECK_VERSION(4, 0, 0)
351  static gboolean signalConfigure( GtkWidget*, GdkEventConfigure*, gpointer );
352 #endif
353  static void signalDestroy( GtkWidget*, gpointer );
354 
355  void Center();
356  void SetDefaultSize();
357 
358  bool doKeyCallback( guint state,
359  guint keyval,
360  guint16 hardware_keycode,
361  guint8 group,
362  sal_Unicode aOrigCode,
363  bool bDown,
364  bool bSendRelease
365  );
366 
367 #if !GTK_CHECK_VERSION(4, 0, 0)
369 #endif
370 
371  static int m_nFloats;
372 
373  bool isFloatGrabWindow() const
374  {
375  return
376  (m_nStyle & SalFrameStyleFlags::FLOAT) && // only a float can be floatgrab
377  !(m_nStyle & SalFrameStyleFlags::TOOLTIP) && // tool tips are not
378  !(m_nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION); // toolbars are also not
379  }
380 
381  bool isChild( bool bPlug = true, bool bSysChild = true )
382  {
384  if( bPlug )
385  nMask |= SalFrameStyleFlags::PLUG;
386  if( bSysChild )
388  return bool(m_nStyle & nMask);
389  }
390 
391  //call gtk_window_resize
392  void window_resize(tools::Long nWidth, tools::Long nHeight);
393  //call gtk_widget_set_size_request
394  void widget_set_size_request(tools::Long nWidth, tools::Long nHeight);
395 
396  void resizeWindow( tools::Long nWidth, tools::Long nHeight );
397  void moveWindow( tools::Long nX, tools::Long nY );
398 
400 
401  void setMinMaxSize();
402 
403  void AllocateFrame();
404  void TriggerPaintEvent();
405 
406  void updateWMClass();
407 
409 
410  void SetScreen( unsigned int nNewScreen, SetType eType, tools::Rectangle const *pSize = nullptr );
411 
412  void SetIcon(const char* pIcon);
413 
414 public:
418  std::vector<GdkEvent*> m_aPendingScrollEvents;
419 #if !GTK_CHECK_VERSION(4, 0, 0)
421 #endif
424  GtkSalFrame( SalFrame* pParent, SalFrameStyleFlags nStyle );
425  GtkSalFrame( SystemParentData* pSysData );
426 
430  std::vector<gulong> m_aMouseSignalIds;
431 
432  void grabPointer(bool bGrab, bool bKeyboardAlso, bool bOwnerEvents);
433 
434  static GtkSalDisplay* getDisplay();
435  static GdkDisplay* getGdkDisplay();
436  GtkWidget* getWindow() const { return m_pWindow; }
437  GtkFixed* getFixedContainer() const { return GTK_FIXED(m_pFixedContainer); }
438  GtkWidget* getMouseEventWidget() const;
439  GtkGrid* getTopLevelGridWidget() const { return m_pTopLevelGrid; }
440  const SalX11Screen& getXScreenNumber() const { return m_nXScreen; }
442  void updateScreenNumber();
443 
444  cairo_t* getCairoContext() const;
445  void damaged(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop,
446  sal_Int32 nExtentsRight, sal_Int32 nExtentsBottom) const;
447 
449  {
450  assert(!m_pDropTarget);
451  m_pDropTarget = pDropTarget;
452  }
453 
454  void deregisterDropTarget(GtkInstDropTarget const * pDropTarget)
455  {
456  assert(m_pDropTarget == pDropTarget); (void)pDropTarget;
457  m_pDropTarget = nullptr;
458  }
459 
461  {
462  assert(!m_pDragSource);
463  m_pDragSource = pDragSource;
464  }
465 
466  void deregisterDragSource(GtkInstDragSource const * pDragSource)
467  {
468  assert(m_pDragSource == pDragSource); (void)pDragSource;
469  m_pDragSource = nullptr;
470  }
471 
472  void startDrag(const css::datatransfer::dnd::DragGestureEvent& rEvent,
473  const css::uno::Reference<css::datatransfer::XTransferable>& rTrans,
474  VclToGtkHelper& rConversionHelper,
475  GdkDragAction sourceActions);
476 
477  void closePopup();
478 
479  void addGrabLevel();
480  void removeGrabLevel();
481 
482 #if !GTK_CHECK_VERSION(4, 0, 0)
483  void nopaint_container_resize_children(GtkContainer*);
484 
485  void LaunchAsyncScroll(GdkEvent const * pEvent);
486  DECL_LINK(AsyncScroll, Timer *, void);
487 #endif
488 
489  virtual ~GtkSalFrame() override;
490 
491  // SalGraphics or NULL, but two Graphics for all SalFrames
492  // must be returned
493  virtual SalGraphics* AcquireGraphics() override;
494  virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
495 
496  // Event must be destroyed, when Frame is destroyed
497  // When Event is called, SalInstance::Yield() must be returned
498  virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
499 
500  virtual void SetTitle( const OUString& rTitle ) override;
501  virtual void SetIcon( sal_uInt16 nIcon ) override;
502  virtual void SetMenu( SalMenu *pSalMenu ) override;
503  SalMenu* GetMenu();
504  virtual void DrawMenuBar() override;
505  void EnsureAppMenuWatch();
506 
507  virtual void SetExtendedFrameStyle( SalExtStyle nExtStyle ) override;
508  // Before the window is visible, a resize event
509  // must be sent with the correct size
510  virtual void Show( bool bVisible, bool bNoActivate = false ) override;
511  // Set ClientSize and Center the Window to the desktop
512  // and send/post a resize message
513  virtual void SetMinClientSize( tools::Long nWidth, tools::Long nHeight ) override;
514  virtual void SetMaxClientSize( tools::Long nWidth, tools::Long nHeight ) override;
515  virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags ) override;
516  virtual void GetClientSize( tools::Long& rWidth, tools::Long& rHeight ) override;
517  virtual void GetWorkArea( tools::Rectangle& rRect ) override;
518  virtual SalFrame* GetParent() const override;
519  virtual void SetWindowState( const SalFrameState* pState ) override;
520  virtual bool GetWindowState( SalFrameState* pState ) override;
521  virtual void ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ) override;
522  // Enable/Disable ScreenSaver, SystemAgents, ...
523  virtual void StartPresentation( bool bStart ) override;
524  // Show Window over all other Windows
525  virtual void SetAlwaysOnTop( bool bOnTop ) override;
526 
527  // Window to top and grab focus
528  virtual void ToTop( SalFrameToTop nFlags ) override;
529 
530  // this function can call with the same
531  // pointer style
532  virtual void SetPointer( PointerStyle ePointerStyle ) override;
533  virtual void CaptureMouse( bool bMouse ) override;
534  virtual void GrabFocus() override;
535  virtual void SetPointerPos( tools::Long nX, tools::Long nY ) override;
536 
537  // flush output buffer
538  using SalFrame::Flush;
539  virtual void Flush() override;
540  // flush output buffer, wait till outstanding operations are done
541 
542  virtual void SetInputContext( SalInputContext* pContext ) override;
543  virtual void EndExtTextInput( EndExtTextInputFlags nFlags ) override;
544 
545  virtual OUString GetKeyName( sal_uInt16 nKeyCode ) override;
546  virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) override;
547 
548  // returns the input language used for the last key stroke
549  // may be LANGUAGE_DONTKNOW if not supported by the OS
550  virtual LanguageType GetInputLanguage() override;
551 
552  virtual void UpdateSettings( AllSettings& rSettings ) override;
553 
554  virtual void Beep() override;
555 
556  // returns system data (most prominent: window handle)
557  virtual const SystemEnvData* GetSystemData() const override;
558 
559  virtual void ResolveWindowHandle(SystemEnvData& rData) const override;
560 
561  // get current modifier and button mask
562  virtual SalPointerState GetPointerState() override;
563 
564  virtual KeyIndicatorState GetIndicatorState() override;
565 
566  virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) override;
567 
568  // set new parent window
569  virtual void SetParent( SalFrame* pNewParent ) override;
570  // reparent window to act as a plugin; implementation
571  // may choose to use a new system window internally
572  // return false to indicate failure
573  virtual void SetPluginParent( SystemParentData* pNewParent ) override;
574 
575  virtual void SetScreenNumber( unsigned int ) override;
576  virtual void SetApplicationID( const OUString &rWMClass ) override;
577 
578  // shaped system windows
579  // set clip region to none (-> rectangular windows, normal state)
580  virtual void ResetClipRegion() override;
581  // start setting the clipregion consisting of nRects rectangles
582  virtual void BeginSetClipRegion( sal_uInt32 nRects ) override;
583  // add a rectangle to the clip region
584  virtual void UnionClipRegion( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override;
585  // done setting up the clipregion
586  virtual void EndSetClipRegion() override;
587 
588  virtual void PositionByToolkit(const tools::Rectangle& rRect, FloatWinPopupFlags nFlags) override;
589  virtual void SetModal(bool bModal) override;
590  virtual bool GetModal() const override;
591  void HideTooltip();
592  void BlockTooltip();
593  void UnblockTooltip();
594  virtual bool ShowTooltip(const OUString& rHelpText, const tools::Rectangle& rHelpArea) override;
595  virtual void* ShowPopover(const OUString& rHelpText, vcl::Window* pParent, const tools::Rectangle& rHelpArea, QuickHelpFlags nFlags) override;
596  virtual bool UpdatePopover(void* nId, const OUString& rHelpText, vcl::Window* pParent, const tools::Rectangle& rHelpArea) override;
597  virtual bool HidePopover(void* nId) override;
598  virtual weld::Window* GetFrameWeld() const override;
599 
600  static GtkSalFrame *getFromWindow( GtkWidget *pWindow );
601 
602  static sal_uIntPtr GetNativeWindowHandle(GtkWidget *pWidget);
603 
604  //Call the usual SalFrame Callback, but catch uno exceptions and delegate
605  //to GtkSalData to rethrow them after the gsignal is processed when its safe
606  //to do so again in our own code after the g_main_context_iteration call
607  //which triggers the gsignals.
608  bool CallCallbackExc(SalEvent nEvent, const void* pEvent) const;
609 
610  // call gtk_widget_queue_draw on the drawing widget
611  void queue_draw();
612 
613  static void KeyCodeToGdkKey(const vcl::KeyCode& rKeyCode,
614  guint* pGdkKeyCode, GdkModifierType *pGdkModifiers);
615 
616  static guint32 GetLastInputEventTime();
617  static void UpdateLastInputEventTime(guint32 nUserInputTime);
618  static sal_uInt16 GetMouseModCode(guint nState);
619  static sal_uInt16 GetKeyCode(guint nKeyVal);
620 #if !GTK_CHECK_VERSION(4, 0, 0)
621  static guint GetKeyValFor(GdkKeymap* pKeyMap, guint16 hardware_keycode, guint8 group);
622 #endif
623  static sal_uInt16 GetKeyModCode(guint nState);
624  static GdkEvent* makeFakeKeyPress(GtkWidget* pWidget);
625 #if !GTK_CHECK_VERSION(4, 0, 0)
626  static SalWheelMouseEvent GetWheelEvent(const GdkEventScroll& rEvent);
627  static gboolean NativeWidgetHelpPressed(GtkAccelGroup*, GObject*, guint,
628  GdkModifierType, gpointer pFrame);
629 #endif
630  static OUString GetPreeditDetails(GtkIMContext* pIMContext, std::vector<ExtTextInputAttr>& rInputFlags, sal_Int32& rCursorPos, sal_uInt8& rCursorFlags);
631  static Selection CalcDeleteSurroundingSelection(const OUString& rSurroundingText, sal_Int32 nCursorIndex, int nOffset, int nChars);
632 
634 
635  void DisallowCycleFocusOut();
636  bool IsCycleFocusOutDisallowed() const;
637  void AllowCycleFocusOut();
638 };
639 
640 #define OOO_TYPE_FIXED ooo_fixed_get_type()
641 
642 #if !GTK_CHECK_VERSION(4, 0, 0)
643 extern "C" {
644 
645 GType ooo_fixed_get_type();
646 AtkObject* ooo_fixed_get_accessible(GtkWidget *obj);
647 
648 } // extern "C"
649 #endif
650 
651 #if !GTK_CHECK_VERSION(3, 22, 0)
653 {
663 };
664 #endif
665 
666 #endif // INCLUDED_VCL_INC_UNX_GTK_GTKFRAME_HXX
667 
668 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Rectangle m_aRestorePosSize
Definition: gtkframe.hxx:216
GdkNativeWindow m_aForeignTopLevelWindow
Definition: gtkframe.hxx:192
virtual bool HidePopover(void *nId) override
GdkNativeWindow m_aForeignParentWindow
Definition: gtkframe.hxx:190
guint m_nActionGroupExportId
Definition: gtkframe.hxx:428
bool doKeyCallback(guint state, guint keyval, guint16 hardware_keycode, guint8 group, sal_Unicode aOrigCode, bool bDown, bool bSendRelease)
struct _GDBusConnection GDBusConnection
Definition: cpdmgr.hxx:30
void deregisterDropTarget(GtkInstDropTarget const *pDropTarget)
Definition: gtkframe.hxx:454
virtual void GetClientSize(tools::Long &rWidth, tools::Long &rHeight) override
void nopaint_container_resize_children(GtkContainer *)
virtual void Show(bool bVisible, bool bNoActivate=false) override
static void gestureLongPress(GtkGestureLongPress *gesture, gdouble x, gdouble y, gpointer frame)
void EnsureAppMenuWatch()
virtual void SetPluginParent(SystemParentData *pNewParent) override
static sal_uInt16 GetKeyCode(guint nKeyVal)
static void signalDragDataGet(GtkWidget *widget, GdkDragContext *context, GtkSelectionData *data, guint info, guint time, gpointer frame)
virtual bool MapUnicodeToKeyCode(sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode &rKeyCode) override
bool isFloatGrabWindow() const
Definition: gtkframe.hxx:373
static gboolean signalWindowState(GtkWidget *, GdkEvent *, gpointer)
void DrawingAreaDraw(cairo_t *cr)
cairo_t * getCairoContext() const
static gboolean NativeWidgetHelpPressed(GtkAccelGroup *, GObject *, guint, GdkModifierType, gpointer pFrame)
static void signalDragDropReceived(GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint ttype, guint time, gpointer frame)
virtual void Flush() override
void SetIcon(const char *pIcon)
static gboolean signalDelete(GtkWidget *, GdkEvent *, gpointer)
virtual void SetParent(SalFrame *pNewParent) override
SalMenu * GetMenu()
Size calcDefaultSize()
GtkFixed * m_pDrawingArea
Definition: gtkframe.hxx:180
long Long
GtkInstDragSource * m_pDragSource
Definition: gtkframe.hxx:227
GtkHeaderBar * m_pHeaderBar
Definition: gtkframe.hxx:175
std::vector< gulong > m_aMouseSignalIds
Definition: gtkframe.hxx:430
static void signalDestroy(GtkWidget *, gpointer)
virtual const SystemEnvData * GetSystemData() const override
tools::Long m_nWidthRequest
Definition: gtkframe.hxx:223
static sal_uInt16 GetKeyModCode(guint nState)
virtual void EndExtTextInput(EndExtTextInputFlags nFlags) override
OUString m_aTooltip
Definition: gtkframe.hxx:218
virtual void SimulateKeyPress(sal_uInt16 nKeyCode) override
static gboolean signalIMRetrieveSurrounding(GtkIMContext *, gpointer)
void setMinMaxSize()
ModKeyFlags
Definition: keycodes.hxx:163
std::unique_ptr< GtkSalGraphics > m_pGraphics
Definition: gtkframe.hxx:199
SalExtTextInputEvent m_aInputEvent
Definition: gtkframe.hxx:144
std::vector< GdkEvent * > m_aPendingScrollEvents
Definition: gtkframe.hxx:418
std::vector< ExtTextInputAttr > m_aInputFlags
Definition: gtkframe.hxx:145
void Center()
virtual bool GetModal() const override
IMHandler(GtkSalFrame *)
virtual void ShowFullScreen(bool bFullScreen, sal_Int32 nDisplay) override
virtual SalFrame * GetParent() const override
void removeGrabLevel()
const cairo_font_options_t * get_font_options()
FloatWinPopupFlags
Definition: vclenum.hxx:367
virtual void PositionByToolkit(const tools::Rectangle &rRect, FloatWinPopupFlags nFlags) override
static void gestureSwipe(GtkGestureSwipe *gesture, gdouble velocity_x, gdouble velocity_y, gpointer frame)
GtkEventBox * m_pEventBox
Definition: gtkframe.hxx:178
virtual KeyIndicatorState GetIndicatorState() override
void DrawingAreaMotion(int nEventX, int nEventY, guint32 nTime, guint nState)
gulong m_nSetFocusSignalId
Definition: gtkframe.hxx:204
void queue_draw()
GdkWindow * m_pForeignParent
Definition: gtkframe.hxx:189
void updateWMClass()
GtkFixed * m_pFixedContainer
Definition: gtkframe.hxx:179
GdkWindow * m_pForeignTopLevel
Definition: gtkframe.hxx:191
std::list< PreviousKeyPress > m_aPrevKeyPresses
Definition: gtkframe.hxx:138
static gboolean signalIMDeleteSurrounding(GtkIMContext *, gint, gint, gpointer)
static GtkSalFrame * getFromWindow(GtkWidget *pWindow)
bool DrawingAreaButton(SalEvent nEventType, int nEventX, int nEventY, int nButton, guint32 nTime, guint nState)
virtual void SetMenu(SalMenu *pSalMenu) override
GtkSalFrame * m_pParent
Definition: gtkframe.hxx:195
virtual void UnionClipRegion(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight) override
PointerStyle m_ePointerStyle
Definition: gtkframe.hxx:202
sal_uInt16 sal_Unicode
static OUString GetPreeditDetails(GtkIMContext *pIMContext, std::vector< ExtTextInputAttr > &rInputFlags, sal_Int32 &rCursorPos, sal_uInt8 &rCursorFlags)
virtual void * ShowPopover(const OUString &rHelpText, vcl::Window *pParent, const tools::Rectangle &rHelpArea, QuickHelpFlags nFlags) override
static void KeyCodeToGdkKey(const vcl::KeyCode &rKeyCode, guint *pGdkKeyCode, GdkModifierType *pGdkModifiers)
GdkToplevelState m_nState
Definition: gtkframe.hxx:197
void DisallowCycleFocusOut()
void DrawingAreaCrossing(SalEvent nEventType, int nEventX, int nEventY, guint32 nTime, guint nState)
guint m_nHudAwarenessId
Definition: gtkframe.hxx:429
OUString m_sWMClass
Definition: gtkframe.hxx:210
bool handleKeyEvent(GdkEventKey *pEvent)
GtkIMContext * m_pIMContext
Definition: gtkframe.hxx:141
GtkGrid * getTopLevelGridWidget() const
Definition: gtkframe.hxx:439
GtkSalFrame(SalFrame *pParent, SalFrameStyleFlags nStyle)
static gboolean signalMotion(GtkWidget *, GdkEventMotion *, gpointer)
static gboolean signalDragFailed(GtkWidget *widget, GdkDragContext *context, GtkDragResult result, gpointer frame)
virtual void ResolveWindowHandle(SystemEnvData &rData) const override
virtual void GetWorkArea(tools::Rectangle &rRect) override
void grabPointer(bool bGrab, bool bKeyboardAlso, bool bOwnerEvents)
virtual void EndSetClipRegion() override
sal_uInt64 SalExtStyle
Definition: salframe.hxx:97
ttype
void widget_set_size_request(tools::Long nWidth, tools::Long nHeight)
void window_resize(tools::Long nWidth, tools::Long nHeight)
DECL_LINK(AsyncScroll, Timer *, void)
static void signalSetFocus(GtkWindow *pWindow, GtkWidget *pWidget, gpointer frame)
static void UpdateLastInputEventTime(guint32 nUserInputTime)
virtual void SetScreenNumber(unsigned int) override
static GdkEvent * makeFakeKeyPress(GtkWidget *pWidget)
void damaged(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop, sal_Int32 nExtentsRight, sal_Int32 nExtentsBottom) const
PreviousKeyPress(const PreviousKeyPress &rPrev)
Definition: gtkframe.hxx:110
bool CallCallbackExc(SalEvent nEvent, const void *pEvent) const
bool operator==(GdkEventKey const *event) const
Definition: gtkframe.hxx:120
bool WindowCloseRequest()
GtkWidget * getWindow() const
Definition: gtkframe.hxx:436
virtual void ReleaseGraphics(SalGraphics *pGraphics) override
SalFrameToTop
Definition: salframe.hxx:43
virtual void SetApplicationID(const OUString &rWMClass) override
virtual void SetMaxClientSize(tools::Long nWidth, tools::Long nHeight) override
virtual void SetAlwaysOnTop(bool bOnTop) override
GType ooo_fixed_get_type()
void UnblockTooltip()
static void signalDragDelete(GtkWidget *widget, GdkDragContext *context, gpointer frame)
virtual bool PostEvent(std::unique_ptr< ImplSVEvent > pData) override
void updateScreenNumber()
virtual void SetPosSize(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags) override
Size m_aMaxSize
Definition: gtkframe.hxx:214
static guint GetKeyValFor(GdkKeymap *pKeyMap, guint16 hardware_keycode, guint8 group)
virtual void CaptureMouse(bool bMouse) override
virtual void SetPointer(PointerStyle ePointerStyle) override
virtual void SetMinClientSize(tools::Long nWidth, tools::Long nHeight) override
void HideTooltip()
GtkGrid * m_pTopLevelGrid
Definition: gtkframe.hxx:176
virtual SalPointerState GetPointerState() override
static SalWheelMouseEvent GetWheelEvent(const GdkEventScroll &rEvent)
static gboolean signalDragDrop(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer frame)
bool m_bGraphics
Definition: gtkframe.hxx:200
KeyIndicatorState
Definition: keycodes.hxx:184
QuickHelpFlags
Definition: help.hxx:32
sal_uIntPtr GdkNativeWindow
Definition: gtkframe.hxx:55
void Init(SalFrame *pParent, SalFrameStyleFlags nStyle)
virtual void SetTitle(const OUString &rTitle) override
GtkWidget * getMouseEventWidget() const
static guint32 GetLastInputEventTime()
static void signalIMPreeditEnd(GtkIMContext *, gpointer)
SalFrameGeometry maGeometry
absolute, unmirrored values
Definition: salframe.hxx:129
GdkWindowState GdkToplevelState
Definition: gtkdata.hxx:52
void AllowCycleFocusOut()
EndExtTextInputFlags
Definition: window.hxx:344
void closePopup()
void DrawingAreaResized(GtkWidget *pWidget, int nWidth, int nHeight)
FloatWinPopupFlags m_nFloatFlags
Definition: gtkframe.hxx:221
static void signalIMPreeditStart(GtkIMContext *, gpointer)
static void signalRealize(GtkWidget *, gpointer frame)
static sal_uInt16 GetMouseModCode(guint nState)
struct _cairo cairo_t
Definition: svpgdi.hxx:70
void endExtTextInput(EndExtTextInputFlags nFlags)
DamageHandler m_aDamageHandler
Definition: gtkframe.hxx:417
virtual OUString GetKeyName(sal_uInt16 nKeyCode) override
bool m_bSalObjectSetPosSize
Definition: gtkframe.hxx:423
virtual void Flush()=0
basegfx::B2IVector m_aFrameSize
Definition: gtkframe.hxx:416
static void signalDragLeave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer frame)
static gboolean signalDraw(GtkWidget *, cairo_t *cr, gpointer)
static gboolean signalButton(GtkWidget *, GdkEventButton *, gpointer)
void registerDropTarget(GtkInstDropTarget *pDropTarget)
Definition: gtkframe.hxx:448
GdkAnchorHints
Definition: gtkframe.hxx:652
GtkWidget * m_pWindow
Definition: gtkframe.hxx:174
SalEvent
Definition: salwtype.hxx:41
static void sizeAllocated(GtkWidget *, GdkRectangle *pAllocation, gpointer frame)
void SetScreen(unsigned int nNewScreen, SetType eType, tools::Rectangle const *pSize=nullptr)
virtual void SetPointerPos(tools::Long nX, tools::Long nY) override
void DrawingAreaScroll(double delta_x, double delta_y, int nEventX, int nEventY, guint32 nTime, guint nState)
cairo_surface_t * m_pSurface
Definition: gtkframe.hxx:415
virtual void StartPresentation(bool bStart) override
guint m_nWatcherId
Definition: gtkframe.hxx:238
static sal_uIntPtr GetNativeWindowHandle(GtkWidget *pWidget)
static gboolean signalDragMotion(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer frame)
static gboolean signalKey(GtkWidget *, GdkEventKey *, gpointer)
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:114
static GdkDisplay * getGdkDisplay()
struct _cairo_font_options cairo_font_options_t
Definition: salinst.hxx:72
static gboolean signalMap(GtkWidget *, GdkEvent *, gpointer)
bool m_bDefaultSize
Definition: gtkframe.hxx:208
void resizeWindow(tools::Long nWidth, tools::Long nHeight)
bool m_bDefaultPos
Definition: gtkframe.hxx:207
GtkSalFrame * m_pFrame
Definition: gtkframe.hxx:136
cairo_region_t * m_pRegion
Definition: gtkframe.hxx:225
virtual bool UpdatePopover(void *nId, const OUString &rHelpText, vcl::Window *pParent, const tools::Rectangle &rHelpArea) override
virtual void SetModal(bool bModal) override
void moveWindow(tools::Long nX, tools::Long nY)
static void signalIMPreeditChanged(GtkIMContext *, gpointer)
tools::Long m_nHeightRequest
Definition: gtkframe.hxx:224
unsigned char sal_uInt8
void InvalidateGraphics()
SalFrameStyleFlags
Definition: salframe.hxx:64
virtual void DrawMenuBar() override
void registerDragSource(GtkInstDragSource *pDragSource)
Definition: gtkframe.hxx:460
static gboolean signalCrossing(GtkWidget *, GdkEventCrossing *, gpointer)
ScreenSaverInhibitor m_ScreenSaverInhibitor
Definition: gtkframe.hxx:203
GtkFixed * getFixedContainer() const
Definition: gtkframe.hxx:437
GtkSalMenu * m_pSalMenu
Definition: gtkframe.hxx:231
ModKeyFlags m_nKeyModifiers
Definition: gtkframe.hxx:201
virtual bool ShowTooltip(const OUString &rHelpText, const tools::Rectangle &rHelpArea) override
static void signalDragEnd(GtkWidget *widget, GdkDragContext *context, gpointer frame)
static Selection CalcDeleteSurroundingSelection(const OUString &rSurroundingText, sal_Int32 nCursorIndex, int nOffset, int nChars)
void startDrag(const css::datatransfer::dnd::DragGestureEvent &rEvent, const css::uno::Reference< css::datatransfer::XTransferable > &rTrans, VclToGtkHelper &rConversionHelper, GdkDragAction sourceActions)
virtual void Beep() override
bool m_bSpanMonitorsWhenFullscreen
Definition: gtkframe.hxx:206
static void signalIMCommit(GtkIMContext *, gchar *, gpointer)
void DrawingAreaFocusInOut(SalEvent nEventType)
bool isChild(bool bPlug=true, bool bSysChild=true)
Definition: gtkframe.hxx:381
static GdkNativeWindow findTopLevelSystemWindow(GdkNativeWindow aWindow)
static gboolean signalUnmap(GtkWidget *, GdkEvent *, gpointer)
Idle m_aSmoothScrollIdle
Definition: gtkframe.hxx:420
bool m_bFloatPositioned
Definition: gtkframe.hxx:222
static void signalStyleUpdated(GtkWidget *, gpointer)
guint m_nMenuExportId
Definition: gtkframe.hxx:427
AtkObject * ooo_fixed_get_accessible(GtkWidget *obj)
virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle) override
PointerStyle
Definition: ptrstyle.hxx:25
virtual void GrabFocus() override
bool m_bIconSetWhileUnmapped
Definition: gtkframe.hxx:229
int GetDisplayScreen() const
Definition: gtkframe.hxx:441
void addGrabLevel()
void SetDefaultSize()
SystemEnvData m_aSystemData
Definition: gtkframe.hxx:198
static gboolean signalConfigure(GtkWidget *, GdkEventConfigure *, gpointer)
std::unique_ptr< IMHandler > m_pIMHandler
Definition: gtkframe.hxx:212
virtual void UpdateSettings(AllSettings &rSettings) override
virtual SalGraphics * AcquireGraphics() override
void TriggerPaintEvent()
virtual bool GetWindowState(SalFrameState *pState) override
void WindowUnmap()
static gboolean signalTooltipQuery(GtkWidget *, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, gpointer frame)
bool m_bTooltipBlocked
Definition: gtkframe.hxx:209
virtual void ToTop(SalFrameToTop nFlags) override
static gboolean signalScroll(GtkWidget *, GdkEvent *, gpointer)
std::list< GtkSalFrame * > m_aChildren
Definition: gtkframe.hxx:196
Definition: timer.hxx:26
virtual weld::Window * GetFrameWeld() const override
GtkInstDropTarget * m_pDropTarget
Definition: gtkframe.hxx:226
void BlockTooltip()
Size m_aMinSize
Definition: gtkframe.hxx:215
void AllocateFrame()
tools::Rectangle m_aHelpArea
Definition: gtkframe.hxx:219
SalX11Screen m_nXScreen
Definition: gtkframe.hxx:173
bool IsCycleFocusOutDisallowed() const
static gboolean signalFocus(GtkWidget *, GdkEventFocus *, gpointer)
static int m_nFloats
Definition: gtkframe.hxx:371
struct _cairo_surface cairo_surface_t
Definition: svpgdi.hxx:71
virtual void ResetClipRegion() override
const SalX11Screen & getXScreenNumber() const
Definition: gtkframe.hxx:440
virtual LanguageType GetInputLanguage() override
virtual void SetInputContext(SalInputContext *pContext) override
tools::Rectangle m_aFloatRect
Definition: gtkframe.hxx:220
virtual void BeginSetClipRegion(sal_uInt32 nRects) override
int m_nGrabLevel
Definition: gtkframe.hxx:422
virtual void SetWindowState(const SalFrameState *pState) override
void WindowMap()
void focusChanged(bool bFocusIn)
void InitCommon()
bool m_bFullscreen
Definition: gtkframe.hxx:205
unsigned int nDisplayScreenNumber
Definition: salgeom.hxx:38
An idle is a timer to be scheduled immediately.
Definition: idle.hxx:34
void deregisterDragSource(GtkInstDragSource const *pDragSource)
Definition: gtkframe.hxx:466
void LaunchAsyncScroll(GdkEvent const *pEvent)
static GtkSalDisplay * getDisplay()
bool m_bGeometryIsProvisional
Definition: gtkframe.hxx:228
virtual ~GtkSalFrame() override
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo
SalFrameStyleFlags m_nStyle
Definition: gtkframe.hxx:194