Skip to content

Commit

Permalink
Disable while fullscreen app is focused (#29)
Browse files Browse the repository at this point in the history
Fixes Issue #27 

Disables hot corner while a focused app is fullscreen. I have verified that it works in the following cases:
- Exclusive fullscreen games
- Borderless fullscreen games
- Fullscreen apps entered with F11/Alt+Enter (such as Firefox)
- Fullscreen videos (YouTube)
- LibreOffice Impress while in presentation

At only 10 additional lines of code, I believe this will make the program more useful for the majority of users, while maintaining the simplicity of the program. This also brings the program closer to proper Gnome hot corner functionality.

Anyone that does not desire this functionality need only remove these additional lines before compilation.
  • Loading branch information
dyskos authored Oct 31, 2024
1 parent 2db56ec commit 819a3ce
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions hotcorner.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#define WIN32_LEAN_AND_MEAN
#include <stdlib.h>
#include <windows.h>
#include <shellapi.h>

#pragma comment(lib, "USER32")
#pragma comment(linker, "/SUBSYSTEM:WINDOWS")
Expand Down Expand Up @@ -90,6 +91,7 @@ static DWORD WINAPI CornerHotFunc(LPVOID lpParameter)
static LRESULT CALLBACK MouseHookCallback(int nCode, WPARAM wParam, LPARAM lParam)
{
MSLLHOOKSTRUCT *evt = (MSLLHOOKSTRUCT *) lParam;
QUERY_USER_NOTIFICATION_STATE pquns;

// If the mouse hasn't moved, we're done.
if (wParam != WM_MOUSEMOVE)
Expand Down Expand Up @@ -123,6 +125,17 @@ static LRESULT CALLBACK MouseHookCallback(int nCode, WPARAM wParam, LPARAM lPara
goto finish;
}

// Check if an app is currently fullscreen.
SHQueryUserNotificationState(&pquns);

switch (pquns) {
case QUNS_BUSY:
case QUNS_RUNNING_D3D_FULL_SCREEN:
case QUNS_PRESENTATION_MODE:
goto finish;
default:
}

// The corner is hot, and was previously cold. Here we start a thread to
// monitor if the mouse lingers.
CornerThread = CreateThread(NULL, 0, CornerHotFunc, NULL, 0, NULL);
Expand Down

0 comments on commit 819a3ce

Please sign in to comment.