diff options
Diffstat (limited to 'vcl/inc/unx/gtk')
-rw-r--r-- | vcl/inc/unx/gtk/atkbridge.hxx | 30 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gloactiongroup.h | 78 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/glomenu.h | 137 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkbackend.hxx | 25 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkdata.hxx | 152 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkframe.hxx | 567 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkgdi.hxx | 399 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkinst.hxx | 298 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkobject.hxx | 107 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkprintwrapper.hxx | 69 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkprn.hxx | 51 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtksalmenu.hxx | 151 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtksys.hxx | 48 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/hudawareness.h | 32 |
14 files changed, 2144 insertions, 0 deletions
diff --git a/vcl/inc/unx/gtk/atkbridge.hxx b/vcl/inc/unx/gtk/atkbridge.hxx new file mode 100644 index 000000000..49c422dac --- /dev/null +++ b/vcl/inc/unx/gtk/atkbridge.hxx @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_UNX_GTK_ATKBRIDGE_HXX +#define INCLUDED_VCL_INC_UNX_GTK_ATKBRIDGE_HXX + +#include <vclpluginapi.h> + +bool InitAtkBridge(); +void DeInitAtkBridge(); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/gtk/gloactiongroup.h b/vcl/inc/unx/gtk/gloactiongroup.h new file mode 100644 index 000000000..4028f76dc --- /dev/null +++ b/vcl/inc/unx/gtk/gloactiongroup.h @@ -0,0 +1,78 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_INC_UNX_GTK_GLOACTIONGROUP_H +#define INCLUDED_VCL_INC_UNX_GTK_GLOACTIONGROUP_H + +#include <glib-object.h> +#include <glib.h> + +G_BEGIN_DECLS + +#define G_TYPE_LO_ACTION_GROUP (g_lo_action_group_get_type ()) +#define G_LO_ACTION_GROUP(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_LO_ACTION_GROUP, GLOActionGroup)) +#define G_IS_LO_ACTION_GROUP(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_LO_ACTION_GROUP)) + +struct GLOActionGroupPrivate; + +struct GLOActionGroup +{ + /*< private >*/ + GObject parent_instance; + + GLOActionGroupPrivate *priv; +}; + +struct GLOActionGroupClass +{ + /*< private >*/ + GObjectClass parent_class; + + /*< private >*/ + gpointer padding[12]; +}; + +GType g_lo_action_group_get_type (void) G_GNUC_CONST; + +GLOActionGroup * g_lo_action_group_new (void); + +void g_lo_action_group_set_top_menu (GLOActionGroup *group, + gpointer top_menu); + +void g_lo_action_group_insert (GLOActionGroup *group, + const gchar *action_name, + gint item_id, + gboolean submenu); + +void g_lo_action_group_insert_stateful (GLOActionGroup *group, + const gchar *action_name, + gint item_id, + gboolean submenu, + const GVariantType *parameter_type, + const GVariantType *state_type, + GVariant *state_hint, + GVariant *state); + +void g_lo_action_group_set_action_enabled (GLOActionGroup *group, + const gchar *action_name, + gboolean enabled); + +void g_lo_action_group_remove (GLOActionGroup *group, + const gchar *action_name); + +void g_lo_action_group_clear (GLOActionGroup *group); + +G_END_DECLS + +#endif // INCLUDED_VCL_INC_UNX_GTK_GLOACTIONGROUP_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/gtk/glomenu.h b/vcl/inc/unx/gtk/glomenu.h new file mode 100644 index 000000000..a0150a845 --- /dev/null +++ b/vcl/inc/unx/gtk/glomenu.h @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_INC_UNX_GTK_GLOMENU_H +#define INCLUDED_VCL_INC_UNX_GTK_GLOMENU_H + +#include <gio/gio.h> + +#define G_LO_MENU_ATTRIBUTE_ACCELERATOR "accel" +#define G_LO_MENU_ATTRIBUTE_COMMAND "command" +#define G_LO_MENU_ATTRIBUTE_SUBMENU_ACTION "submenu-action" + +G_BEGIN_DECLS + +#define G_TYPE_LO_MENU (g_lo_menu_get_type ()) +#define G_LO_MENU(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \ + G_TYPE_LO_MENU, GLOMenu)) +#define G_IS_LO_MENU(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \ + G_TYPE_LO_MENU)) + +struct GLOMenu; + +class GtkSalMenuItem; + +GLIB_AVAILABLE_IN_2_32 +GType g_lo_menu_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_2_32 +GLOMenu * g_lo_menu_new (void); + +gint g_lo_menu_get_n_items_from_section (GLOMenu *menu, + gint section); + +void g_lo_menu_insert (GLOMenu *menu, + gint position, + const gchar *label); + +void g_lo_menu_insert_in_section (GLOMenu *menu, + gint section, + gint position, + const gchar *label); + +void g_lo_menu_new_section (GLOMenu *menu, + gint position, + const gchar *label); + +void g_lo_menu_insert_section (GLOMenu *menu, + gint position, + const gchar *label, + GMenuModel *section); + +GLOMenu * g_lo_menu_get_section (GLOMenu *menu, + gint section); + +void g_lo_menu_remove (GLOMenu *menu, + gint position); + +void g_lo_menu_remove_from_section (GLOMenu *menu, + gint section, + gint position); + +void g_lo_menu_set_label (GLOMenu *menu, + gint position, + const gchar *label); + +void g_lo_menu_set_icon (GLOMenu *menu, + gint position, + const GIcon *icon); + + +void g_lo_menu_set_label_to_item_in_section (GLOMenu *menu, + gint section, + gint position, + const gchar *label); + +void g_lo_menu_set_icon_to_item_in_section (GLOMenu *menu, + gint section, + gint position, + const GIcon *icon); + +gchar * g_lo_menu_get_label_from_item_in_section (GLOMenu *menu, + gint section, + gint position); + +void g_lo_menu_set_action_and_target_value (GLOMenu *menu, + gint position, + const gchar *command, + GVariant *target_value); + +void g_lo_menu_set_action_and_target_value_to_item_in_section (GLOMenu *menu, + gint section, + gint position, + const gchar *command, + GVariant *target_value); + +void g_lo_menu_set_command_to_item_in_section (GLOMenu *menu, + gint section, + gint position, + const gchar *command); + +gchar * g_lo_menu_get_command_from_item_in_section (GLOMenu *menu, + gint section, + gint position); + +void g_lo_menu_set_accelerator_to_item_in_section (GLOMenu *menu, + gint section, + gint position, + const gchar *accelerator); + +gchar * g_lo_menu_get_accelerator_from_item_in_section (GLOMenu *menu, + gint section, + gint position); + +void g_lo_menu_new_submenu_in_item_in_section (GLOMenu *menu, + gint section, + gint position); + +GLOMenu * g_lo_menu_get_submenu_from_item_in_section (GLOMenu *menu, + gint section, + gint position); + +void g_lo_menu_set_submenu_action_to_item_in_section (GLOMenu *menu, + gint section, + gint position, + const gchar *action); + +G_END_DECLS + +#endif // INCLUDED_VCL_INC_UNX_GTK_GLOMENU_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/gtk/gtkbackend.hxx b/vcl/inc/unx/gtk/gtkbackend.hxx new file mode 100644 index 000000000..288311b41 --- /dev/null +++ b/vcl/inc/unx/gtk/gtkbackend.hxx @@ -0,0 +1,25 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_INC_UNX_GTK_GTKBACKEND_HXX +#define INCLUDED_VCL_INC_UNX_GTK_GTKBACKEND_HXX + +#include <gtk/gtk.h> +#if defined(GDK_WINDOWING_X11) +#include <gdk/gdkx.h> +bool DLSYM_GDK_IS_X11_DISPLAY(GdkDisplay* pDisplay); +#endif +#if defined(GDK_WINDOWING_WAYLAND) +#include <gdk/gdkwayland.h> +bool DLSYM_GDK_IS_WAYLAND_DISPLAY(GdkDisplay* pDisplay); +#endif + +#endif // INCLUDED_VCL_INC_UNX_GTK_GTKBACKEND_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/gtk/gtkdata.hxx b/vcl/inc/unx/gtk/gtkdata.hxx new file mode 100644 index 000000000..2f88ffe8b --- /dev/null +++ b/vcl/inc/unx/gtk/gtkdata.hxx @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_UNX_GTK_GTKDATA_HXX +#define INCLUDED_VCL_INC_UNX_GTK_GTKDATA_HXX + +#define GLIB_DISABLE_DEPRECATION_WARNINGS +#include <gdk/gdk.h> +#include <gdk/gdkx.h> +#include <gtk/gtk.h> + +#include <unx/gendata.hxx> +#include <unx/saldisp.hxx> +#include <unx/gtk/gtksys.hxx> +#include <vcl/ptrstyle.hxx> +#include <osl/conditn.hxx> +#include <saltimer.hxx> +#include <o3tl/enumarray.hxx> + +#include <vector> + +namespace com::sun::star::accessibility { class XAccessibleEventListener; } + +class GtkSalDisplay; +class DocumentFocusListener; + +inline ::Window widget_get_xid(GtkWidget *widget) +{ + return GDK_WINDOW_XID(gtk_widget_get_window(widget)); +} + +class GtkSalTimer final : public SalTimer +{ + struct SalGtkTimeoutSource *m_pTimeout; +public: + GtkSalTimer(); + virtual ~GtkSalTimer() override; + virtual void Start( sal_uInt64 nMS ) override; + virtual void Stop() override; + bool Expired(); + + sal_uLong m_nTimeoutMS; +}; + +class GtkSalData final : public GenericUnixSalData +{ + GSource* m_pUserEvent; + osl::Mutex m_aDispatchMutex; + osl::Condition m_aDispatchCondition; + std::exception_ptr m_aException; + + css::uno::Reference<css::accessibility::XAccessibleEventListener> m_xDocumentFocusListener; + DocumentFocusListener * m_pDocumentFocusListener; + +public: + GtkSalData( SalInstance *pInstance ); + virtual ~GtkSalData() override; + + DocumentFocusListener & GetDocumentFocusListener(); + + void Init(); + virtual void Dispose() override; + + static void initNWF(); + static void deInitNWF(); + + void TriggerUserEventProcessing(); + void TriggerAllUserEventsProcessed(); + + bool Yield( bool bWait, bool bHandleAllCurrentEvents ); + inline GdkDisplay *GetGdkDisplay(); + + virtual void ErrorTrapPush() override; + virtual bool ErrorTrapPop( bool bIgnoreError = true ) override; + + inline GtkSalDisplay *GetGtkDisplay() const; + void setException(const std::exception_ptr& exception) { m_aException = exception; } +}; + +class GtkSalFrame; + +class GtkSalDisplay : public SalGenericDisplay +{ + GtkSalSystem* m_pSys; + GdkDisplay* m_pGdkDisplay; + o3tl::enumarray<PointerStyle, GdkCursor*> m_aCursors; + bool m_bStartupCompleted; + bool m_bX11Display; + + GdkCursor* getFromSvg( OUString const & name, int nXHot, int nYHot ); + +public: + GtkSalDisplay( GdkDisplay* pDisplay ); + virtual ~GtkSalDisplay() override; + + GdkDisplay* GetGdkDisplay() const { return m_pGdkDisplay; } + bool IsX11Display() const { return m_bX11Display; } + + GtkSalSystem* getSystem() const { return m_pSys; } + + GtkWidget* findGtkWidgetForNativeHandle(sal_uIntPtr hWindow) const; + + virtual void deregisterFrame( SalFrame* pFrame ) override; + GdkCursor *getCursor( PointerStyle ePointerStyle ); + virtual int CaptureMouse( SalFrame* pFrame ); + + SalX11Screen GetDefaultXScreen() { return m_pSys->GetDisplayDefaultXScreen(); } + Size GetScreenSize( int nDisplayScreen ); + + GdkFilterReturn filterGdkEvent( GdkXEvent* sys_event ); + void startupNotificationCompleted() { m_bStartupCompleted = true; } + + void screenSizeChanged( GdkScreen const * ); + void monitorsChanged( GdkScreen const * ); + + virtual void TriggerUserEventProcessing() override; + virtual void TriggerAllUserEventsProcessed() override; +}; + +inline GtkSalData* GetGtkSalData() +{ + return static_cast<GtkSalData*>(ImplGetSVData()->mpSalData); +} +inline GdkDisplay *GtkSalData::GetGdkDisplay() +{ + return GetGtkDisplay()->GetGdkDisplay(); +} + +GtkSalDisplay *GtkSalData::GetGtkDisplay() const +{ + return static_cast<GtkSalDisplay *>(GetDisplay()); +} + +#endif // INCLUDED_VCL_INC_UNX_GTK_GTKDATA_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx new file mode 100644 index 000000000..e42e1649a --- /dev/null +++ b/vcl/inc/unx/gtk/gtkframe.hxx @@ -0,0 +1,567 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_UNX_GTK_GTKFRAME_HXX +#define INCLUDED_VCL_INC_UNX_GTK_GTKFRAME_HXX + +#include <cairo.h> +#include <gdk/gdk.h> +#include <gdk/gdkx.h> +#include <gtk/gtk.h> +#include <gtk/gtkx.h> +#include <gdk/gdkkeysyms.h> + +#include <salframe.hxx> +#include <vcl/idle.hxx> +#include <vcl/sysdata.hxx> +#include <unx/nativewindowhandleprovider.hxx> +#include <unx/saltype.h> +#include <unx/screensaverinhibitor.hxx> + +#include <tools/link.hxx> + +#include <com/sun/star/awt/XTopWindow.hpp> +#include <com/sun/star/datatransfer/DataFlavor.hpp> +#include <com/sun/star/datatransfer/dnd/XDragSource.hpp> +#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> + +#include <list> +#include <vector> + +#include <config_dbus.h> +#include <config_gio.h> + +#include <headless/svpgdi.hxx> + +class GtkSalGraphics; +class GtkSalDisplay; + +typedef sal_uIntPtr GdkNativeWindow; +#define GDK_WINDOW_XWINDOW(o) GDK_WINDOW_XID(o) +#define gdk_set_sm_client_id(i) gdk_x11_set_sm_client_id(i) +#define gdk_window_foreign_new_for_display(a,b) gdk_x11_window_foreign_new_for_display(a,b) +class GtkDropTarget; +class GtkDragSource; +class GtkDnDTransferable; + +class GtkSalMenu; + +class GtkSalFrame final : public SalFrame + , public NativeWindowHandleProvider +{ + struct IMHandler + { + + // Not all GTK Input Methods swallow key release + // events. Since they swallow the key press events and we + // are left with the key release events, we need to + // manually swallow those. To do this, we keep a list of + // the previous 10 key press events in each GtkSalFrame + // and when we get a key release that matches one of the + // key press events in our list, we swallow it. + struct PreviousKeyPress + { + GdkWindow *window; + gint8 send_event; + guint32 time; + guint state; + guint keyval; + guint16 hardware_keycode; + guint8 group; + + PreviousKeyPress (GdkEventKey *event) + : window (nullptr), + send_event (0), + time (0), + state (0), + keyval (0), + hardware_keycode (0), + group (0) + { + if (event) + { + window = event->window; + send_event = event->send_event; + time = event->time; + state = event->state; + keyval = event->keyval; + hardware_keycode = event->hardware_keycode; + group = event->group; + } + } + + PreviousKeyPress( const PreviousKeyPress& rPrev ) + : window( rPrev.window ), + send_event( rPrev.send_event ), + time( rPrev.time ), + state( rPrev.state ), + keyval( rPrev.keyval ), + hardware_keycode( rPrev.hardware_keycode ), + group( rPrev.group ) + {} + + bool operator== (GdkEventKey const *event) const + { + return (event != nullptr) + && (event->window == window) + && (event->send_event == send_event) + // ignore non-Gdk state bits, e.g., these used by IBus + && ((event->state & GDK_MODIFIER_MASK) == (state & GDK_MODIFIER_MASK)) + && (event->keyval == keyval) + && (event->hardware_keycode == hardware_keycode) + && (event->group == group) + && (event->time - time < 300) + ; + } + }; + + GtkSalFrame* m_pFrame; + std::list< PreviousKeyPress > m_aPrevKeyPresses; + int m_nPrevKeyPresses; // avoid using size() + GtkIMContext* m_pIMContext; + bool m_bFocused; + bool m_bPreeditJustChanged; + SalExtTextInputEvent m_aInputEvent; + std::vector< ExtTextInputAttr > m_aInputFlags; + + IMHandler( GtkSalFrame* ); + ~IMHandler(); + + void createIMContext(); + void deleteIMContext(); + void updateIMSpotLocation(); + void endExtTextInput( EndExtTextInputFlags nFlags ); + bool handleKeyEvent( GdkEventKey* pEvent ); + void focusChanged( bool bFocusIn ); + + void doCallEndExtTextInput(); + void sendEmptyCommit(); + + static void signalIMCommit( GtkIMContext*, gchar*, gpointer ); + static gboolean signalIMDeleteSurrounding( GtkIMContext*, gint, gint, gpointer ); + static void signalIMPreeditChanged( GtkIMContext*, gpointer ); + static void signalIMPreeditEnd( GtkIMContext*, gpointer ); + static void signalIMPreeditStart( GtkIMContext*, gpointer ); + static gboolean signalIMRetrieveSurrounding( GtkIMContext*, gpointer ); + }; + friend struct IMHandler; + + friend class GtkSalObjectWidgetClip; + + SalX11Screen m_nXScreen; + GtkWidget* m_pWindow; + GtkHeaderBar* m_pHeaderBar; + GtkGrid* m_pTopLevelGrid; + GtkEventBox* m_pEventBox; + GtkFixed* m_pFixedContainer; + GdkWindow* m_pForeignParent; + GdkNativeWindow m_aForeignParentWindow; + GdkWindow* m_pForeignTopLevel; + GdkNativeWindow m_aForeignTopLevelWindow; + SalFrameStyleFlags m_nStyle; + GtkSalFrame* m_pParent; + std::list< GtkSalFrame* > m_aChildren; + GdkWindowState m_nState; + SystemEnvData m_aSystemData; + std::unique_ptr<GtkSalGraphics> m_pGraphics; + bool m_bGraphics; + ModKeyFlags m_nKeyModifiers; + GdkCursor *m_pCurrentCursor; + PointerStyle m_ePointerStyle; + ScreenSaverInhibitor m_ScreenSaverInhibitor; + bool m_bFullscreen; + bool m_bSpanMonitorsWhenFullscreen; + bool m_bDefaultPos; + bool m_bDefaultSize; + bool m_bTooltipBlocked; + OUString m_sWMClass; + + std::unique_ptr<IMHandler> m_pIMHandler; + + Size m_aMaxSize; + Size m_aMinSize; + tools::Rectangle m_aRestorePosSize; + + OUString m_aTooltip; + tools::Rectangle m_aHelpArea; + tools::Rectangle m_aFloatRect; + FloatWinPopupFlags m_nFloatFlags; + bool m_bFloatPositioned; + long m_nWidthRequest; + long m_nHeightRequest; + cairo_region_t* m_pRegion; + GtkDropTarget* m_pDropTarget; + GtkDragSource* m_pDragSource; + bool m_bGeometryIsProvisional; + bool m_bIconSetWhileUnmapped; + + GtkSalMenu* m_pSalMenu; + +#if ENABLE_DBUS && ENABLE_GIO + private: + friend void ensure_dbus_setup(GdkWindow* gdkWindow, GtkSalFrame* pSalFrame); + friend void on_registrar_available (GDBusConnection*, const gchar*, const gchar*, gpointer); + friend void on_registrar_unavailable (GDBusConnection*, const gchar*, gpointer); +#endif + guint m_nWatcherId; + + void Init( SalFrame* pParent, SalFrameStyleFlags nStyle ); + void Init( SystemParentData* pSysData ); + void InitCommon(); + void InvalidateGraphics(); + + // signals + static gboolean signalButton( GtkWidget*, GdkEventButton*, gpointer ); + static void signalStyleUpdated(GtkWidget*, gpointer); + static gboolean signalDraw( GtkWidget*, cairo_t *cr, gpointer ); + static void signalRealize(GtkWidget*, gpointer frame); + static void sizeAllocated(GtkWidget*, GdkRectangle *pAllocation, gpointer frame); + static gboolean signalTooltipQuery(GtkWidget*, gint x, gint y, + gboolean keyboard_mode, GtkTooltip *tooltip, + gpointer frame); + static gboolean signalDragMotion(GtkWidget *widget, GdkDragContext *context, gint x, gint y, + guint time, gpointer frame); + static gboolean signalDragDrop(GtkWidget* widget, GdkDragContext *context, gint x, gint y, + guint time, gpointer frame); + static void signalDragDropReceived(GtkWidget *widget, GdkDragContext *context, gint x, gint y, + GtkSelectionData *data, guint ttype, guint time, gpointer frame); + static void signalDragLeave(GtkWidget *widget, GdkDragContext *context, guint time, gpointer frame); + + static gboolean signalDragFailed(GtkWidget *widget, GdkDragContext *context, GtkDragResult result, gpointer frame); + static void signalDragDelete(GtkWidget *widget, GdkDragContext *context, gpointer frame); + static void signalDragEnd(GtkWidget *widget, GdkDragContext *context, gpointer frame); + static void signalDragDataGet(GtkWidget* widget, GdkDragContext* context, GtkSelectionData *data, guint info, + guint time, gpointer frame); + + static void gestureSwipe(GtkGestureSwipe* gesture, gdouble velocity_x, gdouble velocity_y, gpointer frame); + static void gestureLongPress(GtkGestureLongPress* gesture, gdouble x, gdouble y, gpointer frame); + static gboolean signalFocus( GtkWidget*, GdkEventFocus*, gpointer ); + static void signalSetFocus( GtkWindow* pWindow, GtkWidget* pWidget, gpointer frame ); + static gboolean signalMap( GtkWidget*, GdkEvent*, gpointer ); + static gboolean signalUnmap( GtkWidget*, GdkEvent*, gpointer ); + static gboolean signalConfigure( GtkWidget*, GdkEventConfigure*, gpointer ); + static gboolean signalMotion( GtkWidget*, GdkEventMotion*, gpointer ); + static gboolean signalKey( GtkWidget*, GdkEventKey*, gpointer ); + static gboolean signalDelete( GtkWidget*, GdkEvent*, gpointer ); + static gboolean signalWindowState( GtkWidget*, GdkEvent*, gpointer ); + static gboolean signalScroll( GtkWidget*, GdkEvent*, gpointer ); + static gboolean signalCrossing( GtkWidget*, GdkEventCrossing*, gpointer ); + static gboolean signalVisibility( GtkWidget*, GdkEventVisibility*, gpointer ); + static void signalDestroy( GtkWidget*, gpointer ); + + void Center(); + void SetDefaultSize(); + + bool doKeyCallback( guint state, + guint keyval, + guint16 hardware_keycode, + guint8 group, + sal_Unicode aOrigCode, + bool bDown, + bool bSendRelease + ); + + static GdkNativeWindow findTopLevelSystemWindow( GdkNativeWindow aWindow ); + + static int m_nFloats; + + bool isFloatGrabWindow() const + { + return + (m_nStyle & SalFrameStyleFlags::FLOAT) && // only a float can be floatgrab + !(m_nStyle & SalFrameStyleFlags::TOOLTIP) && // tool tips are not + !(m_nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION); // toolbars are also not + } + + bool isChild( bool bPlug = true, bool bSysChild = true ) + { + SalFrameStyleFlags nMask = SalFrameStyleFlags::NONE; + if( bPlug ) + nMask |= SalFrameStyleFlags::PLUG; + if( bSysChild ) + nMask |= SalFrameStyleFlags::SYSTEMCHILD; + return bool(m_nStyle & nMask); + } + + //call gtk_window_resize + void window_resize(long nWidth, long nHeight); + //call gtk_widget_set_size_request + void widget_set_size_request(long nWidth, long nHeight); + + void resizeWindow( long nWidth, long nHeight ); + void moveWindow( long nX, long nY ); + + Size calcDefaultSize(); + + void setMinMaxSize(); + + void AllocateFrame(); + void TriggerPaintEvent(); + + void updateWMClass(); + + enum class SetType { RetainSize, Fullscreen, UnFullscreen }; + + void SetScreen( unsigned int nNewScreen, SetType eType, tools::Rectangle const *pSize = nullptr ); + + void SetIcon(const char* pIcon); + +public: + cairo_surface_t* m_pSurface; + basegfx::B2IVector m_aFrameSize; + DamageHandler m_aDamageHandler; + std::vector<GdkEvent*> m_aPendingScrollEvents; + Idle m_aSmoothScrollIdle; + int m_nGrabLevel; + bool m_bSalObjectSetPosSize; + GtkSalFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ); + GtkSalFrame( SystemParentData* pSysData ); + + guint m_nMenuExportId; + guint m_nActionGroupExportId; + guint m_nHudAwarenessId; + std::vector<gulong> m_aMouseSignalIds; + + void grabPointer(bool bGrab, bool bKeyboardAlso, bool bOwnerEvents); + + static GtkSalDisplay* getDisplay(); + static GdkDisplay* getGdkDisplay(); + GtkWidget* getWindow() const { return m_pWindow; } + GtkFixed* getFixedContainer() const { return m_pFixedContainer; } + GtkEventBox* getEventBox() const { return m_pEventBox; } + GtkWidget* getMouseEventWidget() const; + GtkGrid* getTopLevelGridWidget() const { return m_pTopLevelGrid; } + const SalX11Screen& getXScreenNumber() const { return m_nXScreen; } + int GetDisplayScreen() const { return maGeometry.nDisplayScreenNumber; } + void updateScreenNumber(); + + cairo_t* getCairoContext() const; + void damaged(sal_Int32 nExtentsLeft, sal_Int32 nExtentsTop, + sal_Int32 nExtentsRight, sal_Int32 nExtentsBottom) const; + + void registerDropTarget(GtkDropTarget* pDropTarget) + { + assert(!m_pDropTarget); + m_pDropTarget = pDropTarget; + } + + void deregisterDropTarget(GtkDropTarget const * pDropTarget) + { + assert(m_pDropTarget == pDropTarget); (void)pDropTarget; + m_pDropTarget = nullptr; + } + + void registerDragSource(GtkDragSource* pDragSource) + { + assert(!m_pDragSource); + m_pDragSource = pDragSource; + } + + void deregisterDragSource(GtkDragSource const * pDragSource) + { + assert(m_pDragSource == pDragSource); (void)pDragSource; + m_pDragSource = nullptr; + } + + void startDrag(gint nButton, gint nDragOriginX, gint nDragOriginY, + GdkDragAction sourceActions, GtkTargetList* pTargetList); + + void closePopup(); + + void addGrabLevel(); + void removeGrabLevel(); + + void nopaint_container_resize_children(GtkContainer*); + + void LaunchAsyncScroll(GdkEvent const * pEvent); + DECL_LINK(AsyncScroll, Timer *, void); + + virtual ~GtkSalFrame() override; + + // SalGraphics or NULL, but two Graphics for all SalFrames + // must be returned + virtual SalGraphics* AcquireGraphics() override; + virtual void ReleaseGraphics( SalGraphics* pGraphics ) override; + + // Event must be destroyed, when Frame is destroyed + // When Event is called, SalInstance::Yield() must be returned + virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override; + + virtual void SetTitle( const OUString& rTitle ) override; + virtual void SetIcon( sal_uInt16 nIcon ) override; + virtual void SetMenu( SalMenu *pSalMenu ) override; + SalMenu* GetMenu(); + virtual void DrawMenuBar() override; + void EnsureAppMenuWatch(); + + virtual void SetExtendedFrameStyle( SalExtStyle nExtStyle ) override; + // Before the window is visible, a resize event + // must be sent with the correct size + virtual void Show( bool bVisible, bool bNoActivate = false ) override; + // Set ClientSize and Center the Window to the desktop + // and send/post a resize message + virtual void SetMinClientSize( long nWidth, long nHeight ) override; + virtual void SetMaxClientSize( long nWidth, long nHeight ) override; + virtual void SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags ) override; + virtual void GetClientSize( long& rWidth, long& rHeight ) override; + virtual void GetWorkArea( tools::Rectangle& rRect ) override; + virtual SalFrame* GetParent() const override; + virtual void SetWindowState( const SalFrameState* pState ) override; + virtual bool GetWindowState( SalFrameState* pState ) override; + virtual void ShowFullScreen( bool bFullScreen, sal_Int32 nDisplay ) override; + // Enable/Disable ScreenSaver, SystemAgents, ... + virtual void StartPresentation( bool bStart ) override; + // Show Window over all other Windows + virtual void SetAlwaysOnTop( bool bOnTop ) override; + + // Window to top and grab focus + virtual void ToTop( SalFrameToTop nFlags ) override; + + // this function can call with the same + // pointer style + virtual void SetPointer( PointerStyle ePointerStyle ) override; + virtual void CaptureMouse( bool bMouse ) override; + virtual void GrabFocus() override; + virtual void SetPointerPos( long nX, long nY ) override; + + // flush output buffer + using SalFrame::Flush; + virtual void Flush() override; + // flush output buffer, wait till outstanding operations are done + + virtual void SetInputContext( SalInputContext* pContext ) override; + virtual void EndExtTextInput( EndExtTextInputFlags nFlags ) override; + + virtual OUString GetKeyName( sal_uInt16 nKeyCode ) override; + virtual bool MapUnicodeToKeyCode( sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode& rKeyCode ) override; + + // returns the input language used for the last key stroke + // may be LANGUAGE_DONTKNOW if not supported by the OS + virtual LanguageType GetInputLanguage() override; + + virtual void UpdateSettings( AllSettings& rSettings ) override; + + virtual void Beep() override; + + // returns system data (most prominent: window handle) + virtual const SystemEnvData* GetSystemData() const override; + + // get current modifier and button mask + virtual SalPointerState GetPointerState() override; + + virtual KeyIndicatorState GetIndicatorState() override; + + virtual void SimulateKeyPress( sal_uInt16 nKeyCode ) override; + + // set new parent window + virtual void SetParent( SalFrame* pNewParent ) override; + // reparent window to act as a plugin; implementation + // may choose to use a new system window internally + // return false to indicate failure + virtual bool SetPluginParent( SystemParentData* pNewParent ) override; + + virtual void SetScreenNumber( unsigned int ) override; + virtual void SetApplicationID( const OUString &rWMClass ) override; + + // shaped system windows + // set clip region to none (-> rectangular windows, normal state) + virtual void ResetClipRegion() override; + // start setting the clipregion consisting of nRects rectangles + virtual void BeginSetClipRegion( sal_uInt32 nRects ) override; + // add a rectangle to the clip region + virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) override; + // done setting up the clipregion + virtual void EndSetClipRegion() override; + + virtual void PositionByToolkit(const tools::Rectangle& rRect, FloatWinPopupFlags nFlags) override; + virtual void SetModal(bool bModal) override; + virtual bool GetModal() const override; + void HideTooltip(); + void BlockTooltip(); + void UnblockTooltip(); + virtual bool ShowTooltip(const OUString& rHelpText, const tools::Rectangle& rHelpArea) override; + virtual void* ShowPopover(const OUString& rHelpText, vcl::Window* pParent, const tools::Rectangle& rHelpArea, QuickHelpFlags nFlags) override; + virtual bool UpdatePopover(void* nId, const OUString& rHelpText, vcl::Window* pParent, const tools::Rectangle& rHelpArea) override; + virtual bool HidePopover(void* nId) override; + virtual weld::Window* GetFrameWeld() const override; + + static GtkSalFrame *getFromWindow( GtkWidget *pWindow ); + + sal_uIntPtr GetNativeWindowHandle(GtkWidget *pWidget); + virtual sal_uIntPtr GetNativeWindowHandle() override; + + //Call the usual SalFrame Callback, but catch uno exceptions and delegate + //to GtkSalData to rethrow them after the gsignal is processed when its safe + //to do so again in our own code after the g_main_context_iteration call + //which triggers the gsignals. + bool CallCallbackExc(SalEvent nEvent, const void* pEvent) const; + + + static void KeyCodeToGdkKey(const vcl::KeyCode& rKeyCode, + guint* pGdkKeyCode, GdkModifierType *pGdkModifiers); + + static guint32 GetLastInputEventTime(); + static void UpdateLastInputEventTime(guint32 nUserInputTime); + static sal_uInt16 GetMouseModCode(guint nState); + static sal_uInt16 GetKeyCode(guint nKeyVal); + static guint GetKeyValFor(GdkKeymap* pKeyMap, guint16 hardware_keycode, guint8 group); + static sal_uInt16 GetKeyModCode(guint nState); + static GdkEvent* makeFakeKeyPress(GtkWidget* pWidget); + static SalWheelMouseEvent GetWheelEvent(GdkEventScroll& rEvent); + static gboolean NativeWidgetHelpPressed(GtkAccelGroup*, GObject*, guint, + GdkModifierType, gpointer pFrame); + static OUString GetPreeditDetails(GtkIMContext* pIMContext, std::vector<ExtTextInputAttr>& rInputFlags, sal_Int32& rCursorPos, sal_uInt8& rCursorFlags); +}; + +#define OOO_TYPE_FIXED ooo_fixed_get_type() + +extern "C" { + +GType ooo_fixed_get_type(); +AtkObject* ooo_fixed_get_accessible(GtkWidget *obj); + +} // extern "C" + +#if !GTK_CHECK_VERSION(3, 20, 0) +enum GdkDragCancelReason +{ + GDK_DRAG_CANCEL_NO_TARGET, + GDK_DRAG_CANCEL_USER_CANCELLED, + GDK_DRAG_CANCEL_ERROR +}; +#endif + +#if !GTK_CHECK_VERSION(3, 22, 0) +enum GdkAnchorHints +{ + GDK_ANCHOR_FLIP_X = 1 << 0, + GDK_ANCHOR_FLIP_Y = 1 << 1, + GDK_ANCHOR_SLIDE_X = 1 << 2, + GDK_ANCHOR_SLIDE_Y = 1 << 3, + GDK_ANCHOR_RESIZE_X = 1 << 4, + GDK_ANCHOR_RESIZE_Y = 1 << 5, + GDK_ANCHOR_FLIP = GDK_ANCHOR_FLIP_X | GDK_ANCHOR_FLIP_Y, + GDK_ANCHOR_SLIDE = GDK_ANCHOR_SLIDE_X | GDK_ANCHOR_SLIDE_Y, + GDK_ANCHOR_RESIZE = GDK_ANCHOR_RESIZE_X | GDK_ANCHOR_RESIZE_Y +}; +#endif + +#endif // INCLUDED_VCL_INC_UNX_GTK_GTKFRAME_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx new file mode 100644 index 000000000..430bab56d --- /dev/null +++ b/vcl/inc/unx/gtk/gtkgdi.hxx @@ -0,0 +1,399 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_UNX_GTK_GTKGDI_HXX +#define INCLUDED_VCL_INC_UNX_GTK_GTKGDI_HXX + +#include <config_cairo_canvas.h> + +#include <gtk/gtk.h> +#include "gtkbackend.hxx" +#include <gdk/gdkkeysyms.h> + +#include <unx/gtk/gtkframe.hxx> +#include <ControlCacheKey.hxx> + +#include <headless/svpgdi.hxx> +#include <textrender.hxx> + +enum class GtkControlPart +{ + ToplevelWindow, + Button, + LinkButton, + CheckButton, + CheckButtonCheck, + RadioButton, + RadioButtonRadio, + Entry, + Combobox, + ComboboxBox, + ComboboxBoxEntry, + ComboboxBoxButton, + ComboboxBoxButtonBox, + ComboboxBoxButtonBoxArrow, + Listbox, + ListboxBox, + ListboxBoxButton, + ListboxBoxButtonBox, + ListboxBoxButtonBoxArrow, + SpinButton, + SpinButtonEntry, + SpinButtonUpButton, + SpinButtonDownButton, + ScrollbarVertical, + ScrollbarVerticalContents, + ScrollbarVerticalTrough, + ScrollbarVerticalSlider, + ScrollbarVerticalButton, + ScrollbarHorizontal, + ScrollbarHorizontalContents, + ScrollbarHorizontalTrough, + ScrollbarHorizontalSlider, + ScrollbarHorizontalButton, + ProgressBar, + ProgressBarTrough, + ProgressBarProgress, + Notebook, + NotebookHeader, + NotebookStack, + NotebookHeaderTabs, + NotebookHeaderTabsTab, + NotebookHeaderTabsTabLabel, + NotebookHeaderTabsTabActiveLabel, + NotebookHeaderTabsTabHoverLabel, + FrameBorder, + MenuBar, + MenuBarItem, + MenuWindow, + Menu, + MenuItem, + MenuItemLabel, + MenuItemArrow, + CheckMenuItem, + CheckMenuItemCheck, + RadioMenuItem, + RadioMenuItemRadio, + SeparatorMenuItem, + SeparatorMenuItemSeparator, +}; + +typedef void (*gtk_widget_path_iter_set_object_nameFunc)(GtkWidgetPath *, guint, const char*); + +class GtkSalGraphics : public SvpSalGraphics +{ + GtkSalFrame * const mpFrame; + +protected: + bool isNativeControlSupported(ControlType, ControlPart) override; + virtual bool drawNativeControl( ControlType nType, ControlPart nPart, + const tools::Rectangle& rControlRegion, + ControlState nState, const ImplControlValue& aValue, + const OUString& rCaption, + const Color& rBackgroundColor ) override; + virtual bool getNativeControlRegion( ControlType nType, ControlPart nPart, + const tools::Rectangle& rControlRegion, + ControlState nState, + const ImplControlValue& aValue, + const OUString& rCaption, + tools::Rectangle &rNativeBoundingRegion, + tools::Rectangle &rNativeContentRegion ) override; + bool updateSettings(AllSettings&) override; + void handleDamage(const tools::Rectangle&) override; + +public: + GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow ); + +#if ENABLE_CAIRO_CANVAS + + virtual bool SupportsCairo() const override; + virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const override; + virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const override; + +#endif + + void WidgetQueueDraw() const; + + virtual void GetResolution(sal_Int32& rDPIX, sal_Int32& rDPIY) override; + + virtual OUString getRenderBackendName() const override { return "gtk3svp"; } + + GtkStyleContext* createStyleContext(gtk_widget_path_iter_set_object_nameFunc set_object_name, GtkControlPart ePart); + GtkStyleContext* createNewContext(GtkControlPart ePart, gtk_widget_path_iter_set_object_nameFunc set_object_name); + GtkStyleContext* createOldContext(GtkControlPart ePart); + GtkStyleContext* makeContext(GtkWidgetPath *pPath, GtkStyleContext *pParent); +private: + GtkWidget *mpWindow; + static GtkStyleContext *mpWindowStyle; + static GtkStyleContext *mpButtonStyle; + static GtkStyleContext *mpLinkButtonStyle; + static GtkStyleContext *mpEntryStyle; + static GtkStyleContext *mpTextViewStyle; + static GtkStyleContext *mpVScrollbarStyle; + static GtkStyleContext *mpVScrollbarContentsStyle; + static GtkStyleContext *mpVScrollbarTroughStyle; + static GtkStyleContext *mpVScrollbarSliderStyle; + static GtkStyleContext *mpVScrollbarButtonStyle; + static GtkStyleContext *mpHScrollbarStyle; + static GtkStyleContext *mpHScrollbarContentsStyle; + static GtkStyleContext *mpHScrollbarTroughStyle; + static GtkStyleContext *mpHScrollbarSliderStyle; + static GtkStyleContext *mpHScrollbarButtonStyle; + static GtkStyleContext *mpToolbarStyle; + static GtkStyleContext *mpToolButtonStyle; + static GtkStyleContext *mpToolbarSeperatorStyle; + static GtkStyleContext *mpCheckButtonStyle; + static GtkStyleContext *mpCheckButtonCheckStyle; + static GtkStyleContext *mpRadioButtonStyle; + static GtkStyleContext *mpRadioButtonRadioStyle; + static GtkStyleContext *mpSpinStyle; + static GtkStyleContext *mpSpinEntryStyle; + static GtkStyleContext *mpSpinUpStyle; + static GtkStyleContext *mpSpinDownStyle; + static GtkStyleContext *mpComboboxStyle; + static GtkStyleContext *mpComboboxBoxStyle; + static GtkStyleContext *mpComboboxEntryStyle; + static GtkStyleContext *mpComboboxButtonStyle; + static GtkStyleContext *mpComboboxButtonBoxStyle; + static GtkStyleContext *mpComboboxButtonArrowStyle; + static GtkStyleContext *mpListboxStyle; + static GtkStyleContext *mpListboxBoxStyle; + static GtkStyleContext *mpListboxButtonStyle; + static GtkStyleContext *mpListboxButtonBoxStyle; + static GtkStyleContext *mpListboxButtonArrowStyle; + static GtkStyleContext *mpFrameInStyle; + static GtkStyleContext *mpFrameOutStyle; + static GtkStyleContext *mpFixedHoriLineStyle; + static GtkStyleContext *mpFixedVertLineStyle; + static GtkStyleContext *mpTreeHeaderButtonStyle; + static GtkStyleContext *mpProgressBarStyle; + static GtkStyleContext *mpProgressBarTroughStyle; + static GtkStyleContext *mpProgressBarProgressStyle; + static GtkStyleContext *mpNotebookStyle; + static GtkStyleContext *mpNotebookStackStyle; + static GtkStyleContext *mpNotebookHeaderStyle; + static GtkStyleContext *mpNotebookHeaderTabsStyle; + static GtkStyleContext *mpNotebookHeaderTabsTabStyle; + static GtkStyleContext *mpNotebookHeaderTabsTabLabelStyle; + static GtkStyleContext *mpNotebookHeaderTabsTabActiveLabelStyle; + static GtkStyleContext *mpNotebookHeaderTabsTabHoverLabelStyle; + static GtkStyleContext *mpMenuBarStyle; + static GtkStyleContext *mpMenuBarItemStyle; + static GtkStyleContext *mpMenuWindowStyle; + static GtkStyleContext *mpMenuStyle; + static GtkStyleContext *mpMenuItemStyle; + static GtkStyleContext *mpMenuItemLabelStyle; + static GtkStyleContext *mpMenuItemArrowStyle; + static GtkStyleContext *mpCheckMenuItemStyle; + static GtkStyleContext *mpCheckMenuItemCheckStyle; + static GtkStyleContext *mpRadioMenuItemStyle; + static GtkStyleContext *mpRadioMenuItemRadioStyle; + static GtkStyleContext *mpSeparatorMenuItemStyle; + static GtkStyleContext *mpSeparatorMenuItemSeparatorStyle; + + static tools::Rectangle NWGetScrollButtonRect( ControlPart nPart, tools::Rectangle aAreaRect ); + static tools::Rectangle NWGetSpinButtonRect( ControlPart nPart, tools::Rectangle aAreaRect); + static tools::Rectangle NWGetComboBoxButtonRect(ControlType nType, ControlPart nPart, tools::Rectangle aAreaRect); + + static void PaintScrollbar(GtkStyleContext *context, + cairo_t *cr, + const tools::Rectangle& rControlRectangle, + ControlPart nPart, + const ImplControlValue& aValue ); + void PaintOneSpinButton( GtkStyleContext *context, + cairo_t *cr, + ControlPart nPart, + tools::Rectangle aAreaRect, + ControlState nState ); + void PaintSpinButton(GtkStateFlags flags, + cairo_t *cr, + const tools::Rectangle& rControlRectangle, + ControlPart nPart, + const ImplControlValue& aValue); + static void PaintCombobox(GtkStateFlags flags, + cairo_t *cr, + const tools::Rectangle& rControlRectangle, + ControlType nType, + ControlPart nPart); + static void PaintCheckOrRadio(cairo_t *cr, GtkStyleContext *context, + const tools::Rectangle& rControlRectangle, + bool bIsCheck, bool bInMenu); + + static void PaintCheck(cairo_t *cr, GtkStyleContext *context, + const tools::Rectangle& rControlRectangle, bool bInMenu); + + static void PaintRadio(cairo_t *cr, GtkStyleContext *context, + const tools::Rectangle& rControlRectangle, bool bInMenu); + + + static bool style_loaded; +}; + +#else +#include <unx/salgdi.h> + +class GdkX11Pixmap; +class GtkSalGraphics : public X11SalGraphics +{ + GtkWidget *m_pWindow; + vcl::Region m_aClipRegion; + +public: + GtkSalGraphics(GtkSalFrame *, GtkWidget *window, SalX11Screen nXScreen); + virtual ~GtkSalGraphics() override; + + GtkWidget* GetGtkWidget() const { return m_pWindow; } + GdkWindow* GetGdkWindow() const { return m_pWindow->window; } + GtkSalFrame* GetGtkFrame() const { return static_cast<GtkSalFrame*>(m_pFrame); } + void SetWindow( GtkWidget* window ) { m_pWindow = window; } + + // will be set when UI theme was changed + static bool bThemeChanged; + static bool bNeedPixmapPaint; + static bool bNeedTwoPasses; + +protected: + // native widget methods + bool isNativeControlSupported(ControlType, ControlPart) override; + virtual bool hitTestNativeControl( ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion, + const Point& aPos, bool& rIsInside ) override; + virtual bool drawNativeControl( ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion, + ControlState nState, const ImplControlValue& aValue, + const OUString& rCaption, const Color& rBackgroundColor ) override; + virtual bool getNativeControlRegion( ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion, ControlState nState, + const ImplControlValue& aValue, const OUString& rCaption, + tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion ) override; + bool updateSettings(AllSettings&) override; + +public: + //helper methods for frame's UpdateSettings + static void refreshFontconfig( GtkSettings *pSettings ); + static void signalSettingsNotify( GObject*, GParamSpec *pSpec, gpointer ); + + virtual bool setClipRegion( const vcl::Region& ) override; + virtual void ResetClipRegion() override; + + // some themes set the background pixmap of our window EVERY time + // a control is painted; but presentation effects need + // the background set to None; workaround: set the background + // before copyBits + virtual void copyBits( const SalTwoRect& rPosAry, + SalGraphics* pSrcGraphics ) override; + + virtual OUString getRenderBackendName() const override { return "gtk3"; } + +protected: + + std::unique_ptr<GdkX11Pixmap> NWGetPixmapFromScreen( tools::Rectangle srcRect, int nBgColor = 0 ); + bool NWRenderPixmapToScreen( GdkX11Pixmap* pPixmap, GdkX11Pixmap* pMask, tools::Rectangle dstRect ); + + bool DoDrawNativeControl( GdkDrawable* pDrawable, + ControlType nType, + ControlPart nPart, + const tools::Rectangle& aCtrlRect, + const std::vector< tools::Rectangle >& aClip, + ControlState nState, + const ImplControlValue& aValue, + ControlCacheKey& rControlCacheKey); + + bool NWPaintGTKArrow( GdkDrawable* gdkDrawable, + const tools::Rectangle& rControlRectangle, + const std::vector< tools::Rectangle >& rClipList, + ControlState nState, const ImplControlValue& aValue ); + bool NWPaintGTKListHeader( GdkDrawable* gdkDrawable, + const tools::Rectangle& rControlRectangle, + const std::vector< tools::Rectangle >& rClipList, + ControlState nState ); + bool NWPaintGTKFixedLine( GdkDrawable* gdkDrawable, ControlPart nPart, + const tools::Rectangle& rControlRectangle ); + bool NWPaintGTKFrame( GdkDrawable* gdkDrawable, + const tools::Rectangle& rControlRectangle, + const std::vector< tools::Rectangle >& rClipList, + const ImplControlValue& aValue ); + bool NWPaintGTKWindowBackground( GdkDrawable* gdkDrawable, + const tools::Rectangle& rControlRectangle, + const std::vector< tools::Rectangle >& rClipList ); + bool NWPaintGTKButtonReal( GtkWidget* button, GdkDrawable* gdkDrawable, + const tools::Rectangle& rControlRectangle, + const std::vector< tools::Rectangle >& rClipList, + ControlState nState ); + bool NWPaintGTKButton( GdkDrawable* gdkDrawable, + const tools::Rectangle& rControlRectangle, + const std::vector< tools::Rectangle >& rClipList, + ControlState nState ); + bool NWPaintGTKRadio( GdkDrawable* gdkDrawable, + const tools::Rectangle& rControlRectangle, + const std::vector< tools::Rectangle >& rClipList, + ControlState nState, const ImplControlValue& aValue ); + bool NWPaintGTKCheck( GdkDrawable* gdkDrawable, + const tools::Rectangle& rControlRectangle, + const std::vector< tools::Rectangle >& rClipList, + ControlState nState, const ImplControlValue& aValue ); + bool NWPaintGTKScrollbar( ControlPart nPart, + const tools::Rectangle& rControlRectangle, + ControlState nState, const ImplControlValue& aValue ); + bool NWPaintGTKEditBox( GdkDrawable* gdkDrawable, ControlType nType, + const tools::Rectangle& rControlRectangle, + const std::vector< tools::Rectangle >& rClipList, + ControlState nState ); + bool NWPaintGTKSpinBox(ControlType nType, ControlPart nPart, + const tools::Rectangle& rControlRectangle, + ControlState nState, const ImplControlValue& aValue, + ControlCacheKey& rControlCacheKey); + bool NWPaintGTKComboBox( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, + const tools::Rectangle& rControlRectangle, + const std::vector< tools::Rectangle >& rClipList, + ControlState nState ); + bool NWPaintGTKTabItem( ControlType nType, + const tools::Rectangle& rControlRectangle, + ControlState nState, const ImplControlValue& aValue ); + bool NWPaintGTKListBox( GdkDrawable* gdkDrawable, ControlPart nPart, + const tools::Rectangle& rControlRectangle, + const std::vector< tools::Rectangle >& rClipList, + ControlState nState ); + + bool NWPaintGTKToolbar( GdkDrawable* gdkDrawable, ControlPart nPart, + const tools::Rectangle& rControlRectangle, + const std::vector< tools::Rectangle >& rClipList, + ControlState nState, const ImplControlValue& aValue ); + bool NWPaintGTKMenubar( GdkDrawable* gdkDrawable, ControlPart nPart, + const tools::Rectangle& rControlRectangle, + const std::vector< tools::Rectangle >& rClipList, + ControlState nState ); + bool NWPaintGTKPopupMenu( GdkDrawable* gdkDrawable, ControlPart nPart, + const tools::Rectangle& rControlRectangle, + const std::vector< tools::Rectangle >& rClipList, + ControlState nState ); + bool NWPaintGTKTooltip( GdkDrawable* gdkDrawable, + const tools::Rectangle& rControlRectangle, + const std::vector< tools::Rectangle >& rClipList ); + bool NWPaintGTKProgress( + const tools::Rectangle& rControlRectangle, + const ImplControlValue& aValue ); + bool NWPaintGTKSlider( GdkDrawable* gdkDrawable, ControlPart nPart, + const tools::Rectangle& rControlRectangle, + ControlState nState, const ImplControlValue& aValue ); + bool NWPaintGTKListNode( GdkDrawable* gdkDrawable, + const tools::Rectangle& rControlRectangle, + ControlState nState, const ImplControlValue& aValue ); +}; + +#endif // INCLUDED_VCL_INC_UNX_GTK_GTKGDI_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx new file mode 100644 index 000000000..3402aa6e3 --- /dev/null +++ b/vcl/inc/unx/gtk/gtkinst.hxx @@ -0,0 +1,298 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_UNX_GTK_GTKINST_HXX +#define INCLUDED_VCL_INC_UNX_GTK_GTKINST_HXX + +#include <sal/config.h> + +#include <stack> + +#include <unx/salinst.h> +#include <unx/gensys.h> +#include <headless/svpinst.hxx> +#include <com/sun/star/datatransfer/DataFlavor.hpp> +#include <com/sun/star/datatransfer/dnd/XDragSource.hpp> +#include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/awt/XWindow.hpp> +#include <cppuhelper/compbase.hxx> +#include <vcl/weld.hxx> +#include <vcl/weldutils.hxx> +#include <gtk/gtk.h> + +namespace vcl +{ +namespace unx +{ +class GtkPrintWrapper; +} +} + +vcl::Font pango_to_vcl(const PangoFontDescription* font, const css::lang::Locale& rLocale); + +class GenPspGraphics; +class GtkYieldMutex final : public SalYieldMutex +{ + thread_local static std::stack<sal_uInt32> yieldCounts; + +public: + GtkYieldMutex() {} + void ThreadsEnter(); + void ThreadsLeave(); +}; + +class GtkSalFrame; + +struct VclToGtkHelper +{ + std::vector<css::datatransfer::DataFlavor> aInfoToFlavor; + std::vector<GtkTargetEntry> FormatsToGtk(const css::uno::Sequence<css::datatransfer::DataFlavor> &rFormats); + void setSelectionData(const css::uno::Reference<css::datatransfer::XTransferable> &rTrans, + GtkSelectionData *selection_data, guint info); +private: + GtkTargetEntry makeGtkTargetEntry(const css::datatransfer::DataFlavor& rFlavor); +}; + +class GtkTransferable : public cppu::WeakImplHelper<css::datatransfer::XTransferable> +{ +protected: + std::map<OUString, GdkAtom> m_aMimeTypeToAtom; + + std::vector<css::datatransfer::DataFlavor> getTransferDataFlavorsAsVector(GdkAtom *targets, gint n_targets); + +public: + virtual css::uno::Any SAL_CALL getTransferData(const css::datatransfer::DataFlavor& rFlavor) override = 0; + virtual std::vector<css::datatransfer::DataFlavor> getTransferDataFlavorsAsVector() = 0; + virtual css::uno::Sequence<css::datatransfer::DataFlavor> SAL_CALL getTransferDataFlavors() override; + virtual sal_Bool SAL_CALL isDataFlavorSupported(const css::datatransfer::DataFlavor& rFlavor) override; +}; + +class GtkDnDTransferable; + +class GtkDropTarget final : public cppu::WeakComponentImplHelper<css::datatransfer::dnd::XDropTarget, + css::lang::XInitialization, + css::lang::XServiceInfo> +{ + osl::Mutex m_aMutex; + GtkSalFrame* m_pFrame; + GtkDnDTransferable* m_pFormatConversionRequest; + bool m_bActive; + bool m_bInDrag; + sal_Int8 m_nDefaultActions; + std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> m_aListeners; +public: + GtkDropTarget(); + virtual ~GtkDropTarget() override; + + // XInitialization + virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArgs) override; + void deinitialize(); + + // XDropTarget + virtual void SAL_CALL addDropTargetListener(const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>&) override; + virtual void SAL_CALL removeDropTargetListener(const css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>&) override; + virtual sal_Bool SAL_CALL isActive() override; + virtual void SAL_CALL setActive(sal_Bool active) override; + virtual sal_Int8 SAL_CALL getDefaultActions() override; + virtual void SAL_CALL setDefaultActions(sal_Int8 actions) override; + + OUString SAL_CALL getImplementationName() override; + + sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + void fire_dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent& dtdee); + void fire_dragOver(const css::datatransfer::dnd::DropTargetDragEvent& dtde); + void fire_drop(const css::datatransfer::dnd::DropTargetDropEvent& dtde); + void fire_dragExit(const css::datatransfer::dnd::DropTargetEvent& dte); + + void SetFormatConversionRequest(GtkDnDTransferable *pRequest) + { + m_pFormatConversionRequest = pRequest; + } + + gboolean signalDragDrop(GtkWidget* pWidget, GdkDragContext* context, gint x, gint y, guint time); + gboolean signalDragMotion(GtkWidget* pWidget, GdkDragContext* context, gint x, gint y, guint time); + void signalDragDropReceived(GtkWidget* pWidget, GdkDragContext* context, gint x, gint y, GtkSelectionData* data, guint ttype, guint time); + void signalDragLeave(GtkWidget* pWidget, GdkDragContext* context, guint time); +}; + +class GtkDragSource final : public cppu::WeakComponentImplHelper<css::datatransfer::dnd::XDragSource, + css::lang::XInitialization, + css::lang::XServiceInfo> +{ + osl::Mutex m_aMutex; + GtkSalFrame* m_pFrame; + css::uno::Reference<css::datatransfer::dnd::XDragSourceListener> m_xListener; + css::uno::Reference<css::datatransfer::XTransferable> m_xTrans; + VclToGtkHelper m_aConversionHelper; +public: + GtkDragSource() + : WeakComponentImplHelper(m_aMutex) + , m_pFrame(nullptr) + { + } + + void set_datatransfer(const css::uno::Reference<css::datatransfer::XTransferable>& rTrans, + const css::uno::Reference<css::datatransfer::dnd::XDragSourceListener>& rListener); + + std::vector<GtkTargetEntry> FormatsToGtk(const css::uno::Sequence<css::datatransfer::DataFlavor> &rFormats); + + void setActiveDragSource(); + + virtual ~GtkDragSource() override; + + // XDragSource + virtual sal_Bool SAL_CALL isDragImageSupported() override; + virtual sal_Int32 SAL_CALL getDefaultCursor(sal_Int8 dragAction) override; + virtual void SAL_CALL startDrag( + const css::datatransfer::dnd::DragGestureEvent& trigger, sal_Int8 sourceActions, sal_Int32 cursor, sal_Int32 image, + const css::uno::Reference< css::datatransfer::XTransferable >& transferable, + const css::uno::Reference< css::datatransfer::dnd::XDragSourceListener >& listener) override; + + // XInitialization + virtual void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any >& rArguments) override; + void deinitialize(); + + OUString SAL_CALL getImplementationName() override; + + sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override; + + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + void dragFailed(); + void dragDelete(); + void dragEnd(GdkDragContext* context); + void dragDataGet(GtkSelectionData *data, guint info); + + // For LibreOffice internal D&D we provide the Transferable without Gtk + // intermediaries as a shortcut, see tdf#100097 for how dbaccess depends on this + static GtkDragSource* g_ActiveDragSource; + css::uno::Reference<css::datatransfer::XTransferable> const & GetTransferrable() const { return m_xTrans; } +}; + +class GtkSalTimer; +class GtkInstance final : public SvpSalInstance +{ +public: + GtkInstance( std::unique_ptr<SalYieldMutex> pMutex ); + virtual ~GtkInstance() override; + void EnsureInit(); + virtual void AfterAppInit() override; + + virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override; + virtual SalFrame* CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) override; + virtual SalObject* CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, bool bShow ) override; + virtual SalSystem* CreateSalSystem() override; + virtual SalInfoPrinter* CreateInfoPrinter(SalPrinterQueueInfo* pPrinterQueueInfo, ImplJobSetup* pJobSetup) override; + virtual std::unique_ptr<SalPrinter> CreatePrinter( SalInfoPrinter* pInfoPrinter ) override; + virtual std::unique_ptr<SalMenu> CreateMenu( bool, Menu* ) override; + virtual std::unique_ptr<SalMenuItem> CreateMenuItem( const SalItemParams& ) override; + virtual SalTimer* CreateSalTimer() override; + virtual void AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService) override; + virtual std::unique_ptr<SalVirtualDevice> + CreateVirtualDevice( SalGraphics*, + long &nDX, long &nDY, + DeviceFormat eFormat, + const SystemGraphicsData* = nullptr ) override; + virtual std::shared_ptr<SalBitmap> CreateSalBitmap() override; + + virtual bool DoYield(bool bWait, bool bHandleAllCurrentEvents) override; + virtual bool AnyInput( VclInputFlags nType ) override; + // impossible to handle correctly, as "main thread" depends on the dispatch mutex + virtual bool IsMainThread() const override { return false; } + + virtual std::unique_ptr<GenPspGraphics> CreatePrintGraphics() override; + + virtual bool hasNativeFileSelection() const override { return true; } + + virtual css::uno::Reference< css::ui::dialogs::XFilePicker2 > + createFilePicker( const css::uno::Reference< css::uno::XComponentContext >& ) override; + virtual css::uno::Reference< css::ui::dialogs::XFolderPicker2 > + createFolderPicker( const css::uno::Reference< css::uno::XComponentContext >& ) override; + + virtual css::uno::Reference< css::uno::XInterface > CreateClipboard( const css::uno::Sequence< css::uno::Any >& i_rArguments ) override; + virtual css::uno::Reference< css::uno::XInterface > CreateDragSource() override; + virtual css::uno::Reference< css::uno::XInterface > CreateDropTarget() override; + virtual OpenGLContext* CreateOpenGLContext() override; + virtual weld::Builder* CreateBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile) override; + virtual weld::Builder* CreateInterimBuilder(vcl::Window* pParent, const OUString& rUIRoot, const OUString& rUIFile) override; + virtual weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage) override; + virtual weld::Window* GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow) override; + + virtual const cairo_font_options_t* GetCairoFontOptions() override; + const cairo_font_options_t* GetLastSeenCairoFontOptions() const; + void ResetLastSeenCairoFontOptions(const cairo_font_options_t* pOptions); + + void RemoveTimer (); + + std::shared_ptr<vcl::unx::GtkPrintWrapper> const & getPrintWrapper() const; + + void* CreateGStreamerSink(const SystemChildWindow*) override; + +private: + GtkSalTimer *m_pTimer; + std::unordered_map< GdkAtom, css::uno::Reference<css::uno::XInterface> > m_aClipboards; + bool IsTimerExpired(); + bool bNeedsInit; + cairo_font_options_t* m_pLastCairoFontOptions; + + mutable std::shared_ptr<vcl::unx::GtkPrintWrapper> m_xPrintWrapper; +}; + +class SalGtkXWindow final : public weld::TransportAsXWindow +{ +private: + weld::Window* m_pWeldWidget; + GtkWidget* m_pWidget; +public: + + SalGtkXWindow(weld::Window* pWeldWidget, GtkWidget* pWidget) + : TransportAsXWindow(pWeldWidget) + , m_pWeldWidget(pWeldWidget) + , m_pWidget(pWidget) + { + } + + virtual void clear() override + { + m_pWeldWidget = nullptr; + m_pWidget = nullptr; + TransportAsXWindow::clear(); + } + + GtkWidget* getGtkWidget() const + { + return m_pWidget; + } + + weld::Window* getFrameWeld() const + { + return m_pWeldWidget; + } +}; + +GdkPixbuf* load_icon_by_name(const OUString& rIconName); + +#endif // INCLUDED_VCL_INC_UNX_GTK_GTKINST_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/gtk/gtkobject.hxx b/vcl/inc/unx/gtk/gtkobject.hxx new file mode 100644 index 000000000..d1a5226cd --- /dev/null +++ b/vcl/inc/unx/gtk/gtkobject.hxx @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_INC_UNX_GTK_GTKOBJECT_HXX +#define INCLUDED_VCL_INC_UNX_GTK_GTKOBJECT_HXX + +#include <tools/solar.h> +#include <vcl/sysdata.hxx> +#include <salobj.hxx> +#include <unx/gtk/gtkframe.hxx> + +class GtkSalObjectBase : public SalObject +{ +protected: + SystemEnvData m_aSystemData; + GtkWidget* m_pSocket; + GtkSalFrame* m_pParent; + cairo_region_t* m_pRegion; + + void Init(); + +public: + GtkSalObjectBase(GtkSalFrame* pParent); + virtual ~GtkSalObjectBase() override; + + virtual void BeginSetClipRegion( sal_uInt32 nRects ) override; + virtual void UnionClipRegion( long nX, long nY, long nWidth, long nHeight ) override; + + virtual void SetForwardKey( bool bEnable ) override; + + virtual const SystemEnvData* GetSystemData() const override; + + virtual Size GetOptimalSize() const override; + +private: + // signals + static gboolean signalButton( GtkWidget*, GdkEventButton*, gpointer ); + static gboolean signalFocus( GtkWidget*, GdkEventFocus*, gpointer ); +}; + +// this attempts to clip the hosted native window using gdk_window_shape_combine_region +class GtkSalObject final : public GtkSalObjectBase +{ + // signals + static void signalDestroy( GtkWidget*, gpointer ); + +public: + GtkSalObject(GtkSalFrame* pParent, bool bShow); + virtual ~GtkSalObject() override; + + // override all pure virtual methods + virtual void ResetClipRegion() override; + virtual void EndSetClipRegion() override; + + virtual void SetPosSize( long nX, long nY, long nWidth, long nHeight ) override; + virtual void Show( bool bVisible ) override; + virtual void Reparent(SalFrame* pFrame) override; +}; + +// this attempts to clip the hosted native GtkWidget by using a GtkScrolledWindow as a viewport +// only a rectangular area is going to work +class GtkSalObjectWidgetClip final : public GtkSalObjectBase +{ + tools::Rectangle m_aRect; + tools::Rectangle m_aClipRect; + GtkWidget* m_pScrolledWindow; + + // signals + static gboolean signalScroll( GtkWidget*, GdkEvent*, gpointer ); + static void signalDestroy( GtkWidget*, gpointer ); + + bool signal_scroll(GtkWidget* pScrolledWindow, GdkEvent* pEvent); + + void ApplyClipRegion(); +public: + GtkSalObjectWidgetClip(GtkSalFrame* pParent, bool bShow); + virtual ~GtkSalObjectWidgetClip() override; + + // override all pure virtual methods + virtual void ResetClipRegion() override; + virtual void EndSetClipRegion() override; + + virtual void SetPosSize( long nX, long nY, long nWidth, long nHeight ) override; + virtual void Show( bool bVisible ) override; + virtual void Reparent(SalFrame* pFrame) override; +}; + + +#endif // INCLUDED_VCL_INC_UNX_GTK_GTKOBJECT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/gtk/gtkprintwrapper.hxx b/vcl/inc/unx/gtk/gtkprintwrapper.hxx new file mode 100644 index 000000000..589c800d7 --- /dev/null +++ b/vcl/inc/unx/gtk/gtkprintwrapper.hxx @@ -0,0 +1,69 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_UNX_GTK_INC_GTKPRINTWRAPPER_HXX +#define INCLUDED_VCL_UNX_GTK_INC_GTKPRINTWRAPPER_HXX + +#include <gtk/gtk.h> + +#include <gtk/gtkunixprint.h> + +#include <osl/module.hxx> +#include <sal/types.h> + +namespace vcl +{ +namespace unx +{ + +class GtkPrintWrapper +{ +private: + GtkPrintWrapper(const GtkPrintWrapper&) = delete; + GtkPrintWrapper& operator=(const GtkPrintWrapper&) = delete; +public: + GtkPrintWrapper(); + ~GtkPrintWrapper(); + + bool supportsPrinting() const; + bool supportsPrintSelection() const; + + // general printing support, since 2.10.0 + GtkPageSetup* page_setup_new() const; + + GtkPrintJob* print_job_new(const gchar* title, GtkPrinter* printer, GtkPrintSettings* settings, GtkPageSetup* page_setup) const; + void print_job_send(GtkPrintJob* job, GtkPrintJobCompleteFunc callback, gpointer user_data, GDestroyNotify dnotify) const; + gboolean print_job_set_source_file(GtkPrintJob* job, const gchar* filename, GError** error) const; + + const gchar* print_settings_get(GtkPrintSettings* settings, const gchar* key) const; + gboolean print_settings_get_collate(GtkPrintSettings* settings) const; + void print_settings_set_collate(GtkPrintSettings* settings, gboolean collate) const; + gint print_settings_get_n_copies(GtkPrintSettings* settings) const; + void print_settings_set_n_copies(GtkPrintSettings* settings, gint num_copies) const; + GtkPageRange* print_settings_get_page_ranges(GtkPrintSettings* settings, gint* num_ranges) const; + void print_settings_set_print_pages(GtkPrintSettings* settings, GtkPrintPages pages) const; + + GtkWidget* print_unix_dialog_new() const; + void print_unix_dialog_add_custom_tab(GtkPrintUnixDialog* dialog, GtkWidget* child, GtkWidget* tab_label) const; + GtkPrinter* print_unix_dialog_get_selected_printer(GtkPrintUnixDialog* dialog) const; + void print_unix_dialog_set_manual_capabilities(GtkPrintUnixDialog* dialog, GtkPrintCapabilities capabilities) const; + GtkPrintSettings* print_unix_dialog_get_settings(GtkPrintUnixDialog* dialog) const; + void print_unix_dialog_set_settings(GtkPrintUnixDialog* dialog, GtkPrintSettings* settings) const; + + // print selection support, since 2.17.4 + void print_unix_dialog_set_support_selection(GtkPrintUnixDialog* dialog, gboolean support_selection) const; + void print_unix_dialog_set_has_selection(GtkPrintUnixDialog* dialog, gboolean has_selection) const; +}; + +} +} + +#endif // INCLUDED_VCL_UNX_GTK_INC_GTKPRINTWRAPPER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/gtk/gtkprn.hxx b/vcl/inc/unx/gtk/gtkprn.hxx new file mode 100644 index 000000000..aa24f0e4d --- /dev/null +++ b/vcl/inc/unx/gtk/gtkprn.hxx @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_INC_UNX_GTK_GTKPRN_HXX +#define INCLUDED_VCL_INC_UNX_GTK_GTKPRN_HXX + +#include <unx/genprn.h> + +#include <memory> + +struct GtkSalPrinter_Impl; + +class GtkSalPrinter final : public PspSalPrinter +{ +public: + GtkSalPrinter(SalInfoPrinter* i_pInfoPrinter); + + ~GtkSalPrinter() override; + + using PspSalPrinter::StartJob; + virtual bool StartJob( + const OUString* i_pFileName, const OUString& i_rJobName, + const OUString& i_rAppName, ImplJobSetup* io_pSetupData, + vcl::PrinterController& io_rController) override; + virtual bool EndJob() override; + +private: + bool impl_doJob( + const OUString* i_pFileName, const OUString& i_rJobName, + const OUString& i_rAppName, ImplJobSetup* io_pSetupData, + bool i_bCollate, vcl::PrinterController& io_rController); + +private: + std::unique_ptr<GtkSalPrinter_Impl> m_xImpl; +}; + +class GtkSalInfoPrinter final : public PspSalInfoPrinter +{ +public: + sal_uInt32 GetCapabilities(const ImplJobSetup* i_pSetupData, PrinterCapType i_nType) override; +}; + +#endif // INCLUDED_VCL_INC_UNX_GTK_GTKPRN_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/gtk/gtksalmenu.hxx b/vcl/inc/unx/gtk/gtksalmenu.hxx new file mode 100644 index 000000000..4bac1fe53 --- /dev/null +++ b/vcl/inc/unx/gtk/gtksalmenu.hxx @@ -0,0 +1,151 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_INC_UNX_GTK_GTKSALMENU_HXX +#define INCLUDED_VCL_INC_UNX_GTK_GTKSALMENU_HXX + +#include <config_dbus.h> +#include <config_gio.h> + +#include <vector> +#if ENABLE_GIO +#include <gio/gio.h> +#endif + +#include <salmenu.hxx> +#include <unx/gtk/gtkframe.hxx> +#include <unotools/tempfile.hxx> +#include <vcl/idle.hxx> + +#include <unx/gtk/glomenu.h> +#include <unx/gtk/gloactiongroup.h> + +class MenuItemList; +class GtkSalMenuItem; + +class GtkSalMenu : public SalMenu +{ +private: + std::vector< GtkSalMenuItem* > maItems; + Idle maUpdateMenuBarIdle; + + bool mbInActivateCallback; + bool mbMenuBar; + bool mbNeedsUpdate; + bool mbReturnFocusToDocument; + bool mbAddedGrab; + /// Even setting null icon on a menuitem can be expensive, so cache state to avoid that call + bool mbHasNullItemIcon = true; + GtkWidget* mpMenuBarContainerWidget; + std::unique_ptr<utl::TempFile> mxPersonaImage; + BitmapEx maPersonaBitmap; + GtkWidget* mpMenuAllowShrinkWidget; + GtkWidget* mpMenuBarWidget; + GtkCssProvider* mpMenuBarContainerProvider; + GtkCssProvider* mpMenuBarProvider; + GtkWidget* mpCloseButton; + VclPtr<Menu> mpVCLMenu; + GtkSalMenu* mpParentSalMenu; + GtkSalFrame* mpFrame; + + // GMenuModel and GActionGroup attributes + GMenuModel* mpMenuModel; + GActionGroup* mpActionGroup; + + void ImplUpdate(bool bRecurse, bool bRemoveDisabledEntries); + void ActivateAllSubmenus(Menu* pMenuBar); + + DECL_LINK(MenuBarHierarchyChangeHandler, Timer*, void); + +public: + GtkSalMenu( bool bMenuBar ); + virtual ~GtkSalMenu() override; + + virtual bool VisibleMenuBar() override; // must return TRUE to actually DISPLAY native menu bars + // otherwise only menu messages are processed (eg, OLE on Windows) + + virtual void InsertItem( SalMenuItem* pSalMenuItem, unsigned nPos ) override; + virtual void RemoveItem( unsigned nPos ) override; + virtual void SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, unsigned nPos ) override; + virtual void SetFrame( const SalFrame* pFrame ) override; + const GtkSalFrame* GetFrame() const; + virtual void CheckItem( unsigned nPos, bool bCheck ) override; + virtual void EnableItem( unsigned nPos, bool bEnable ) override; + virtual void ShowItem( unsigned nPos, bool bShow ) override; + virtual void SetItemText( unsigned nPos, SalMenuItem* pSalMenuItem, const OUString& rText ) override; + virtual void SetItemImage( unsigned nPos, SalMenuItem* pSalMenuItem, const Image& rImage) override; + virtual void SetAccelerator( unsigned nPos, SalMenuItem* pSalMenuItem, const vcl::KeyCode& rKeyCode, const OUString& rKeyName ) override; + virtual void GetSystemMenuData( SystemMenuData* pData ) override; + + void SetMenu( Menu* pMenu ) { mpVCLMenu = pMenu; } + Menu* GetMenu() { return mpVCLMenu; } + void SetMenuModel(GMenuModel* pMenuModel); + unsigned GetItemCount() const { return maItems.size(); } + GtkSalMenuItem* GetItemAtPos( unsigned nPos ) { return maItems[ nPos ]; } + void SetActionGroup( GActionGroup* pActionGroup ) { mpActionGroup = pActionGroup; } + bool IsItemVisible( unsigned nPos ); + + void NativeSetItemText( unsigned nSection, unsigned nItemPos, const OUString& rText ); + void NativeSetItemIcon( unsigned nSection, unsigned nItemPos, const Image& rImage ); + bool NativeSetItemCommand( unsigned nSection, + unsigned nItemPos, + sal_uInt16 nId, + const gchar* aCommand, + MenuItemBits nBits, + bool bChecked, + bool bIsSubmenu ); + void NativeSetEnableItem( gchar const * aCommand, gboolean bEnable ); + void NativeCheckItem( unsigned nSection, unsigned nItemPos, MenuItemBits bits, gboolean bCheck ); + void NativeSetAccelerator( unsigned nSection, unsigned nItemPos, const vcl::KeyCode& rKeyCode, const OUString& rKeyName ); + + static void DispatchCommand(const gchar* pMenuCommand); + static void Activate(const gchar* pMenuCommand); + static void Deactivate(const gchar* pMenuCommand); + void EnableUnity(bool bEnable); + virtual void ShowMenuBar( bool bVisible ) override; + bool PrepUpdate(); + virtual void Update() override; // Update this menu only. + // Update full menu hierarchy from this menu. + void UpdateFull () { ActivateAllSubmenus(mpVCLMenu); Update(); } + // Clear ActionGroup and MenuModel from full menu hierarchy + void ClearActionGroupAndMenuModel(); + GtkSalMenu* GetTopLevel(); + void SetNeedsUpdate(); + + GtkWidget* GetMenuBarContainerWidget() const { return mpMenuBarContainerWidget; } + + void CreateMenuBarWidget(); + void DestroyMenuBarWidget(); + gboolean SignalKey(GdkEventKey const * pEvent); + void ReturnFocus(); + + virtual bool ShowNativePopupMenu(FloatingWindow * pWin, const tools::Rectangle& rRect, FloatWinPopupFlags nFlags) override; + virtual void ShowCloseButton(bool bShow) override; + virtual bool CanGetFocus() const override; + virtual bool TakeFocus() override; + virtual int GetMenuBarHeight() const override; + virtual void ApplyPersona() override; +}; + +class GtkSalMenuItem : public SalMenuItem +{ +public: + GtkSalMenuItem( const SalItemParams* ); + virtual ~GtkSalMenuItem() override; + + GtkSalMenu* mpParentMenu; // The menu into which this menu item is inserted + GtkSalMenu* mpSubMenu; // Submenu of this item (if defined) + MenuItemType mnType; // Item type + sal_uInt16 mnId; // Item ID + bool mbVisible; // Item visibility. +}; + +#endif // INCLUDED_VCL_INC_UNX_GTK_GTKSALMENU_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/gtk/gtksys.hxx b/vcl/inc/unx/gtk/gtksys.hxx new file mode 100644 index 000000000..8775f5af0 --- /dev/null +++ b/vcl/inc/unx/gtk/gtksys.hxx @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#ifndef INCLUDED_VCL_INC_UNX_GTK_GTKSYS_HXX +#define INCLUDED_VCL_INC_UNX_GTK_GTKSYS_HXX + +#include <unx/gensys.h> +#include <gtk/gtk.h> +#include <unx/saltype.h> +#include <deque> + +class GtkSalSystem final : public SalGenericSystem +{ + typedef std::deque<std::pair<GdkScreen*, int> > ScreenMonitors_t; + + GdkDisplay *mpDisplay; + // Number of monitors for every active screen. + ScreenMonitors_t maScreenMonitors; +public: + GtkSalSystem(); + virtual ~GtkSalSystem() override; + static GtkSalSystem *GetSingleton(); + + virtual bool IsUnifiedDisplay() override; + virtual unsigned int GetDisplayScreenCount() override; + virtual unsigned int GetDisplayBuiltInScreen() override; + virtual tools::Rectangle GetDisplayScreenPosSizePixel (unsigned int nScreen) override; + virtual int ShowNativeDialog (const OUString& rTitle, + const OUString& rMessage, + const std::vector< OUString >& rButtons) override; + SalX11Screen GetDisplayDefaultXScreen() + { return getXScreenFromDisplayScreen( GetDisplayBuiltInScreen() ); } + SalX11Screen getXScreenFromDisplayScreen(unsigned int nDisplayScreen); + void countScreenMonitors(); + // We have a 'screen' number that is combined from screen-idx + monitor-idx + int getScreenIdxFromPtr (GdkScreen *pScreen); + int getScreenMonitorIdx (GdkScreen *pScreen, int nX, int nY); + GdkScreen *getScreenMonitorFromIdx (int nIdx, gint &nMonitor); +}; + +#endif // INCLUDED_VCL_INC_UNX_GTK_GTKSYS_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/gtk/hudawareness.h b/vcl/inc/unx/gtk/hudawareness.h new file mode 100644 index 000000000..eb80e12fe --- /dev/null +++ b/vcl/inc/unx/gtk/hudawareness.h @@ -0,0 +1,32 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_INC_UNX_GTK_HUDAWARENESS_H +#define INCLUDED_VCL_INC_UNX_GTK_HUDAWARENESS_H + +#include <gio/gio.h> + +G_BEGIN_DECLS + +typedef void (* HudAwarenessCallback) (gboolean hud_active, + gpointer user_data); + +guint hud_awareness_register (GDBusConnection *connection, + const gchar *object_path, + HudAwarenessCallback callback, + gpointer user_data, + GDestroyNotify notify, + GError **error); + +void hud_awareness_unregister (GDBusConnection *connection, + guint awareness_id); + +G_END_DECLS + +#endif // INCLUDED_VCL_INC_UNX_GTK_HUDAWARENESS_H |