cef 3904 (#87)

This commit is contained in:
Oleg Korshul
2020-02-20 12:00:34 +03:00
committed by GitHub
parent f6e5f99f7c
commit 18dd80b81e
17 changed files with 194 additions and 141 deletions

File diff suppressed because one or more lines are too long

View File

@ -266,13 +266,13 @@
self.tabsControl = windowController.titlebarController.tabsControl;
// Create CEF event listener
[ASCEventsController sharedInstance];
[self setupTabControl];
[self createStartPage];
[self loadStartPage];
[self setupTouchBar];
// Create CEF event listener
[ASCEventsController sharedInstance];
// External handle
if (_externalDelegate && [_externalDelegate respondsToSelector:@selector(onMainWindowLoaded:)]) {

View File

@ -41,87 +41,7 @@
#import "NSCefView.h"
#import "NSString+Extensions.h"
#import "mac_application.h"
class CCefViewWrapper : public CCefViewWidgetImpl
{
public:
CCefViewWrapper(NSCefView* pView)
{
m_pParent = pView;
m_pCefView = NULL;
}
virtual ~CCefViewWrapper()
{
}
void SetBackgroundCefColor(unsigned char r, unsigned char g, unsigned char b)
{
}
CCefView* GetCefView()
{
return m_pCefView;
}
void Create(CAscApplicationManager* pManager, CefViewWrapperType eType);
public:
CCefView* m_pCefView;
NSCefView* m_pParent;
void focusInEvent()
{
if (NULL != m_pCefView)
m_pCefView->focus();
}
void resizeEvent()
{
if (NULL != m_pCefView)
m_pCefView->resizeEvent();
}
void moveEvent()
{
if (NULL != m_pCefView)
m_pCefView->moveEvent();
}
public:
// CCefViewWidgetImpl
virtual int parent_x()
{
//CGFloat koef = [[NSScreen mainScreen] backingScaleFactor];
CGFloat koef = 1;
return (int)(m_pParent.frame.origin.x * koef);
}
virtual int parent_y()
{
//CGFloat koef = [[NSScreen mainScreen] backingScaleFactor];
CGFloat koef = 1;
return (int)(m_pParent.frame.origin.y * koef);
}
virtual int parent_width()
{
//CGFloat koef = [[NSScreen mainScreen] backingScaleFactor];
CGFloat koef = 1;
return (int)(m_pParent.frame.size.width * koef);
}
virtual int parent_height()
{
//CGFloat koef = [[NSScreen mainScreen] backingScaleFactor];
CGFloat koef = 1;
return (int)(m_pParent.frame.size.height * koef);
}
virtual WindowHandleId parent_wid()
{
return (__bridge WindowHandleId)m_pParent;
}
virtual bool parent_window_is_empty()
{
return true;
}
};
#import "mac_cefview.h"
@interface NSCefView () {
CCefViewWrapper* m_pCefView;

Binary file not shown.

View File

@ -28,12 +28,10 @@ include($$CORE_ROOT_DIR/Common/base.pri)
INCLUDEPATH += \
$$BASEEDITORS_PATH/lib/include \
$$BASEEDITORS_PATH/lib/qcefview \
$$BASEEDITORS_PATH/lib/qt_wrapper/include \
$$CORE_ROOT_DIR/DesktopEditor
HEADERS += \
$$BASEEDITORS_PATH/lib/qcefview/qcefview.h \
$$BASEEDITORS_PATH/lib/qcefview/qcefview_media.h \
$$PWD/src/asctabwidget.h \
$$PWD/src/version.h \
$$PWD/src/defines.h \
@ -75,8 +73,6 @@ HEADERS += \
# src/casclabel.h
SOURCES += \
$$BASEEDITORS_PATH/lib/qcefview/qcefview.cpp \
$$BASEEDITORS_PATH/lib/qcefview/qcefview_media.cpp \
$$PWD/src/main.cpp \
$$PWD/src/asctabwidget.cpp\
$$PWD/src/cdownloadwidget.cpp \
@ -131,7 +127,7 @@ core_windows:LIBS += -L$$CORE_3DPARTY_PATH/cef/$$PLATFORM_BUILD/build -llibcef
core_linux:LIBS += -L$$CORE_3DPARTY_PATH/cef/$$PLATFORM_BUILD/build -lcef
# core
ADD_DEPENDENCY(PdfReader, PdfWriter, DjVuFile, XpsFile, HtmlRenderer, UnicodeConverter, hunspell, ooxmlsignature, kernel, graphics, videoplayer, ascdocumentscore)
ADD_DEPENDENCY(PdfReader, PdfWriter, DjVuFile, XpsFile, HtmlRenderer, UnicodeConverter, hunspell, ooxmlsignature, kernel, graphics, videoplayer, ascdocumentscore, qtascdocumentscore)
core_linux {
QT += network x11extras
@ -142,11 +138,13 @@ core_linux {
HEADERS += $$PWD/src/linux/cmainwindow.h \
$$PWD/src/linux/cx11decoration.h \
$$PWD/src/linux/gtk_addon.h \
$$PWD/src/linux/csinglewindow.h \
$$PWD/src/linux/csinglewindowplatform.h \
$$PWD/src/linux/singleapplication.h
SOURCES += $$PWD/src/linux/cmainwindow.cpp \
$$PWD/src/linux/cx11decoration.cpp \
$$PWD/src/linux/gtk_addon.cpp \
$$PWD/src/linux/cx11caption.cpp \
$$PWD/src/linux/csinglewindow.cpp \
$$PWD/src/linux/csinglewindowplatform.cpp \
@ -156,7 +154,7 @@ core_linux {
SOURCES += $$PWD/src/linux/cdialogopenssl.cpp
CONFIG += link_pkgconfig
PKGCONFIG += glib-2.0 gdk-2.0 atk cairo gtk+-unix-print-2.0
PKGCONFIG += glib-2.0 gtk+-3.0 atk
LIBS += -lX11
LIBS += $$CORE_3DPARTY_PATH/icu/$$PLATFORM_BUILD/build/libicuuc.so.58

View File

@ -855,9 +855,26 @@ void CAscTabWidget::setEditorOptions(int id, const wstring& option)
void CAscTabWidget::setFocusedView(int index)
{
if (!m_pMainWidget->isHidden())
{
if (!QCefView::IsSupportLayers())
{
if (this->currentWidget() && !this->currentWidget()->isHidden())
this->currentWidget()->hide();
}
return;
}
int nIndex = !(index < 0) ? index : currentIndex();
if (!(nIndex < 0 ))
{
if (!QCefView::IsSupportLayers())
{
if (this->currentWidget()->isHidden())
this->currentWidget()->show();
}
panel(nIndex)->cef()->focus();
}
}
void CAscTabWidget::activate(bool a)

View File

@ -1356,3 +1356,10 @@ QString CAscApplicationManagerWrapper::newFileName(int format)
default: return "Document.asc";
}
}
// external message loop
#include "qexternalmessageloop.h"
IExternalMessageLoop* CAscApplicationManagerWrapper::GetExternalMessageLoop()
{
return new QExternalMessageLoop(this);
}

View File

@ -120,6 +120,8 @@ private:
CEditorWindow * editorWindowFromViewId(int uid) const;
CEditorWindow * editorWindowFromUrl(const QString&) const;
virtual IExternalMessageLoop* GetExternalMessageLoop();
public:
static void bindReceiver(int view_id, CCefEventsGate * const receiver);
static void unbindReceiver(int view_id);

View File

@ -375,6 +375,11 @@ void CEditorWindow::recalculatePlaces()
windowH = m_pMainPanel->height(),
captionH = TITLE_HEIGHT * m_dpiRatio;
if (!QCefView::IsSupportLayers())
{
d_ptr->panel()->view()->SetCaptionMaskSize(TITLE_HEIGHT * m_dpiRatio);
}
// int contentH = windowH - captionH;
// if ( contentH < 1 ) contentH = 1;

View File

@ -42,6 +42,8 @@
#include <QList>
#include <QDebug>
#include "qcefview.h"
#if defined(_WIN32)
CFileDialogWrapper::CFileDialogWrapper(HWND hParentWnd) : QWinWidget(hParentWnd)
#else
@ -59,7 +61,17 @@ public:
{
if (parent)
{
m_pChild = new QWidget(parent);
if (QCefView::IsSupportLayers())
{
m_pChild = new QWidget(parent);
}
else
{
QWindow* win = new QWindow((QWindow*)NULL);
win->setOpacity(1);
m_pChild = QWidget::createWindowContainer(win, parent);
}
m_pChild->setGeometry(0, 0, parent->width(), parent->height());
m_pChild->setStyleSheet("background-color: rgba(255,0,0,0)");
m_pChild->setAttribute(Qt::WA_NoSystemBackground);

View File

@ -211,6 +211,7 @@ CMainPanel::CMainPanel(QWidget *parent, bool isCustomWindow, uchar dpi_ratio)
m_pMainWidget = (QWidget *)pMainWidget;
m_pTabs->m_pMainButton = m_pButtonMain;
m_pTabs->m_pMainWidget = m_pMainWidget;
// m_pMainWidget->setVisible(false);
@ -364,6 +365,7 @@ void CMainPanel::pushButtonMainClicked()
if (m_pTabs->isActive()) {
m_pTabs->activate(false);
m_pMainWidget->setHidden(false);
m_pTabs->setFocusedView();
((QCefView *)m_pMainWidget)->GetCefView()->focus();
onTabChanged(m_pTabs->currentIndex());
@ -377,12 +379,11 @@ void CMainPanel::toggleButtonMain(bool toggle, bool delay)
if ( state ) {
m_pTabs->activate(false);
m_pMainWidget->setHidden(false);
m_pTabs->setFocusedView();
((QCefView *)m_pMainWidget)->GetCefView()->focus();
} else {
m_pTabs->activate(true);
m_pMainWidget->setHidden(true);
m_pTabs->setFocusedView();
}
@ -951,12 +952,14 @@ void CMainPanel::loadStartPage()
{
GET_REGISTRY_USER(_reg_user);
QString data_path;
#if defined(QT_DEBUG)
QString data_path = _reg_user.value("startpage").value<QString>();
#else
QString data_path = qApp->applicationDirPath() + "/index.html";
data_path = _reg_user.value("startpage").value<QString>();
#endif
if (data_path.isEmpty())
data_path = qApp->applicationDirPath() + "/index.html";
QString additional = "?waitingloader=yes&lang=" + CLangater::getCurrentLangCode();
QString _portal = _reg_user.value("portal").value<QString>();

View File

@ -13,6 +13,14 @@ CMainWindowBase::CMainWindowBase()
int CMainWindowBase::attachEditor(QWidget * panel, int index)
{
CMainPanel * _pMainPanel = mainPanel();
if (!QCefView::IsSupportLayers())
{
CTabPanel * _panel = dynamic_cast<CTabPanel *>(panel);
if (_panel)
_panel->view()->SetCaptionMaskSize(0);
}
int _index = _pMainPanel->tabWidget()->insertPanel(panel, index);
if ( !(_index < 0) ) {
_pMainPanel->toggleButtonMain(false);

View File

@ -79,14 +79,12 @@ void CTabPanel::initAsEditor()
m_pViewer->hide();
#endif
m_pViewer->Create(&AscAppManager::getInstance(), cvwtEditor);
cef()->resizeEvent(width(), height());
m_pViewer->Create(&AscAppManager::getInstance(), cvwtEditor);
}
void CTabPanel::initAsSimple()
{
m_pViewer->Create(&AscAppManager::getInstance(), cvwtSimple);
cef()->resizeEvent(width(), height());
m_pViewer->Create(&AscAppManager::getInstance(), cvwtSimple);
}
void CTabPanel::openLocalFile(const std::wstring& path, int format)
@ -112,7 +110,6 @@ bool CTabPanel::openRecentFile(int id)
void CTabPanel::resizeEvent(QResizeEvent *event)
{
m_pViewer->resize(event->size());
cef()->resizeEvent(event->size().width(), event->size().height());
}
void CTabPanel::showEvent(QShowEvent *)
@ -131,7 +128,7 @@ void CTabPanel::paintEvent(QPaintEvent *)
void CTabPanel::timerEvent(QTimerEvent *)
{
if ( m_startSize == m_lastSize ) {
cef()->resizeEvent(m_lastSize.width(), m_lastSize.height());
cef()->resizeEvent();
QObject::killTimer(m_idTimerResize);
m_idTimerResize = 0;

View File

@ -170,7 +170,6 @@ QWidget * CSingleWindow::createMainPanel(bool custom, const QString& title, QWid
_cef_rect.setTopLeft(QPoint(_layout->margin() * m_dpiRatio * 2, (TOOLBTN_HEIGHT + _layout->margin() * 2) * m_dpiRatio));
_cef_rect.translate(-_layout->margin() * m_dpiRatio, -_layout->margin() * m_dpiRatio);
view->setGeometry(_cef_rect);
((QCefView *)view)->GetCefView()->resizeEvent(_cef_rect.width(), _cef_rect.height());
_layout->addWidget(view, 1);
return mainPanel;

View File

@ -38,7 +38,7 @@
#include "X11/Xlib.h"
#include "X11/cursorfont.h"
#include <gdk/gdkscreen.h>
#include "gtk_addon.h"
#define CUSTOM_BORDER_WIDTH 4
#define MOTION_TIMER_MS 500
@ -308,40 +308,7 @@ void CX11Decoration::setMaximized(bool bVal)
int CX11Decoration::devicePixelRatio()
{
GdkScreen* screen = gdk_screen_get_default();
if (screen)
{
double dScale = gdk_screen_get_resolution(screen);
if (dScale < 1)
return 1;
int wPx = gdk_screen_get_width(screen);
int hPx = gdk_screen_get_height(screen);
int wMm = gdk_screen_get_width_mm(screen);
int hMm = gdk_screen_get_height_mm(screen);
if (wMm < 1)
wMm = 1;
if (hMm < 1)
hMm = 1;
int nDpiX = (int)(0.5 + wPx * 25.4 / wMm);
int nDpiY = (int)(0.5 + hPx * 25.4 / hMm);
int nDpi = (nDpiX + nDpiY) >> 1;
if (nDpi < 10)
return 1;
dScale /= nDpi;
if (dScale < 1)
return 1;
else if (dScale > 2)
return 2;
else
return (int)(dScale + 0.49);
}
return 1;
return gtk_addon::devicePixelRatio();
}
int CX11Decoration::customWindowBorderWith()

View File

@ -0,0 +1,75 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "./gtk_addon.h"
#include <gtk/gtk.h>
namespace gtk_addon
{
int devicePixelRatio()
{
GdkScreen* screen = gdk_screen_get_default();
if (screen)
{
double dScale = gdk_screen_get_resolution(screen);
if (dScale < 1)
return 1;
int wPx = gdk_screen_get_width(screen);
int hPx = gdk_screen_get_height(screen);
int wMm = gdk_screen_get_width_mm(screen);
int hMm = gdk_screen_get_height_mm(screen);
if (wMm < 1)
wMm = 1;
if (hMm < 1)
hMm = 1;
int nDpiX = (int)(0.5 + wPx * 25.4 / wMm);
int nDpiY = (int)(0.5 + hPx * 25.4 / hMm);
int nDpi = (nDpiX + nDpiY) >> 1;
if (nDpi < 10)
return 1;
dScale /= nDpi;
if (dScale < 1)
return 1;
else if (dScale > 2)
return 2;
else
return (int)(dScale + 0.49);
}
return 1;
}
}

View File

@ -0,0 +1,41 @@
/*
* (c) Copyright Ascensio System SIA 2010-2019
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef GTK_ADDON_H
#define GTK_ADDON_H
namespace gtk_addon
{
int devicePixelRatio();
}
#endif // GTK_ADDON_H