code style

This commit is contained in:
Patrick von Reth 2015-04-06 11:57:55 +02:00
parent a2cc0dbb9c
commit be25b29bde

View File

@ -19,16 +19,15 @@
using namespace Snore;
using namespace std;
void bringWindowToFront( WId _wid) {
void bringWindowToFront(WId _wid)
{
snoreDebug(SNORE_DEBUG) << _wid;
#ifdef Q_OS_WIN
HWND wid = (HWND)_wid;
HWND hwndActiveWin = GetForegroundWindow();
int idActive = GetWindowThreadProcessId(hwndActiveWin, NULL);
if ( AttachThreadInput(GetCurrentThreadId(), idActive, TRUE) )
{
if (AttachThreadInput(GetCurrentThreadId(), idActive, TRUE)) {
SetForegroundWindow(wid);
SetFocus(wid);
FlashWindow(wid, TRUE);
@ -45,18 +44,19 @@ void bringToFront(QString pid)
{
snoreDebug(SNORE_DEBUG) << pid;
#ifdef Q_OS_WIN
auto findWindowForPid = [](ulong pid)
{
auto findWindowForPid = [](ulong pid) {
// based on http://stackoverflow.com/a/21767578
pair<ulong, HWND> data = make_pair(pid, (HWND)0);
::EnumWindows([](HWND handle, LPARAM lParam) -> BOOL {
auto isMainWindow = [](HWND handle){
auto isMainWindow = [](HWND handle)
{
return ::GetWindow(handle, GW_OWNER) == (HWND)0 && IsWindowVisible(handle);
};
pair<ulong, HWND> &data = *(pair<ulong, HWND> *)lParam;
ulong process_id = 0;
::GetWindowThreadProcessId(handle, &process_id);
if (data.first != process_id || !isMainWindow(handle)) {
if (data.first != process_id || !isMainWindow(handle))
{
return TRUE;
}
data.second = handle;
@ -108,8 +108,6 @@ int main(int argc, char *argv[])
QCommandLineOption _bringWindowToFront(QStringList() << "bring-window-to-front", "Bring window with wid to front if notification is clicked.", "wid");
parser.addOption(_bringWindowToFront);
parser.process(app);
snoreDebug(SNORE_DEBUG) << app.arguments();
if (parser.isSet(title) && parser.isSet(message)) {
@ -125,8 +123,7 @@ int main(int argc, char *argv[])
core.registerApplication(application);
Notification n(application, alert, parser.value(title), parser.value(message), icon);
if(parser.isSet(_bringProcessToFront) || parser.isSet(_bringWindowToFront))
{
if (parser.isSet(_bringProcessToFront) || parser.isSet(_bringWindowToFront)) {
n.addAction(Action(1, "Bring to Front"));
}