mirror of
https://github.com/ONLYOFFICE/desktop-apps.git
synced 2026-02-10 18:05:16 +08:00
Merge branch 'release/v7.3.0' into develop
This commit is contained in:
@ -207,7 +207,8 @@ core_linux {
|
||||
$$PWD/src/platform_linux/gtkfilechooser.h \
|
||||
$$PWD/src/platform_linux/gtkprintdialog.h \
|
||||
$$PWD/src/platform_linux/gtkmessage.h \
|
||||
$$PWD/src/platform_linux/gtkutils.h
|
||||
$$PWD/src/platform_linux/gtkutils.h \
|
||||
$$PWD/src/platform_linux/xcbutils.h
|
||||
|
||||
SOURCES += $$PWD/src/windows/platform_linux/cx11decoration.cpp \
|
||||
#$$PWD/src/windows/platform_linux/gtk_addon.cpp \
|
||||
@ -220,7 +221,8 @@ core_linux {
|
||||
$$PWD/src/platform_linux/gtkfilechooser.cpp \
|
||||
$$PWD/src/platform_linux/gtkprintdialog.cpp \
|
||||
$$PWD/src/platform_linux/gtkmessage.cpp \
|
||||
$$PWD/src/platform_linux/gtkutils.cpp
|
||||
$$PWD/src/platform_linux/gtkutils.cpp \
|
||||
$$PWD/src/platform_linux/xcbutils.cpp
|
||||
|
||||
CONFIG += link_pkgconfig
|
||||
PKGCONFIG += glib-2.0 gtk+-3.0 atk dbus-1 gtk+-unix-print-3.0 xcb
|
||||
|
||||
@ -1124,7 +1124,6 @@ void CAscTabWidget::setFullScreen(bool apply, int id)
|
||||
|
||||
RELEASEOBJECT(m_dataFullScreen->parent)
|
||||
RELEASEOBJECT(m_dataFullScreen)
|
||||
fsWidget->cef()->focus();
|
||||
// updateGeometry();
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -31,27 +31,16 @@
|
||||
*/
|
||||
|
||||
#include "gtkutils.h"
|
||||
#include <QWidget>
|
||||
#include <QApplication>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <xcb/xcb.h>
|
||||
#include <X11/Xlib-xcb.h>
|
||||
#include "platform_linux/xcbutils.h"
|
||||
|
||||
|
||||
gboolean set_focus(GtkWidget *dialog)
|
||||
{
|
||||
Display *disp = NULL;
|
||||
disp = XOpenDisplay(NULL);
|
||||
if (disp) {
|
||||
xcb_connection_t *conn = NULL;
|
||||
conn = XGetXCBConnection(disp);
|
||||
GdkWindow *gdk_dialog = gtk_widget_get_window(dialog);
|
||||
if (conn && gdk_dialog) {
|
||||
xcb_window_t wnd = (xcb_window_t)gdk_x11_window_get_xid(gdk_dialog);
|
||||
if (wnd != 0L)
|
||||
xcb_set_input_focus(conn, XCB_INPUT_FOCUS_PARENT, wnd, XCB_CURRENT_TIME);
|
||||
}
|
||||
XCloseDisplay(disp);
|
||||
GdkWindow *gdk_dialog = gtk_widget_get_window(dialog);
|
||||
if (gdk_dialog) {
|
||||
xcb_window_t wnd = (xcb_window_t)gdk_x11_window_get_xid(gdk_dialog);
|
||||
XcbUtils::setNativeFocusTo(wnd);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
@ -61,9 +50,8 @@ gboolean focus_out(gpointer data)
|
||||
if (data) {
|
||||
DialogTag *tag = (DialogTag*)data;
|
||||
GtkWidget *dialog = tag->dialog;
|
||||
WId parent_xid = (WId)tag->parent_xid;
|
||||
auto *focused_wgt = QApplication::activeWindow();
|
||||
if (dialog && focused_wgt && focused_wgt->winId() == parent_xid)
|
||||
xcb_window_t parent_xid = (xcb_window_t)tag->parent_xid;
|
||||
if (dialog && XcbUtils::isNativeFocus(parent_xid))
|
||||
set_focus(dialog);
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
151
win-linux/src/platform_linux/xcbutils.cpp
Normal file
151
win-linux/src/platform_linux/xcbutils.cpp
Normal file
@ -0,0 +1,151 @@
|
||||
/*
|
||||
* (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 "xcbutils.h"
|
||||
#include <QtConcurrent/QtConcurrent>
|
||||
#include <QX11Info>
|
||||
#include <thread>
|
||||
#include <stdlib.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xlib-xcb.h>
|
||||
|
||||
|
||||
bool XcbUtils::isNativeFocus(xcb_window_t window)
|
||||
{
|
||||
xcb_window_t win = 0;
|
||||
xcb_connection_t *conn = QX11Info::connection();
|
||||
if (conn) {
|
||||
xcb_get_input_focus_cookie_t cookie;
|
||||
xcb_get_input_focus_reply_t *reply;
|
||||
cookie = xcb_get_input_focus(conn);
|
||||
reply = xcb_get_input_focus_reply(conn, cookie, NULL);
|
||||
if (reply) {
|
||||
win = reply->focus;
|
||||
free(reply);
|
||||
}
|
||||
xcb_flush(conn);
|
||||
}
|
||||
return window == win;
|
||||
}
|
||||
|
||||
void XcbUtils::setNativeFocusTo(xcb_window_t window)
|
||||
{
|
||||
xcb_connection_t *conn = QX11Info::connection();
|
||||
if (conn && window != XCB_WINDOW_NONE) {
|
||||
xcb_void_cookie_t cookie;
|
||||
cookie = xcb_set_input_focus(conn, XCB_INPUT_FOCUS_PARENT,
|
||||
window, XCB_CURRENT_TIME);
|
||||
xcb_flush(conn);
|
||||
}
|
||||
}
|
||||
|
||||
static void GetWindowName(Display* disp, Window win, char **name) {
|
||||
XClassHint* class_hint = NULL;
|
||||
class_hint = XAllocClassHint();
|
||||
if (class_hint) {
|
||||
Status s = XGetClassHint(disp, win, class_hint);
|
||||
if (s == 1)
|
||||
*name = strdup(class_hint->res_name);
|
||||
XFree(class_hint);
|
||||
}
|
||||
}
|
||||
|
||||
static void GetWindowList(Display *disp, Window **list, unsigned long *len) {
|
||||
int form;
|
||||
unsigned long remain;
|
||||
unsigned char *win_list;
|
||||
Atom type;
|
||||
Atom prop = XInternAtom(disp, "_NET_CLIENT_LIST", true);
|
||||
Window root = XDefaultRootWindow(disp);
|
||||
int res = XGetWindowProperty(disp, root, prop, 0, 1024, false, XA_WINDOW,
|
||||
&type, &form, len, &remain, &win_list);
|
||||
if (res == Success)
|
||||
*list = (Window*)win_list;
|
||||
}
|
||||
|
||||
static bool IsVisible(Display *disp, Window wnd)
|
||||
{
|
||||
xcb_connection_t *conn = XGetXCBConnection(disp);
|
||||
if (conn) {
|
||||
xcb_get_window_attributes_cookie_t cookie;
|
||||
xcb_get_window_attributes_reply_t *reply;
|
||||
cookie = xcb_get_window_attributes(conn, wnd);
|
||||
reply = xcb_get_window_attributes_reply(conn, cookie, NULL);
|
||||
if (reply) {
|
||||
uint8_t state = reply->map_state;
|
||||
free(reply);
|
||||
if (state == XCB_MAP_STATE_VIEWABLE)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void XcbUtils::findWindowAsync(const char *window_name,
|
||||
uint timeout_ms,
|
||||
void(*callback)(xcb_window_t))
|
||||
{
|
||||
QtConcurrent::run([=]() {
|
||||
Display *disp = XOpenDisplay(NULL);
|
||||
if (!disp)
|
||||
return;
|
||||
int DELAY_MS = 50;
|
||||
int RETRIES = (int)((float)timeout_ms / DELAY_MS);
|
||||
Window win_found = None;
|
||||
do {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(DELAY_MS));
|
||||
Window *win_list = NULL;
|
||||
unsigned long win_list_size = 0;
|
||||
GetWindowList(disp, &win_list, &win_list_size);
|
||||
for (int i = 0; i < (int)win_list_size; i++) {
|
||||
char *name = NULL;
|
||||
GetWindowName(disp, win_list[i], &name);
|
||||
if (name) {
|
||||
if (strstr(name, window_name) != NULL) {
|
||||
if (IsVisible(disp, win_list[i])) {
|
||||
win_found = win_list[i];
|
||||
callback((xcb_window_t)win_found);
|
||||
}
|
||||
free(name);
|
||||
break;
|
||||
}
|
||||
free(name);
|
||||
}
|
||||
}
|
||||
if (win_list)
|
||||
XFree(win_list);
|
||||
} while (--RETRIES > 0 && win_found == None);
|
||||
XCloseDisplay(disp);
|
||||
});
|
||||
}
|
||||
48
win-linux/src/platform_linux/xcbutils.h
Normal file
48
win-linux/src/platform_linux/xcbutils.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* (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 XCBUTILS_H
|
||||
#define XCBUTILS_H
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
|
||||
namespace XcbUtils
|
||||
{
|
||||
void setNativeFocusTo(xcb_window_t window);
|
||||
bool isNativeFocus(xcb_window_t window);
|
||||
void findWindowAsync(const char *window_name,
|
||||
uint timeout_ms,
|
||||
void(*callback)(xcb_window_t));
|
||||
}
|
||||
|
||||
#endif // XCBUTILS_H
|
||||
@ -1,5 +1,6 @@
|
||||
#define _GNU_SOURCE 1
|
||||
#include "xdgdesktopportal.h"
|
||||
#include "platform_linux/xcbutils.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
@ -12,8 +13,6 @@
|
||||
#include <sys/syscall.h>
|
||||
#include <linux/random.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#if defined(__x86_64__)
|
||||
# define GETRANDOM_NR 318
|
||||
@ -81,7 +80,6 @@ typedef struct {
|
||||
const char* pattern;
|
||||
} FilterItem;
|
||||
|
||||
Bool xerror = False;
|
||||
|
||||
Result initDBus(void);
|
||||
Result openDialog(Window parent, Xdg::Mode mode, const char* title,
|
||||
@ -233,15 +231,20 @@ void setFilter(DBusMessageIter &msg_iter, const FilterItem &filterItem) {
|
||||
__dbusOpen(&msg_iter, DBUS_TYPE_STRUCT, nullptr, &struct_iter);
|
||||
// add filter name
|
||||
__dbusAppend(&struct_iter, DBUS_TYPE_STRING, &filterItem.name);
|
||||
|
||||
// add filter extentions
|
||||
__dbusOpen(&struct_iter, DBUS_TYPE_ARRAY, "(us)", &array_iter);
|
||||
__dbusOpen(&array_iter, DBUS_TYPE_STRUCT, nullptr, &array_struct_iter);
|
||||
{
|
||||
const unsigned nil = 0;
|
||||
__dbusAppend(&array_struct_iter, DBUS_TYPE_UINT32, &nil);
|
||||
const QString patterns = QString::fromUtf8(filterItem.pattern);
|
||||
foreach (auto &pattern, patterns.split(' ')) {
|
||||
__dbusOpen(&array_iter, DBUS_TYPE_STRUCT, nullptr, &array_struct_iter);
|
||||
{
|
||||
const unsigned nil = 0;
|
||||
__dbusAppend(&array_struct_iter, DBUS_TYPE_UINT32, &nil);
|
||||
}
|
||||
char *ptrn = pattern.toUtf8().data();
|
||||
__dbusAppend(&array_struct_iter, DBUS_TYPE_STRING, &ptrn);
|
||||
__dbusClose(&array_iter, &array_struct_iter);
|
||||
}
|
||||
__dbusAppend(&array_struct_iter, DBUS_TYPE_STRING, &filterItem.pattern);
|
||||
__dbusClose(&array_iter, &array_struct_iter);
|
||||
__dbusClose(&struct_iter, &array_iter);
|
||||
__dbusClose(&msg_iter, &struct_iter);
|
||||
}
|
||||
@ -1129,7 +1132,7 @@ QStringList Xdg::openXdgPortal(QWidget *parent,
|
||||
const QString &title,
|
||||
const QString &file_name,
|
||||
const QString &path,
|
||||
const QString &filter,
|
||||
QString filter,
|
||||
QString *sel_filter,
|
||||
bool sel_multiple)
|
||||
{
|
||||
@ -1143,6 +1146,7 @@ QStringList Xdg::openXdgPortal(QWidget *parent,
|
||||
const QString _path = (path.isEmpty() && pos != -1) ?
|
||||
file_name.mid(0, pos) : path;
|
||||
|
||||
filter.replace("/", " \u2044 ");
|
||||
QStringList filterList = filter.split(";;");
|
||||
int filterSize = filterList.size();
|
||||
FilterItem filterItem[filterSize];
|
||||
@ -1176,6 +1180,9 @@ QStringList Xdg::openXdgPortal(QWidget *parent,
|
||||
}
|
||||
|
||||
char* outPaths;
|
||||
XcbUtils::findWindowAsync("xdg-desktop-portal",
|
||||
3000,
|
||||
XcbUtils::setNativeFocusTo);
|
||||
Result result;
|
||||
result = openDialog(parentWid, mode, title.toUtf8().data(),
|
||||
&outPaths,
|
||||
|
||||
@ -18,7 +18,7 @@ QStringList openXdgPortal(QWidget *parent,
|
||||
const QString &title,
|
||||
const QString &file_name,
|
||||
const QString &path,
|
||||
const QString &filter,
|
||||
QString filter,
|
||||
QString *sel_filter,
|
||||
bool sel_multiple = false);
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ void CMainWindowImpl::refreshAboutVersion()
|
||||
})
|
||||
);
|
||||
|
||||
if ( !AscAppManager::IsUseSystemScaling() ) {
|
||||
// if ( !AscAppManager::IsUseSystemScaling() ) {
|
||||
std::wstring _force_value = AscAppManager::userSettings(L"force-scale");
|
||||
if ( _force_value == L"1" )
|
||||
_json_obj["uiscaling"] = 100;
|
||||
@ -97,7 +97,7 @@ void CMainWindowImpl::refreshAboutVersion()
|
||||
if ( _force_value == L"2" )
|
||||
_json_obj["uiscaling"] = 200;
|
||||
else _json_obj["uiscaling"] = 0;
|
||||
}
|
||||
// }
|
||||
|
||||
#ifndef __OS_WIN_XP
|
||||
_json_obj["uitheme"] = QString::fromStdWString(AscAppManager::themes().current().id());
|
||||
|
||||
@ -258,10 +258,11 @@ QWidget * CEditorWindow::createMainPanel(QWidget * parent, const QString& title)
|
||||
if (d_ptr->panel()->data()->contentType() != etUndefined)
|
||||
mainPanel->setProperty("window", "pretty");
|
||||
_canExtendTitle = true;
|
||||
if (d_ptr->usedOldEditorVersion) // For old editors only
|
||||
static_cast<QHBoxLayout*>(m_boxTitleBtns->layout())->insertWidget(3, d_ptr.get()->iconUser());
|
||||
else
|
||||
static_cast<QHBoxLayout*>(m_boxTitleBtns->layout())->insertWidget(2, d_ptr.get()->iconUser());
|
||||
int pos = (d_ptr->usedOldEditorVersion) ? 3 : 2; // For old editors only
|
||||
auto *pIconSpacer = new QSpacerItem(9, 5, QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
auto *pTopLayout = static_cast<QHBoxLayout*>(m_boxTitleBtns->layout());
|
||||
pTopLayout->insertWidget(pos, d_ptr->iconUser());
|
||||
pTopLayout->insertSpacerItem(pos + 1, pIconSpacer);
|
||||
}
|
||||
|
||||
d_ptr->customizeTitleLabel();
|
||||
@ -370,6 +371,8 @@ void CEditorWindow::onExitSizeMove()
|
||||
m_restoreMaximized = false;
|
||||
CWindowPlatform::show(true);
|
||||
}
|
||||
if (!isActiveWindow())
|
||||
activateWindow();
|
||||
}
|
||||
|
||||
void CEditorWindow::captureMouse()
|
||||
@ -479,11 +482,6 @@ void CEditorWindow::setScreenScalingFactor(double factor)
|
||||
d_ptr.get()->onScreenScalingFactor(factor);
|
||||
recalculatePlaces();
|
||||
updateTitleCaption();
|
||||
#ifdef _WIN32
|
||||
QTimer::singleShot(50, this, [=]() { // Fix bug with window colors on scaling
|
||||
d_ptr->setWindowColors();
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
void CEditorWindow::onClickButtonHome()
|
||||
|
||||
@ -143,7 +143,7 @@ auto editor_color(int type) -> QColor {
|
||||
class CEditorWindowPrivate : public CCefEventsGate
|
||||
{
|
||||
CEditorWindow * window = nullptr;
|
||||
CElipsisLabel * iconuser = nullptr;
|
||||
QLabel * iconuser = nullptr;
|
||||
QPushButton * btndock = nullptr;
|
||||
bool isPrinting = false,
|
||||
isFullScreen = false;
|
||||
@ -234,6 +234,20 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
auto getInitials(const QString &name) -> QString {
|
||||
auto fio = name.split(' ');
|
||||
QString initials = (!fio[0].isEmpty()) ?
|
||||
fio[0].mid(0, 1).toUpper() : "";
|
||||
for (int i = fio.size() - 1; i > 0; i--) {
|
||||
if (!fio[i].isEmpty() && fio[i].at(0) != '('
|
||||
&& fio[i].at(0) != ')') {
|
||||
initials += fio[i].mid(0, 1).toUpper();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return initials;
|
||||
}
|
||||
|
||||
void onEditorConfig(int, std::wstring cfg) override
|
||||
{
|
||||
// if ( id == window->holdView(id) )
|
||||
@ -252,9 +266,8 @@ public:
|
||||
if ( objRoot.contains("user") ) {
|
||||
QString _user_name = objRoot["user"].toObject().value("name").toString();
|
||||
iconUser()->setToolTip(_user_name);
|
||||
iconuser->setText(_user_name);
|
||||
|
||||
iconuser->adjustSize();
|
||||
adjustIconUser();
|
||||
iconuser->setText(getInitials(_user_name));
|
||||
_user_width = iconuser->width();
|
||||
}
|
||||
|
||||
@ -599,10 +612,7 @@ public:
|
||||
int diffW = int((titleLeftOffset - (TOOLBTN_WIDTH * _btncount)) * f); // 4 tool buttons: min+max+close+usericon
|
||||
|
||||
if ( iconuser ) {
|
||||
iconuser->setMaximumWidth(int(200 * f));
|
||||
iconuser->setContentsMargins(int(12*f),0,int(12*f),int(2*f));
|
||||
iconuser->setMaximumWidth(int(200*f));
|
||||
iconuser->adjustSize();
|
||||
adjustIconUser();
|
||||
if (!viewerMode())
|
||||
diffW -= iconuser->width();
|
||||
}
|
||||
@ -720,17 +730,25 @@ public:
|
||||
{
|
||||
Q_ASSERT(window->m_boxTitleBtns != nullptr);
|
||||
if ( !iconuser ) {
|
||||
iconuser = new CElipsisLabel(window->m_boxTitleBtns);
|
||||
iconuser = new QLabel(window->m_boxTitleBtns);
|
||||
iconuser->setObjectName("iconuser");
|
||||
iconuser->setContentsMargins(0,0,0,int(2 * window->m_dpiRatio));
|
||||
iconuser->setMaximumWidth(int(200 * window->m_dpiRatio));
|
||||
// iconuser->setPixmap(window->m_dpiRatio > 1 ? QPixmap(":/user_2x.png") : QPixmap(":/user.png"));
|
||||
// iconuser->setFixedSize(QSize(TOOLBTN_WIDTH*window->m_dpiRatio,16*window->m_dpiRatio));
|
||||
iconuser->setContentsMargins(0,0,0,0);
|
||||
iconuser->setAlignment(Qt::AlignCenter);
|
||||
}
|
||||
|
||||
return iconuser;
|
||||
}
|
||||
|
||||
void adjustIconUser()
|
||||
{
|
||||
iconuser->setFixedHeight(0.85 * TOOLBTN_HEIGHT * window->m_dpiRatio);
|
||||
iconuser->setFixedWidth(iconuser->height());
|
||||
auto iconTextColor = editor_color(panel()->data()->contentType()).name();
|
||||
iconuser->setStyleSheet(QString("QLabel#iconuser "
|
||||
"{background: #d9ffffff; border-radius: %1px; color: %2;}")
|
||||
.arg(QString::number(iconuser->height()/2), iconTextColor));
|
||||
}
|
||||
|
||||
QLabel * iconCrypted()
|
||||
{
|
||||
Q_ASSERT(window->m_boxTitleBtns != nullptr);
|
||||
|
||||
@ -1196,6 +1196,8 @@ void CMainWindow::onFullScreen(int id, bool apply)
|
||||
if (isHidden()) {
|
||||
m_pTabs->setFullScreen(apply);
|
||||
toggleButtonMain(false);
|
||||
QCoreApplication::processEvents();
|
||||
focus();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1340,11 +1342,6 @@ void CMainWindow::setScreenScalingFactor(double factor)
|
||||
}
|
||||
updateScalingFactor(factor);
|
||||
CScalingWrapper::updateChildScaling(m_pMainPanel, factor);
|
||||
#ifdef _WIN32
|
||||
QTimer::singleShot(50, this, [=]() { // Fix bug with window colors on scaling
|
||||
CWindowBase::applyTheme(L"");
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
QString CMainWindow::getSaveMessage() const
|
||||
|
||||
@ -123,15 +123,12 @@ void CWindowBase::updateScaling()
|
||||
void CWindowBase::setWindowColors(const QColor& background, const QColor& border)
|
||||
{
|
||||
Q_UNUSED(border)
|
||||
QPalette pal = palette();
|
||||
pal.setColor(QPalette::Window, background);
|
||||
setStyleSheet(QString("QMainWindow{border:1px solid %1;"
|
||||
#ifdef _WIN32
|
||||
"border-bottom:2px solid %1;"
|
||||
#endif
|
||||
"}").arg(border.name()));
|
||||
setAutoFillBackground(true);
|
||||
setPalette(pal);
|
||||
"background-color: %2;"
|
||||
"}").arg(border.name(), background.name()));
|
||||
}
|
||||
|
||||
void CWindowBase::applyTheme(const std::wstring& theme)
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
#include "defines.h"
|
||||
#include "utils.h"
|
||||
#include <QTimer>
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
#ifdef DOCUMENTSCORE_OPENSSL_SUPPORT
|
||||
# include "platform_linux/cdialogopenssl.h"
|
||||
@ -49,6 +49,7 @@ CWindowPlatform::CWindowPlatform(const QRect &rect) :
|
||||
if (isCustomWindowStyle())
|
||||
CX11Decoration::turnOff();
|
||||
setIsCustomWindowStyle(!CX11Decoration::isDecorated());
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
}
|
||||
|
||||
CWindowPlatform::~CWindowPlatform()
|
||||
@ -110,13 +111,26 @@ bool CWindowPlatform::event(QEvent * event)
|
||||
if (event->type() == QEvent::HoverLeave) {
|
||||
if (m_boxTitleBtns)
|
||||
m_boxTitleBtns->setCursor(QCursor(Qt::ArrowCursor));
|
||||
} else
|
||||
if (event->type() == QEvent::MouseButtonRelease) {
|
||||
focus();
|
||||
}
|
||||
return CWindowBase::event(event);
|
||||
}
|
||||
|
||||
bool CWindowPlatform::nativeEvent(const QByteArray &ev_type, void *msg, long *res)
|
||||
{
|
||||
if (ev_type == "xcb_generic_event_t") {
|
||||
xcb_generic_event_t *ev = static_cast<xcb_generic_event_t*>(msg);
|
||||
switch (ev->response_type & ~0x80) {
|
||||
case XCB_FOCUS_IN:
|
||||
if (isNativeFocus())
|
||||
focus();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return CWindowBase::nativeEvent(ev_type, msg, res);
|
||||
}
|
||||
|
||||
void CWindowPlatform::setScreenScalingFactor(double factor)
|
||||
{
|
||||
CX11Decoration::onDpiChanged(factor);
|
||||
|
||||
@ -52,6 +52,7 @@ public:
|
||||
protected:
|
||||
virtual void onMinimizeEvent() override;
|
||||
virtual bool event(QEvent *event) override;
|
||||
virtual bool nativeEvent(const QByteArray&, void*, long*) final;
|
||||
virtual void setScreenScalingFactor(double) override;
|
||||
|
||||
private:
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
#include "X11/Xlib.h"
|
||||
#include "X11/cursorfont.h"
|
||||
#include <X11/Xutil.h>
|
||||
#include "platform_linux/xcbutils.h"
|
||||
//#include "gtk_addon.h"
|
||||
|
||||
#define CUSTOM_BORDER_WIDTH 4
|
||||
@ -457,6 +458,10 @@ void CX11Decoration::dispatchMouseMove(QMouseEvent *e)
|
||||
} else {
|
||||
m_motionTimer->stop();
|
||||
sendButtonRelease();
|
||||
QTimer::singleShot(25, [=]() {
|
||||
if (m_window->size() == m_startSize)
|
||||
QApplication::postEvent(m_window, new QEvent(QEvent::User));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -559,6 +564,11 @@ void CX11Decoration::onDpiChanged(double f)
|
||||
m_nBorderSize = CUSTOM_BORDER_WIDTH * dpi_ratio;
|
||||
}
|
||||
|
||||
bool CX11Decoration::isNativeFocus()
|
||||
{
|
||||
return XcbUtils::isNativeFocus(m_window->winId());
|
||||
}
|
||||
|
||||
int CX11Decoration::customWindowBorderWith()
|
||||
{
|
||||
return CUSTOM_BORDER_WIDTH;
|
||||
@ -604,10 +614,6 @@ void CX11Decoration::sendButtonRelease()
|
||||
&event.xbutton.x_root, &event.xbutton.y_root, &event.xbutton.x, &event.xbutton.y, &event.xbutton.state);
|
||||
XSendEvent(xdisplay_, PointerWindow, True, ButtonReleaseMask, &event);
|
||||
XFlush(xdisplay_);
|
||||
QTimer::singleShot(25, [=]() {
|
||||
if (m_window->size() == m_startSize)
|
||||
QApplication::postEvent(m_window, new QEvent(QEvent::User));
|
||||
});
|
||||
}
|
||||
|
||||
void CX11Decoration::setCursorPos(int x, int y)
|
||||
|
||||
@ -70,6 +70,7 @@ public:
|
||||
protected:
|
||||
double dpi_ratio = 1;
|
||||
void onDpiChanged(double);
|
||||
bool isNativeFocus();
|
||||
|
||||
private:
|
||||
QWidget * m_window;
|
||||
|
||||
@ -70,10 +70,7 @@ CWindowPlatform::CWindowPlatform(const QRect &rect) :
|
||||
DwmExtendFrameIntoClientArea(m_hWnd, &shadow);
|
||||
#endif
|
||||
connect(this->window()->windowHandle(), &QWindow::screenChanged, this, [=]() {
|
||||
QTimer::singleShot(50, this, [=]() {
|
||||
resize(size() + QSize(1,1));
|
||||
resize(size() - QSize(1,1));
|
||||
});
|
||||
SetWindowPos(m_hWnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user