Skip to content
Permalink
Browse files

Don't redraw when launcher window when focus is lost/gained

Fixes launcher window contents getting drawn over another window when you try to switch to another app on ReactOS
  • Loading branch information...
UnknownShadow200 committed Aug 12, 2019
1 parent 996b134 commit 18e780ae2e5a314dcade727725689e1e64531f45
Showing with 3 additions and 18 deletions.
  1. +0 −7 src/Launcher.c
  2. +3 −11 src/Window.c
@@ -88,11 +88,6 @@ bool Launcher_ConnectToServer(const String* hash) {
/*########################################################################################################################*
*---------------------------------------------------------Event handler---------------------------------------------------*
*#########################################################################################################################*/
static void Launcher_MaybeRedraw(void* obj) {
/* Only redraw when launcher has been initialised */
if (Launcher_Screen && Window_Exists) Launcher_Redraw();
}

static void Launcher_ReqeustRedraw(void* obj) {
/* We may get multiple Redraw events in short timespan */
/* So we just request a redraw at next launcher tick */
@@ -170,7 +165,6 @@ static void Launcher_Init(void) {

Event_RegisterVoid(&WindowEvents.Resized, NULL, Launcher_OnResize);
Event_RegisterVoid(&WindowEvents.StateChanged, NULL, Launcher_OnResize);
Event_RegisterVoid(&WindowEvents.FocusChanged, NULL, Launcher_MaybeRedraw);
Event_RegisterVoid(&WindowEvents.Redraw, NULL, Launcher_ReqeustRedraw);

Event_RegisterInput(&KeyEvents.Down, NULL, Launcher_KeyDown);
@@ -193,7 +187,6 @@ static void Launcher_Init(void) {
static void Launcher_Free(void) {
Event_UnregisterVoid(&WindowEvents.Resized, NULL, Launcher_OnResize);
Event_UnregisterVoid(&WindowEvents.StateChanged, NULL, Launcher_OnResize);
Event_UnregisterVoid(&WindowEvents.FocusChanged, NULL, Launcher_MaybeRedraw);
Event_UnregisterVoid(&WindowEvents.Redraw, NULL, Launcher_ReqeustRedraw);

Event_UnregisterInput(&KeyEvents.Down, NULL, Launcher_KeyDown);
@@ -228,17 +228,12 @@ static void Window_RefreshBounds(void) {

static LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wParam, LPARAM lParam) {
char keyChar;
bool wasFocused;
float wheelDelta;

switch (message) {
case WM_ACTIVATE:
wasFocused = Window_Focused;
Window_Focused = LOWORD(wParam) != 0;

if (Window_Focused != wasFocused) {
Event_RaiseVoid(&WindowEvents.FocusChanged);
}
Event_RaiseVoid(&WindowEvents.FocusChanged);
break;

case WM_ERASEBKGND:
@@ -1138,12 +1133,9 @@ void Window_ProcessEvents(void) {
case FocusOut:
/* Don't lose focus when another app grabs key or mouse */
if (e.xfocus.mode == NotifyGrab || e.xfocus.mode == NotifyUngrab) break;
wasFocused = Window_Focused;
Window_Focused = e.type == FocusIn;

if (Window_Focused != wasFocused) {
Event_RaiseVoid(&WindowEvents.FocusChanged);
}
Window_Focused = e.type == FocusIn;
Event_RaiseVoid(&WindowEvents.FocusChanged);
/* TODO: Keep track of keyboard when focus is lost */
if (!Window_Focused) Key_Clear();
break;

0 comments on commit 18e780a

Please sign in to comment.
You can’t perform that action at this time.