Skip to content

Commit

Permalink
Merge pull request #1083 from ONLYOFFICE/patch/develop_r5
Browse files Browse the repository at this point in the history
Patch/develop
  • Loading branch information
maxkadushkin authored Dec 18, 2023
2 parents ff986b6 + 05e594e commit 9a0a9d2
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 16 deletions.
2 changes: 0 additions & 2 deletions win-linux/src/cascapplicationmanagerwrapper_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,7 @@ class CAscApplicationManagerWrapper_Private
CMessage::error(m_appmanager.mainWindow()->handle(),
QObject::tr("File %1 cannot be opened or doesn't exists.").arg(_info.fileName()));
}
#ifdef _WIN32
else Utils::addToRecent(file_path);
#endif
}
}

Expand Down
2 changes: 0 additions & 2 deletions win-linux/src/ceditortools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,7 @@ namespace CEditorTools
AscAppManager::GetFileFormatByExtentionForSave(pSaveData->get_Path());

pSaveData->put_FileType(format > -1 ? format : 0);
#ifdef _WIN32
Utils::addToRecent(_full_path.toStdWString());
#endif
}
}

Expand Down
2 changes: 0 additions & 2 deletions win-linux/src/components/cdownloadwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,7 @@ void CDownloadWidget::downloadProcess(void * info)
CMessage::error(parentWidget(), tr("Can't open file: ") + path);
} else {
AscAppManager::handleInputCmd({path.toStdWString()});
#ifdef _WIN32
Utils::addToRecent(path.toStdWString());
#endif
}
});

Expand Down
1 change: 1 addition & 0 deletions win-linux/src/platform_linux/gtkfilechooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ static void nativeFileDialog(const Window &parent_xid,
GTK_RESPONSE_ACCEPT,
NULL);

gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), TRUE);
//g_signal_connect(G_OBJECT(dialog), "destroy", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(G_OBJECT(dialog), "realize", G_CALLBACK(set_parent), (gpointer)&parent_xid);
g_signal_connect(G_OBJECT(dialog), "map_event", G_CALLBACK(set_focus), NULL);
Expand Down
1 change: 1 addition & 0 deletions win-linux/src/platform_linux/gtkprintdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ QDialog::DialogCode GtkPrintDialog::exec()
GtkWidget *dialog;
dialog = gtk_print_unix_dialog_new(m_title.toUtf8().data(), NULL);
gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), TRUE);

GtkEntry *page_ranges_entry = NULL;
g_signal_connect(G_OBJECT(dialog), "map", G_CALLBACK(get_page_ranges_entry), (gpointer)&page_ranges_entry);
Expand Down
7 changes: 7 additions & 0 deletions win-linux/src/platform_linux/gtkutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ void set_parent(GtkWidget *dialog, gpointer data)
}
}

void add_to_recent(const gchar *uri)
{
gtk_init(NULL, NULL);
GtkRecentManager *rm = gtk_recent_manager_get_default();
gtk_recent_manager_add_item(rm, uri);
}

GtkWidget *find_widget_by_path(GtkWidget *parent, const gchar *widget_path)
{
if (!parent)
Expand Down
1 change: 1 addition & 0 deletions win-linux/src/platform_linux/gtkutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ typedef struct DialogTag {
gboolean set_focus(GtkWidget *dialog);
gboolean focus_out(gpointer data);
void set_parent(GtkWidget *dialog, gpointer data);
void add_to_recent(const gchar *uri);
GtkWidget *find_widget_by_path(GtkWidget *parent, const gchar *widget_path);

#endif // GTKUTILS_H
1 change: 1 addition & 0 deletions win-linux/src/platform_linux/updatedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ int WinDlg::showDialog(QWidget *parent,
"%s",
primaryText.toLocal8Bit().data());

gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), TRUE);
g_signal_connect(G_OBJECT(dialog), "realize", G_CALLBACK(set_parent), (gpointer)&parent_xid);
g_signal_connect(G_OBJECT(dialog), "map_event", G_CALLBACK(set_focus), NULL);
DialogTag tag; // unable to send parent_xid via g_signal_connect and "focus_out_event"
Expand Down
9 changes: 9 additions & 0 deletions win-linux/src/platform_linux/xcbutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ void XcbUtils::setNativeFocusTo(xcb_window_t window)
}
}

static void SetSkipTaskbar(Display* disp, Window win)
{
Atom wm_state = XInternAtom(disp, "_NET_WM_STATE", True);
Atom wm_state_skip_taskbar = XInternAtom(disp, "_NET_WM_STATE_SKIP_TASKBAR", True);
if (wm_state != None && wm_state_skip_taskbar != None)
XChangeProperty(disp, win, wm_state, XA_ATOM, 32, PropModeReplace, (const unsigned char*)&wm_state_skip_taskbar, 1);
}

static void GetWindowName(Display* disp, Window win, char **name) {
XClassHint* class_hint = NULL;
class_hint = XAllocClassHint();
Expand Down Expand Up @@ -135,6 +143,7 @@ void XcbUtils::findWindowAsync(const char *window_name,
if (strstr(name, window_name) != NULL) {
if (IsVisible(disp, win_list[i])) {
win_found = win_list[i];
SetSkipTaskbar(disp, win_found);
callback((xcb_window_t)win_found);
}
free(name);
Expand Down
22 changes: 15 additions & 7 deletions win-linux/src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
*
*/

#ifdef __linux__
# include "platform_linux/gtkutils.h"
#endif
#include "utils.h"
#include "defines.h"
#include <QSettings>
Expand Down Expand Up @@ -710,6 +713,18 @@ bool Utils::updatesAllowed()
return false;
}

void Utils::addToRecent(const std::wstring &path)
{
QString _path = QString::fromStdWString(path);
#ifdef _WIN32
QString appPath = qApp->applicationDirPath();
QProcess::startDetached(appPath + "/" + QString(REG_APP_NAME), {"--add-to-recent", QDir::toNativeSeparators(_path)}, appPath);
#else
std::string uri = "file://" + _path.toStdString();
add_to_recent(uri.c_str());
#endif
}

#ifdef _WIN32
Utils::WinVer Utils::getWinVersion()
{
Expand Down Expand Up @@ -750,13 +765,6 @@ Utils::WinVer Utils::getWinVersion()
return WinVer::Undef;
}

void Utils::addToRecent(const std::wstring &path)
{
QString _path = QString::fromStdWString(path);
QString appPath = qApp->applicationDirPath();
QProcess::startDetached(appPath + "/" + QString(REG_APP_NAME), {"--add-to-recent", QDir::toNativeSeparators(_path)}, appPath);
}

std::atomic_bool sessionInProgress{true};

bool Utils::isSessionInProgress()
Expand Down
2 changes: 1 addition & 1 deletion win-linux/src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ class Utils {
static QJsonObject parseJsonString(const std::wstring&);
static QJsonObject parseJsonFile(const QString&);
static bool updatesAllowed();
static void addToRecent(const std::wstring&);

#ifdef _WIN32
enum class WinVer : uchar {
Undef, WinXP, WinVista, Win7, Win8, Win8_1, Win10, Win11
};
static WinVer getWinVersion();
static void addToRecent(const std::wstring&);
static bool isSessionInProgress();
static void setSessionInProgress(bool);
#endif
Expand Down
2 changes: 0 additions & 2 deletions win-linux/src/windows/cmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,9 +749,7 @@ void CMainWindow::doOpenLocalFile(COpenOptions& opts)
int result = m_pTabs->openLocalDocument(opts, true);
if ( !(result < 0) ) {
toggleButtonMain(false, true);
#ifdef _WIN32
Utils::addToRecent(opts.wurl);
#endif
} else
if (result == -255) {
QTimer::singleShot(0, this, [=] {
Expand Down

0 comments on commit 9a0a9d2

Please sign in to comment.