Skip to content

Commit

Permalink
Remove code for stealing focus in client
Browse files Browse the repository at this point in the history
  • Loading branch information
hluk committed Jun 7, 2014
1 parent 859b01c commit b14622d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 39 deletions.
8 changes: 1 addition & 7 deletions src/app/clipboardclient.cpp
Expand Up @@ -42,13 +42,7 @@ ClipboardClient::ClipboardClient(int &argc, char **argv, int skipArgc, const QSt

void ClipboardClient::onMessageReceived(const QByteArray &data, int messageCode)
{
if (messageCode == CommandActivateWindow) {
COPYQ_LOG("Activating window.");
WId wid = (WId)(data.toLongLong());
PlatformWindowPtr window = createPlatformNativeInterface()->getWindow(wid);
if (window)
window->raise();
} else if (messageCode == CommandReadInput) {
if (messageCode == CommandReadInput) {
COPYQ_LOG("Sending standard input.");
QFile in;
in.open(stdin, QIODevice::ReadOnly);
Expand Down
2 changes: 0 additions & 2 deletions src/common/commandstatus.h
Expand Up @@ -30,8 +30,6 @@ enum CommandStatus {
CommandBadSyntax = 2,
/** Command successfully invoked. */
CommandSuccess,
/** Activate window */
CommandActivateWindow,
/** Ask client to send data from its stdin. */
CommandReadInput
};
Expand Down
4 changes: 1 addition & 3 deletions src/gui/mainwindow.cpp
Expand Up @@ -1688,7 +1688,7 @@ void MainWindow::openActionDialog(int row)
openActionDialog(dataMap);
}

WId MainWindow::openActionDialog(const QVariantMap &data)
void MainWindow::openActionDialog(const QVariantMap &data)
{
QScopedPointer<ActionDialog> actionDialog( m_actionHandler->createActionDialog(ui->tabWidget->tabs()) );
actionDialog->setWindowIcon(appIcon(AppIconRunning));
Expand All @@ -1702,8 +1702,6 @@ WId MainWindow::openActionDialog(const QVariantMap &data)
window->raise();

actionDialog.take();

return wid;
}

void MainWindow::openPreferences()
Expand Down
2 changes: 1 addition & 1 deletion src/gui/mainwindow.h
Expand Up @@ -172,7 +172,7 @@ public slots:
/** Open action dialog for given @a row (or current) in current tab. */
void openActionDialog(int row = -1);
/** Open action dialog with given input @a text. */
WId openActionDialog(const QVariantMap &data);
void openActionDialog(const QVariantMap &data);

/** Open preferences dialog. */
void openPreferences();
Expand Down
24 changes: 4 additions & 20 deletions src/scriptable/scriptable.cpp
Expand Up @@ -510,11 +510,7 @@ void Scriptable::show()
m_proxy->showBrowser(toString(argument(0)));
} else {
throwError(argumentError());
return;
}

QByteArray message = QByteArray::number((qlonglong)m_proxy->mainWinId());
sendMessageToClient(message, CommandActivateWindow);
}

void Scriptable::hide()
Expand All @@ -524,28 +520,17 @@ void Scriptable::hide()

void Scriptable::toggle()
{
if ( m_proxy->toggleVisible() ) {
QByteArray message = QByteArray::number((qlonglong)m_proxy->mainWinId());
sendMessageToClient(message, CommandActivateWindow);
}
m_proxy->toggleVisible();
}

void Scriptable::menu()
{
bool shown = false;

if (argumentCount() == 0) {
shown = m_proxy->toggleMenu();
m_proxy->toggleMenu();
} else if (argumentCount() == 1) {
shown = m_proxy->toggleMenu(toString(argument(0)));
m_proxy->toggleMenu(toString(argument(0)));
} else {
throwError(argumentError());
return;
}

if (shown) {
QByteArray message = QByteArray::number((qlonglong)m_proxy->trayMenuWinId());
sendMessageToClient(message, CommandActivateWindow);
}
}

Expand Down Expand Up @@ -871,8 +856,7 @@ void Scriptable::action()
: QString('\n');
m_proxy->action(data, command);
} else {
QByteArray message = QByteArray::number((qlonglong)m_proxy->openActionDialog(data));
sendMessageToClient(message, CommandActivateWindow);
m_proxy->openActionDialog(data);
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/scriptable/scriptableproxy.h
Expand Up @@ -255,11 +255,9 @@ public slots:
void toggleVisible() { v = m_wnd->toggleVisible(); }
void toggleMenu(const QString &tabName) { v = m_wnd->toggleMenu(fetchBrowser(tabName)); }
void toggleMenu() { v = m_wnd->toggleMenu(); }
void mainWinId() { v = (qulonglong)m_wnd->winId(); }
void trayMenuWinId() { v = (qulonglong)m_wnd->trayMenu()->winId(); }
void findTabIndex(const QString &arg1) { v = m_wnd->findTabIndex(arg1); }

void openActionDialog(const QVariantMap &arg1) { v = (qulonglong)m_wnd->openActionDialog(arg1); }
void openActionDialog(const QVariantMap &arg1) { m_wnd->openActionDialog(arg1); }

void loadTab(const QString &arg1) { v = m_wnd->loadTab(arg1); }
void saveTab(const QString &arg1)
Expand Down Expand Up @@ -455,14 +453,12 @@ class ScriptableProxy
PROXY_METHOD_0(bool, toggleVisible)
PROXY_METHOD_0(bool, toggleMenu)
PROXY_METHOD_1(bool, toggleMenu, const QString &)
PROXY_METHOD_0(qulonglong, mainWinId)
PROXY_METHOD_0(qulonglong, trayMenuWinId)
PROXY_METHOD_1(int, findTabIndex, const QString &)

PROXY_METHOD(showBrowser)
PROXY_METHOD_VOID_1(showBrowser, const QString &)

PROXY_METHOD_1(qulonglong, openActionDialog, const QVariantMap &)
PROXY_METHOD_VOID_1(openActionDialog, const QVariantMap &)
PROXY_METHOD_VOID_2(action, const QVariantMap &, const Command &)

PROXY_METHOD_1(bool, loadTab, const QString &)
Expand Down

0 comments on commit b14622d

Please sign in to comment.