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;
209  OUString m_sWMClass;
210 
211  std::unique_ptr<IMHandler> m_pIMHandler;
212 
216 
217  OUString m_aTooltip;
224  cairo_region_t* m_pRegion;
229 
231 
232 #if ENABLE_DBUS && ENABLE_GIO
233  private:
234  friend void on_registrar_available (GDBusConnection*, const gchar*, const gchar*, gpointer);
235  friend void on_registrar_unavailable (GDBusConnection*, const gchar*, gpointer);
236 #endif
238 
239  void Init( SalFrame* pParent, SalFrameStyleFlags nStyle );
240  void Init( SystemParentData* pSysData );
241  void InitCommon();
242  void InvalidateGraphics();
243 
244  // signals
245 #if !GTK_CHECK_VERSION(4, 0, 0)
246  static gboolean signalButton( GtkWidget*, GdkEventButton*, gpointer );
247  static void signalStyleUpdated(GtkWidget*, gpointer);
248 #else
249  static void signalStyleUpdated(GtkWidget*, const gchar* pSetting, pointer);
250 #endif
251  void DrawingAreaResized(GtkWidget* pWidget, int nWidth, int nHeight);
252  void DrawingAreaDraw(cairo_t *cr);
253 #if !GTK_CHECK_VERSION(4, 0, 0)
254  static gboolean signalDraw( GtkWidget*, cairo_t *cr, gpointer );
255  static void sizeAllocated(GtkWidget*, GdkRectangle *pAllocation, gpointer frame);
256 #else
257  static void signalDraw(GtkDrawingArea*, cairo_t *cr, int width, int height, gpointer);
258  static void sizeAllocated(GtkWidget*, int nWidth, int nHeight, gpointer frame);
259 #endif
260  static void signalRealize(GtkWidget*, gpointer frame);
261  static gboolean signalTooltipQuery(GtkWidget*, gint x, gint y,
262  gboolean keyboard_mode, GtkTooltip *tooltip,
263  gpointer frame);
264 #if GTK_CHECK_VERSION(4, 0, 0)
265  static GdkDragAction signalDragMotion(GtkDropTargetAsync *dest, GdkDrop *drop, double x, double y, gpointer frame);
266  static void signalDragLeave(GtkDropTargetAsync *dest, GdkDrop *drop, gpointer frame);
267  static gboolean signalDragDrop(GtkDropTargetAsync* context, GdkDrop* drop, double x, double y, gpointer frame);
268 
269  static void signalDragFailed(GdkDrag* drag, GdkDragCancelReason reason, gpointer frame);
270  static void signalDragDelete(GdkDrag* drag, gpointer frame);
271  static void signalDragEnd(GdkDrag* drag, gpointer frame);
272 #else
273  static gboolean signalDragMotion(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
274  guint time, gpointer frame);
275  static gboolean signalDragDrop(GtkWidget* widget, GdkDragContext *context, gint x, gint y,
276  guint time, gpointer frame);
277  static void signalDragDropReceived(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
278  GtkSelectionData *data, guint ttype, guint time, gpointer frame);
279  static void signalDragLeave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer frame);
280 
281  static gboolean signalDragFailed(GtkWidget *widget, GdkDragContext *context, GtkDragResult result, gpointer frame);
282  static void signalDragDelete(GtkWidget *widget, GdkDragContext *context, gpointer frame);
283  static void signalDragEnd(GtkWidget *widget, GdkDragContext *context, gpointer frame);
284  static void signalDragDataGet(GtkWidget* widget, GdkDragContext* context, GtkSelectionData *data, guint info,
285  guint time, gpointer frame);
286 
287 #endif
288  static void gestureSwipe(GtkGestureSwipe* gesture, gdouble velocity_x, gdouble velocity_y, gpointer frame);
289  static void gestureLongPress(GtkGestureLongPress* gesture, gdouble x, gdouble y, gpointer frame);
290  bool DrawingAreaButton(SalEvent nEventType, int nEventX, int nEventY, int nButton, guint32 nTime, guint nState);
291 #if GTK_CHECK_VERSION(4, 0, 0)
292  static void gesturePressed(GtkGestureClick* gesture, int n_press, gdouble x, gdouble y, gpointer frame);
293  static void gestureReleased(GtkGestureClick* gesture, int n_press, gdouble x, gdouble y, gpointer frame);
294  void gestureButton(GtkGestureClick* gesture, SalEvent nEventType, gdouble x, gdouble y);
295 #endif
296  void DrawingAreaFocusInOut(SalEvent nEventType);
297 #if GTK_CHECK_VERSION(4, 0, 0)
298  static void signalFocusEnter(GtkEventControllerFocus* pController, gpointer frame);
299  static void signalFocusLeave(GtkEventControllerFocus* pController, gpointer frame);
300 #else
301  static gboolean signalFocus( GtkWidget*, GdkEventFocus*, gpointer );
302 #endif
303 #if !GTK_CHECK_VERSION(4, 0, 0)
304  static void signalSetFocus(GtkWindow* pWindow, GtkWidget* pWidget, gpointer frame);
305 #else
306  static void signalSetFocus(GtkWindow* pWindow, GParamSpec* pSpec, gpointer frame);
307 #endif
308  void WindowMap();
309  void WindowUnmap();
310  bool WindowCloseRequest();
311  void DrawingAreaMotion(int nEventX, int nEventY, guint32 nTime, guint nState);
312  void DrawingAreaCrossing(SalEvent nEventType, int nEventX, int nEventY, guint32 nTime, guint nState);
313  void DrawingAreaScroll(double delta_x, double delta_y, int nEventX, int nEventY, guint32 nTime, guint nState);
314 #if GTK_CHECK_VERSION(4, 0, 0)
315  bool DrawingAreaKey(GtkEventControllerKey* pController, SalEvent nEventType, guint keyval, guint keycode, guint nState);
316 
317  static void signalMap(GtkWidget*, gpointer);
318  static void signalUnmap(GtkWidget*, gpointer);
319 
320  static gboolean signalDelete(GtkWidget*, gpointer);
321 
322  static void signalMotion(GtkEventControllerMotion *controller, double x, double y, gpointer);
323 
324  static gboolean signalScroll(GtkEventControllerScroll* pController, double delta_x, double delta_y, gpointer);
325 
326  static void signalEnter(GtkEventControllerMotion *controller, double x, double y, gpointer);
327  static void signalLeave(GtkEventControllerMotion *controller, gpointer);
328 
329  static gboolean signalKeyPressed(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer);
330  static gboolean signalKeyReleased(GtkEventControllerKey *controller, guint keyval, guint keycode, GdkModifierType state, gpointer);
331 
332  static void signalWindowState(GdkToplevel*, GParamSpec*, gpointer);
333 #else
334  static gboolean signalMap( GtkWidget*, GdkEvent*, gpointer );
335  static gboolean signalUnmap( GtkWidget*, GdkEvent*, gpointer );
336 
337  static gboolean signalDelete( GtkWidget*, GdkEvent*, gpointer );
338 
339  static gboolean signalMotion( GtkWidget*, GdkEventMotion*, gpointer );
340 
341  static gboolean signalScroll( GtkWidget*, GdkEvent*, gpointer );
342 
343  static gboolean signalCrossing( GtkWidget*, GdkEventCrossing*, gpointer );
344 
345  static gboolean signalKey( GtkWidget*, GdkEventKey*, gpointer );
346 
347  static gboolean signalWindowState( GtkWidget*, GdkEvent*, gpointer );
348 #endif
349 #if !GTK_CHECK_VERSION(4, 0, 0)
350  static gboolean signalConfigure( GtkWidget*, GdkEventConfigure*, gpointer );
351 #endif
352  static void signalDestroy( GtkWidget*, gpointer );
353 
354  void Center();
355  void SetDefaultSize();
356 
357  bool doKeyCallback( guint state,
358  guint keyval,
359  guint16 hardware_keycode,
360  guint8 group,
361  sal_Unicode aOrigCode,
362  bool bDown,
363  bool bSendRelease
364  );
365 
366 #if !GTK_CHECK_VERSION(4, 0, 0)
368 #endif
369 
370  static int m_nFloats;
371 
372  bool isFloatGrabWindow() const
373  {
374  return
375  (m_nStyle & SalFrameStyleFlags::FLOAT) && // only a float can be floatgrab
376  !(m_nStyle & SalFrameStyleFlags::TOOLTIP) && // tool tips are not
377  !(m_nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION); // toolbars are also not
378  }
379 
380  bool isChild( bool bPlug = true, bool bSysChild = true )
381  {
383  if( bPlug )
384  nMask |= SalFrameStyleFlags::PLUG;
385  if( bSysChild )
387  return bool(m_nStyle & nMask);
388  }
389 
390  //call gtk_window_resize
391  void window_resize(tools::Long nWidth, tools::Long nHeight);
392  //call gtk_widget_set_size_request
393  void widget_set_size_request(tools::Long nWidth, tools::Long nHeight);
394 
395  void resizeWindow( tools::Long nWidth, tools::Long nHeight );
396  void moveWindow( tools::Long nX, tools::Long nY );
397 
399 
400  void setMinMaxSize();
401 
402  void AllocateFrame();
403  void TriggerPaintEvent();
404 
405  void updateWMClass();
406 
408 
409  void SetScreen( unsigned int nNewScreen, SetType eType, tools::Rectangle const *pSize = nullptr );
410 
411  void SetIcon(const char* pIcon);
412 
413  bool HandleMenubarMnemonic(guint eState, guint nKeyval);
414 
415 public:
419  std::vector<GdkEvent*> m_aPendingScrollEvents;
420 #if !GTK_CHECK_VERSION(4, 0, 0)
422 #endif
425  GtkSalFrame( SalFrame* pParent, SalFrameStyleFlags nStyle );
426  GtkSalFrame( SystemParentData* pSysData );
427 
431  std::vector<gulong> m_aMouseSignalIds;
432 
433  void grabPointer(bool bGrab, bool bKeyboardAlso, bool bOwnerEvents);
434 
435  static GtkSalDisplay* getDisplay();
436  static GdkDisplay* getGdkDisplay();
437  GtkWidget* getWindow() const { return m_pWindow; }
438  GtkFixed* getFixedContainer() const { return GTK_FIXED(m_pFixedContainer); }
439  GtkWidget* getMouseEventWidget() const;
440  GtkGrid* getTopLevelGridWidget() const { return m_pTopLevelGrid; }
441  const SalX11Screen& getXScreenNumber() const { return m_nXScreen; }
443  void updateScreenNumber();
444 
445  cairo_t* getCairoContext() const;
446  void damaged(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop,
447  sal_Int32 nExtentsRight, sal_Int32 nExtentsBottom) const;
448 
450  {
451  assert(!m_pDropTarget);
452  m_pDropTarget = pDropTarget;
453  }
454 
455  void deregisterDropTarget(GtkInstDropTarget const * pDropTarget)
456  {
457  assert(m_pDropTarget == pDropTarget); (void)pDropTarget;
458  m_pDropTarget = nullptr;
459  }
460 
462  {
463  assert(!m_pDragSource);
464  m_pDragSource = pDragSource;
465  }
466 
467  void deregisterDragSource(GtkInstDragSource const * pDragSource)
468  {
469  assert(m_pDragSource == pDragSource); (void)pDragSource;
470  m_pDragSource = nullptr;
471  }
472 
473  void startDrag(const css::datatransfer::dnd::DragGestureEvent& rEvent,
474  const css::uno::Reference<css::datatransfer::XTransferable>& rTrans,
475  VclToGtkHelper& rConversionHelper,
476  GdkDragAction sourceActions);
477 
478  void closePopup();
479 
480  void addGrabLevel();
481  void removeGrabLevel();
482 
483 #if !GTK_CHECK_VERSION(4, 0, 0)
484  void nopaint_container_resize_children(GtkContainer*);
485 
486  void LaunchAsyncScroll(GdkEvent const * pEvent);
487  DECL_LINK(AsyncScroll, Timer *, void);
488 #endif
489 
490  virtual ~GtkSalFrame() override;
491 
492  // SalGraphics or NULL, but two Graphics for all SalFrames
493  // must be returned
494  virtual SalGraphics* AcquireGraphics() override;
495  virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
496 
497  // Event must be destroyed, when Frame is destroyed
498  // When Event is called, SalInstance::Yield() must be returned
499  virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
500 
501  virtual void SetTitle( const OUString& rTitle ) override;
502  virtual void SetIcon( sal_uInt16 nIcon ) override;
503  virtual void SetMenu( SalMenu *pSalMenu ) override;
504  SalMenu* GetMenu();
505  virtual void DrawMenuBar() override;
506  void EnsureAppMenuWatch();
507 
508  virtual void SetExtendedFrameStyle( SalExtStyle nExtStyle ) override;
509  // Before the window is visible, a resize event
510  // must be sent with the correct size
511  virtual void Show( bool bVisible, bool bNoActivate = false ) override;
512  // Set ClientSize and Center the Window to the desktop
513  // and send/post a resize message
514  virtual void SetMinClientSize( tools::Long nWidth, tools::Long nHeight ) override;
515  virtual void SetMaxClientSize( tools::Long nWidth, tools::Long nHeight ) override;
516  virtual void SetPosSize( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags ) override;
517  virtual void GetClientSize( tools::Long& rWidth, tools::Long& rHeight ) override;
518  virtual void GetWorkArea( tools::Rectangle& rRect ) override;
519  virtual SalFrame* GetParent() const override;
520  virtual void SetWindowState( const SalFrameState* pState ) override;
521  virtual bool GetWindowState( SalFrameState* pState ) override;
522  virtual void ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ) override;
523  // Enable/Disable ScreenSaver, SystemAgents, ...
524  virtual void StartPresentation( bool bStart ) override;
525  // Show Window over all other Windows
526  virtual void SetAlwaysOnTop( bool bOnTop ) override;
527 
528  // Window to top and grab focus
529  virtual void ToTop( SalFrameToTop nFlags ) override;
530 
531  // this function can call with the same
532  // pointer style
533  virtual void SetPointer( PointerStyle ePointerStyle ) override;
534  virtual void CaptureMouse( bool bMouse ) override;
535  virtual void GrabFocus() override;
536  virtual void SetPointerPos( tools::Long nX, tools::Long nY ) override;
537 
538  // flush output buffer
539  using SalFrame::Flush;
540  virtual void Flush() override;
541  // flush output buffer, wait till outstanding operations are done
542 
543  virtual void SetInputContext( SalInputContext* pContext ) override;
544  virtual void EndExtTextInput( EndExtTextInputFlags nFlags ) override;
545 
546  virtual OUString GetKeyName( sal_uInt16 nKeyCode ) override;
547  virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) override;
548 
549  // returns the input language used for the last key stroke
550  // may be LANGUAGE_DONTKNOW if not supported by the OS
551  virtual LanguageType GetInputLanguage() override;
552 
553  virtual void UpdateSettings( AllSettings& rSettings ) override;
554 
555  virtual void Beep() override;
556 
557  // returns system data (most prominent: window handle)
558  virtual const SystemEnvData* GetSystemData() const override;
559 
560  virtual void ResolveWindowHandle(SystemEnvData& rData) const override;
561 
562  // get current modifier and button mask
563  virtual SalPointerState GetPointerState() override;
564 
565  virtual KeyIndicatorState GetIndicatorState() override;
566 
567  virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) override;
568 
569  // set new parent window
570  virtual void SetParent( SalFrame* pNewParent ) override;
571  // reparent window to act as a plugin; implementation
572  // may choose to use a new system window internally
573  // return false to indicate failure
574  virtual void SetPluginParent( SystemParentData* pNewParent ) override;
575 
576  virtual void SetScreenNumber( unsigned int ) override;
577  virtual void SetApplicationID( const OUString &rWMClass ) override;
578 
579  // shaped system windows
580  // set clip region to none (-> rectangular windows, normal state)
581  virtual void ResetClipRegion() override;
582  // start setting the clipregion consisting of nRects rectangles
583  virtual void BeginSetClipRegion( sal_uInt32 nRects ) override;
584  // add a rectangle to the clip region
585  virtual void UnionClipRegion( tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight ) override;
586  // done setting up the clipregion
587  virtual void EndSetClipRegion() override;
588 
589  virtual void PositionByToolkit(const tools::Rectangle& rRect, FloatWinPopupFlags nFlags) override;
590  virtual void SetModal(bool bModal) override;
591  virtual bool GetModal() const override;
592  void HideTooltip();
593  void BlockTooltip();
594  void UnblockTooltip();
595  virtual bool ShowTooltip(const OUString& rHelpText, const tools::Rectangle& rHelpArea) override;
596  virtual void* ShowPopover(const OUString& rHelpText, vcl::Window* pParent, const tools::Rectangle& rHelpArea, QuickHelpFlags nFlags) override;
597  virtual bool UpdatePopover(void* nId, const OUString& rHelpText, vcl::Window* pParent, const tools::Rectangle& rHelpArea) override;
598  virtual bool HidePopover(void* nId) override;
599  virtual weld::Window* GetFrameWeld() const override;
600 
601  static GtkSalFrame *getFromWindow( GtkWidget *pWindow );
602 
603  static sal_uIntPtr GetNativeWindowHandle(GtkWidget *pWidget);
604 
605  //Call the usual SalFrame Callback, but catch uno exceptions and delegate
606  //to GtkSalData to rethrow them after the gsignal is processed when its safe
607  //to do so again in our own code after the g_main_context_iteration call
608  //which triggers the gsignals.
609  bool CallCallbackExc(SalEvent nEvent, const void* pEvent) const;
610 
611  // call gtk_widget_queue_draw on the drawing widget
612  void queue_draw();
613 
614  static void KeyCodeToGdkKey(const vcl::KeyCode& rKeyCode,
615  guint* pGdkKeyCode, GdkModifierType *pGdkModifiers);
616 
617  static guint32 GetLastInputEventTime();
618  static void UpdateLastInputEventTime(guint32 nUserInputTime);
619  static sal_uInt16 GetMouseModCode(guint nState);
620  static sal_uInt16 GetKeyCode(guint nKeyVal);
621 #if !GTK_CHECK_VERSION(4, 0, 0)
622  static guint GetKeyValFor(GdkKeymap* pKeyMap, guint16 hardware_keycode, guint8 group);
623 #endif
624  static sal_uInt16 GetKeyModCode(guint nState);
625  static GdkEvent* makeFakeKeyPress(GtkWidget* pWidget);
626 #if !GTK_CHECK_VERSION(4, 0, 0)
627  static SalWheelMouseEvent GetWheelEvent(const GdkEventScroll& rEvent);
628  static gboolean NativeWidgetHelpPressed(GtkAccelGroup*, GObject*, guint,
629  GdkModifierType, gpointer pFrame);
630 #endif
631  static OUString GetPreeditDetails(GtkIMContext* pIMContext, std::vector<ExtTextInputAttr>& rInputFlags, sal_Int32& rCursorPos, sal_uInt8& rCursorFlags);
632  static Selection CalcDeleteSurroundingSelection(const OUString& rSurroundingText, sal_Int32 nCursorIndex, int nOffset, int nChars);
633 
635 
636  void DisallowCycleFocusOut();
637  bool IsCycleFocusOutDisallowed() const;
638  void AllowCycleFocusOut();
639 };
640 
641 #define OOO_TYPE_FIXED ooo_fixed_get_type()
642 
643 #if !GTK_CHECK_VERSION(4, 0, 0)
644 extern "C" {
645 
646 GType ooo_fixed_get_type();
647 AtkObject* ooo_fixed_get_accessible(GtkWidget *obj);
648 
649 } // extern "C"
650 #endif
651 
652 #if !GTK_CHECK_VERSION(3, 22, 0)
654 {
664 };
665 #endif
666 
667 #endif // INCLUDED_VCL_INC_UNX_GTK_GTKFRAME_HXX
668 
669 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
tools::Rectangle m_aRestorePosSize
Definition: gtkframe.hxx:215
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:429
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:455
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
struct _cairo cairo_t
Definition: CairoCommon.hxx:71
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:372
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:226
GtkHeaderBar * m_pHeaderBar
Definition: gtkframe.hxx:175
std::vector< gulong > m_aMouseSignalIds
Definition: gtkframe.hxx:431
static void signalDestroy(GtkWidget *, gpointer)
virtual const SystemEnvData * GetSystemData() const override
tools::Long m_nWidthRequest
Definition: gtkframe.hxx:222
static sal_uInt16 GetKeyModCode(guint nState)
virtual void EndExtTextInput(EndExtTextInputFlags nFlags) override
OUString m_aTooltip
Definition: gtkframe.hxx:217
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:419
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:430
OUString m_sWMClass
Definition: gtkframe.hxx:209
bool handleKeyEvent(GdkEventKey *pEvent)
GtkIMContext * m_pIMContext
Definition: gtkframe.hxx:141
GtkGrid * getTopLevelGridWidget() const
Definition: gtkframe.hxx:440
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 HandleMenubarMnemonic(guint eState, guint nKeyval)
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:437
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:213
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:220
static void signalIMPreeditStart(GtkIMContext *, gpointer)
static void signalRealize(GtkWidget *, gpointer frame)
static sal_uInt16 GetMouseModCode(guint nState)
void endExtTextInput(EndExtTextInputFlags nFlags)
DamageHandler m_aDamageHandler
Definition: gtkframe.hxx:418
virtual OUString GetKeyName(sal_uInt16 nKeyCode) override
bool m_bSalObjectSetPosSize
Definition: gtkframe.hxx:424
virtual void Flush()=0
basegfx::B2IVector m_aFrameSize
Definition: gtkframe.hxx:417
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:449
GdkAnchorHints
Definition: gtkframe.hxx:653
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:416
virtual void StartPresentation(bool bStart) override
guint m_nWatcherId
Definition: gtkframe.hxx:237
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:73
static gboolean signalMap(GtkWidget *, GdkEvent *, gpointer)
bool m_bDefaultSize
Definition: gtkframe.hxx:207
void resizeWindow(tools::Long nWidth, tools::Long nHeight)
bool m_bDefaultPos
Definition: gtkframe.hxx:206
GtkSalFrame * m_pFrame
Definition: gtkframe.hxx:136
cairo_region_t * m_pRegion
Definition: gtkframe.hxx:224
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:223
unsigned char sal_uInt8
void InvalidateGraphics()
SalFrameStyleFlags
Definition: salframe.hxx:64
virtual void DrawMenuBar() override
void registerDragSource(GtkInstDragSource *pDragSource)
Definition: gtkframe.hxx:461
static gboolean signalCrossing(GtkWidget *, GdkEventCrossing *, gpointer)
ScreenSaverInhibitor m_ScreenSaverInhibitor
Definition: gtkframe.hxx:203
GtkFixed * getFixedContainer() const
Definition: gtkframe.hxx:438
GtkSalMenu * m_pSalMenu
Definition: gtkframe.hxx:230
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
static void signalIMCommit(GtkIMContext *, gchar *, gpointer)
void DrawingAreaFocusInOut(SalEvent nEventType)
bool isChild(bool bPlug=true, bool bSysChild=true)
Definition: gtkframe.hxx:380
static GdkNativeWindow findTopLevelSystemWindow(GdkNativeWindow aWindow)
static gboolean signalUnmap(GtkWidget *, GdkEvent *, gpointer)
Idle m_aSmoothScrollIdle
Definition: gtkframe.hxx:421
bool m_bFloatPositioned
Definition: gtkframe.hxx:221
static void signalStyleUpdated(GtkWidget *, gpointer)
guint m_nMenuExportId
Definition: gtkframe.hxx:428
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:228
int GetDisplayScreen() const
Definition: gtkframe.hxx:442
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:211
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:208
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:225
void BlockTooltip()
Size m_aMinSize
Definition: gtkframe.hxx:214
void AllocateFrame()
tools::Rectangle m_aHelpArea
Definition: gtkframe.hxx:218
SalX11Screen m_nXScreen
Definition: gtkframe.hxx:173
bool IsCycleFocusOutDisallowed() const
static gboolean signalFocus(GtkWidget *, GdkEventFocus *, gpointer)
static int m_nFloats
Definition: gtkframe.hxx:370
virtual void ResetClipRegion() override
const SalX11Screen & getXScreenNumber() const
Definition: gtkframe.hxx:441
virtual LanguageType GetInputLanguage() override
virtual void SetInputContext(SalInputContext *pContext) override
tools::Rectangle m_aFloatRect
Definition: gtkframe.hxx:219
struct _cairo_surface cairo_surface_t
Definition: CairoCommon.hxx:72
virtual void BeginSetClipRegion(sal_uInt32 nRects) override
int m_nGrabLevel
Definition: gtkframe.hxx:423
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:467
void LaunchAsyncScroll(GdkEvent const *pEvent)
static GtkSalDisplay * getDisplay()
bool m_bGeometryIsProvisional
Definition: gtkframe.hxx:227
virtual ~GtkSalFrame() override
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo
SalFrameStyleFlags m_nStyle
Definition: gtkframe.hxx:194