Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ChromiumBasedEditors/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ list(APPEND ASCDOCUMENTSCORE_HEADERS
"${CEF_SRC_PATH}/include/base/cef_atomic_flag.h"
"${CEF_SRC_PATH}/include/base/cef_atomic_ref_count.h"
"${CEF_SRC_PATH}/include/base/cef_auto_reset.h"
"${CEF_SRC_PATH}/include/base/cef_basictypes.h"
"${CEF_SRC_PATH}/include/base/cef_bind.h"
"${CEF_SRC_PATH}/include/base/cef_build.h"
"${CEF_SRC_PATH}/include/base/cef_callback.h"
Expand All @@ -295,7 +294,6 @@ list(APPEND ASCDOCUMENTSCORE_HEADERS
"${CEF_SRC_PATH}/include/base/cef_ptr_util.h"
"${CEF_SRC_PATH}/include/base/cef_ref_counted.h"
"${CEF_SRC_PATH}/include/base/cef_scoped_refptr.h"
"${CEF_SRC_PATH}/include/base/cef_template_util.h"
"${CEF_SRC_PATH}/include/base/cef_thread_checker.h"
"${CEF_SRC_PATH}/include/base/cef_trace_event.h"
"${CEF_SRC_PATH}/include/base/cef_tuple.h"
Expand Down Expand Up @@ -496,6 +494,7 @@ list(APPEND ASCDOCUMENTSCORE_HEADERS
"${CEF_SRC_PATH}/include/cef_xml_reader.h"
"${CEF_SRC_PATH}/include/cef_zip_reader.h"
"${CEF_SRC_PATH}/include/internal/cef_export.h"
"${CEF_SRC_PATH}/include/internal/cef_linux.h"
"${CEF_SRC_PATH}/include/internal/cef_logging_internal.h"
"${CEF_SRC_PATH}/include/internal/cef_ptr.h"
"${CEF_SRC_PATH}/include/internal/cef_string.h"
Expand All @@ -510,6 +509,7 @@ list(APPEND ASCDOCUMENTSCORE_HEADERS
"${CEF_SRC_PATH}/include/internal/cef_trace_event_internal.h"
"${CEF_SRC_PATH}/include/internal/cef_types.h"
"${CEF_SRC_PATH}/include/internal/cef_types_geometry.h"
"${CEF_SRC_PATH}/include/internal/cef_types_linux.h"
"${CEF_SRC_PATH}/include/internal/cef_types_wrappers.h"
"${CEF_SRC_PATH}/include/test/cef_test_helpers.h"
"${CEF_SRC_PATH}/include/test/cef_test_server.h"
Expand Down
14 changes: 14 additions & 0 deletions ChromiumBasedEditors/lib/include/cefview.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ class CCefViewWidgetImpl
virtual void OnLoaded() {}
virtual void OnRelease() {}

virtual double GetDeviceScaleFactor() { return 1.0; }
virtual bool IsWayland() { return false; }

// Returns the widget's top-left position in screen device (pixel) coordinates.
// Used by CEF's GetScreenPoint to map view DIPs to screen pixels.
virtual void GetWidgetScreenPosition(int& screenX, int& screenY) { screenX = 0; screenY = 0; }

virtual void OnPaint(const void* buffer, int width, int height) {}

static void SetParentNull(WindowHandleId handle);
};

Expand Down Expand Up @@ -148,6 +157,11 @@ class DESKTOP_DECL CCefView

void ExecuteInAllFrames(const std::string& sCode, const bool& isMain = true);

void SendMouseClickEvent(int x, int y, int button, bool mouseUp, int modifiers, int clickCount);
void SendMouseMoveEvent(int x, int y, bool mouseLeave, int modifiers);
void SendMouseWheelEvent(int x, int y, int deltaX, int deltaY, int modifiers);
void SendKeyEvent(int type, int key, int modifiers, const std::wstring& character);

protected:
int m_nId;
CefViewWrapperType m_eWrapperType;
Expand Down
8 changes: 7 additions & 1 deletion ChromiumBasedEditors/lib/qt_wrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ if(NOT TARGET videoplayerlib)
add_subdirectory(${PWD_ROOT_DIR}/../../videoplayerlib videoplayerlib)
endif()

# QOpenGLWidget (Wayland OSR presenter) lives in the OpenGLWidgets module, which
# common.cmake's find_package does not request. Pull it in here so this stays
# self-contained within desktop-sdk (the only submodule the build resets).
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS OpenGLWidgets)

# --- Main Target ---
add_library(qtascdocumentscore SHARED)

Expand Down Expand Up @@ -72,6 +77,7 @@ target_link_libraries(qtascdocumentscore PRIVATE
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Multimedia
Qt${QT_VERSION_MAJOR}::MultimediaWidgets
Qt${QT_VERSION_MAJOR}::OpenGLWidgets
# Internal Dependencies
kernel
graphics
Expand All @@ -89,7 +95,7 @@ if(UNIX AND NOT APPLE)
target_compile_definitions(qtascdocumentscore PRIVATE _LINUX LINUX OS_LINUX _X11)

# Qt6 Linux handling
target_link_libraries(qtascdocumentscore PRIVATE Qt${QT_VERSION_MAJOR}::GuiPrivate)
target_link_libraries(qtascdocumentscore PRIVATE Qt${QT_VERSION_MAJOR}::Gui)

#target_link_options(qtascdocumentscore PRIVATE "-Wl,-unresolved-symbols=ignore-in-shared-libs")

Expand Down
71 changes: 71 additions & 0 deletions ChromiumBasedEditors/lib/qt_wrapper/include/qcefview.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,42 @@
#include <QDebug>
#include <QPointer>

#include <QImage>
#include <QGuiApplication>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QKeyEvent>
#include <QAtomicInt>
#include <QList>
#include <QOpenGLWidget>


#include "./../../include/cefview.h"
#include "./../../include/applicationmanager.h"

class QCefViewProps;

// Wayland-only presenter for the CEF off-screen buffer. Rendering through a GL
// surface makes the swap itself the wl_surface_commit, which participates in
// the compositor's frame-callback / vsync loop natively -- so the raster
// backing-store "commit never completes until input" deadlock cannot occur.
// It is a mouse-transparent, non-focusable child that fully overlays its
// QCefView parent; all input continues to be handled by QCefView.
class QCefGLWidget : public QOpenGLWidget
{
Q_OBJECT
public:
explicit QCefGLWidget(QWidget* parent);
// Stage a new frame (deep-copied by the caller) and schedule a GL repaint.
void SetFrame(const QImage& image);

protected:
virtual void paintGL() override;

private:
QImage m_frame;
};

class DESKTOP_DECL QCefView : public QWidget, public CCefViewWidgetImpl
{
Q_OBJECT
Expand All @@ -56,6 +88,16 @@ class DESKTOP_DECL QCefView : public QWidget, public CCefViewWidgetImpl
virtual void resizeEvent(QResizeEvent* e);
virtual void moveEvent(QMoveEvent* e);

// input events for OSR
virtual void mousePressEvent(QMouseEvent *event) override;
virtual void mouseReleaseEvent(QMouseEvent *event) override;
virtual void mouseMoveEvent(QMouseEvent *event) override;
virtual void wheelEvent(QWheelEvent *event) override;
virtual void keyPressEvent(QKeyEvent *event) override;
virtual void keyReleaseEvent(QKeyEvent *event) override;
virtual void inputMethodEvent(QInputMethodEvent *event) override;
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;

// drag'n'drop
#if defined (_LINUX) && !defined(_MAC)
virtual void dragEnterEvent(QDragEnterEvent *e);
Expand Down Expand Up @@ -93,6 +135,18 @@ class DESKTOP_DECL QCefView : public QWidget, public CCefViewWidgetImpl
void SetBackgroundCefColor(unsigned char r, unsigned char g, unsigned char b);
void paintEvent(QPaintEvent *event);

virtual double GetDeviceScaleFactor() override;
virtual bool IsWayland() override;
virtual void OnPaint(const void* buffer, int width, int height) override;
virtual void GetWidgetScreenPosition(int& screenX, int& screenY) override;

// Wayland: called from the external message loop poller (top of loop,
// non-reentrant) after CEF is pumped. Repaints any view whose OnPaint
// staged a new frame and drives the frame-callback handshake so the
// commit is synchronized to the compositor. Must never be called from
// inside a CEF callback (e.g. OnPaint).
static void FlushDirtyWaylandViews();

// check support z-index
static bool IsSupportLayers();
void SetCaptionMaskSize(int);
Expand All @@ -105,6 +159,21 @@ class DESKTOP_DECL QCefView : public QWidget, public CCefViewWidgetImpl
CCefView* m_pCefView;
QPointer<QWidget> m_pOverride;
QCefViewProps* m_pProperties;

QImage m_imageBuffer;
bool m_isWayland;

// Wayland: GL presenter overlaying this view (see QCefGLWidget). null on
// other platforms and until Init() runs.
QCefGLWidget* m_pGLView = nullptr;

// Set by OnPaint when a new frame is staged; cleared by the poller.
QAtomicInt m_dirty;

// Registry of live Wayland views, so the message-loop poller can find
// dirty views to drive the frame-callback handshake. Populated only on
// Wayland; single-threaded access (main/UI thread).
static QList<QCefView*> s_waylandViews;

void Init();

Expand All @@ -113,9 +182,11 @@ class DESKTOP_DECL QCefView : public QWidget, public CCefViewWidgetImpl
void _loaded();
void _closed();


protected Q_SLOTS:
void _loadedSlot();
void _closedSlot();

};

#if defined (_LINUX) && !defined(_MAC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public Q_SLOTS:

private:
QTimer m_timer;
QTimer* m_wayland_poller = nullptr;
CAscApplicationManager* m_manager;
};

Expand Down
2 changes: 1 addition & 1 deletion ChromiumBasedEditors/lib/qt_wrapper/qtascdocumentscore.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
QT += core gui printsupport widgets
QT += core gui printsupport widgets openglwidgets

TARGET = qtascdocumentscore
TEMPLATE = lib
Expand Down
Loading