Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add faster way to get progman #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions src/weebp.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,19 @@ wnd_t wp_id()
wnd_t worker;

log1("scanning for Progman");
progman = FindWindowA("Progman", 0);
progman = GetShellWindow();

if (!progman)
{
log("failed to find Progman, GLE=%08X", GetLastError());
return 0;
log("failed to find Progman, GLE=%08X, trying old method", GetLastError());
progman = FindWindowA("Progman", 0);

if (!progman)
{
log("failed to find Progman, GLE=%08X", GetLastError());

return 0;
}
}

log1("spawning wallpaper");
Expand Down Expand Up @@ -638,7 +645,7 @@ int wp_add(wnd_t wnd)
}

WEEBAPI
void wp_focus(wnd_t wnd, int ensure)
int wp_focus(wnd_t wnd, int ensure)
{
/*
* by focusing progman first we ensure that we trigger focus events even
Expand All @@ -649,13 +656,30 @@ void wp_focus(wnd_t wnd, int ensure)
{
wnd_t progman;

progman = FindWindowA("Progman", 0);
log1("scanning for Progman");
progman = GetShellWindow();

if (!progman)
{
log("failed to find Progman, GLE=%08X, trying old method", GetLastError());
progman = FindWindowA("Progman", 0);

if (!progman)
{
log("failed to find Progman, GLE=%08X", GetLastError());

return 0;
}
}

SendMessageA(progman, WM_ACTIVATE, WA_CLICKACTIVE, (LPARAM)progman);
SendMessageA(progman, WM_SETFOCUS, (WPARAM)progman, 0);
}

SendMessageA(wnd, WM_ACTIVATE, WA_CLICKACTIVE, (LPARAM)wnd);
SendMessageA(wnd, WM_SETFOCUS, (WPARAM)wnd, 0);

return 1;
}

WEEBAPI
Expand Down