Skip to content

Commit 2b59f41

Browse files
committed
Improve TasksService logs with window title
1 parent 7c45949 commit 2b59f41

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/ManagedShell.WindowsTasks/TasksService.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ private ApplicationWindow addWindow(IntPtr hWnd, ApplicationWindow.WindowState i
272272
// This is because if Explorer is running, it will send the message, so we don't need to
273273
if (EnvironmentHelper.IsAppRunningAsShell) sendTaskbarButtonCreatedMessage(win.Handle);
274274

275+
ShellLogger.Debug($"TasksService: Added window {hWnd} ({win.Title})");
276+
275277
return win;
276278
}
277279

@@ -284,6 +286,8 @@ private void removeWindow(IntPtr hWnd)
284286
ApplicationWindow win = Windows.First(wnd => wnd.Handle == hWnd);
285287
win.Dispose();
286288
Windows.Remove(win);
289+
290+
ShellLogger.Debug($"TasksService: Removed window {hWnd} ({win.Title})");
287291
}
288292
while (Windows.Any(i => i.Handle == hWnd));
289293
}
@@ -292,6 +296,7 @@ private void removeWindow(IntPtr hWnd)
292296
private void redrawWindow(ApplicationWindow win)
293297
{
294298
win.UpdateProperties();
299+
ShellLogger.Debug($"TasksService: Updated window {win.Handle} ({win.Title})");
295300

296301
foreach (ApplicationWindow wind in Windows)
297302
{
@@ -313,7 +318,6 @@ private void ShellWinProc(Message msg)
313318
switch ((HSHELL)msg.WParam.ToInt32())
314319
{
315320
case HSHELL.WINDOWCREATED:
316-
ShellLogger.Debug("TasksService: Created: " + msg.LParam);
317321
if (!Windows.Any(i => i.Handle == msg.LParam))
318322
{
319323
addWindow(msg.LParam);
@@ -326,12 +330,10 @@ private void ShellWinProc(Message msg)
326330
break;
327331

328332
case HSHELL.WINDOWDESTROYED:
329-
ShellLogger.Debug("TasksService: Destroyed: " + msg.LParam);
330333
removeWindow(msg.LParam);
331334
break;
332335

333336
case HSHELL.WINDOWREPLACING:
334-
ShellLogger.Debug("TasksService: Replacing: " + msg.LParam);
335337
if (Windows.Any(i => i.Handle == msg.LParam))
336338
{
337339
ApplicationWindow win = Windows.First(wnd => wnd.Handle == msg.LParam);
@@ -344,15 +346,12 @@ private void ShellWinProc(Message msg)
344346
}
345347
break;
346348
case HSHELL.WINDOWREPLACED:
347-
ShellLogger.Debug("TasksService: Replaced: " + msg.LParam);
348349
// TODO: If a window gets replaced, we lose app-level state such as overlay icons.
349350
removeWindow(msg.LParam);
350351
break;
351352

352353
case HSHELL.WINDOWACTIVATED:
353354
case HSHELL.RUDEAPPACTIVATED:
354-
ShellLogger.Debug("TasksService: Activated: " + msg.LParam);
355-
356355
foreach (var aWin in Windows.Where(w => w.State == ApplicationWindow.WindowState.Active))
357356
{
358357
aWin.State = ApplicationWindow.WindowState.Inactive;
@@ -367,6 +366,7 @@ private void ShellWinProc(Message msg)
367366
win = Windows.First(wnd => wnd.Handle == msg.LParam);
368367
win.State = ApplicationWindow.WindowState.Active;
369368
win.SetShowInTaskbar();
369+
ShellLogger.Debug($"TasksService: Activated window {win.Handle} ({win.Title})");
370370
}
371371
else
372372
{
@@ -396,7 +396,6 @@ private void ShellWinProc(Message msg)
396396
break;
397397

398398
case HSHELL.FLASH:
399-
ShellLogger.Debug("TasksService: Flashing window: " + msg.LParam);
400399
if (Windows.Any(i => i.Handle == msg.LParam))
401400
{
402401
ApplicationWindow win = Windows.First(wnd => wnd.Handle == msg.LParam);
@@ -419,20 +418,17 @@ private void ShellWinProc(Message msg)
419418
break;
420419

421420
case HSHELL.ENDTASK:
422-
ShellLogger.Debug("TasksService: EndTask called: " + msg.LParam);
423421
removeWindow(msg.LParam);
424422
break;
425423

426424
case HSHELL.GETMINRECT:
427-
ShellLogger.Debug("TasksService: GetMinRect called: " + msg.LParam);
428425
SHELLHOOKINFO winHandle = (SHELLHOOKINFO)Marshal.PtrToStructure(msg.LParam, typeof(SHELLHOOKINFO));
429426
winHandle.rc = new NativeMethods.Rect { Bottom = 100, Left = 0, Right = 100, Top = 0 };
430427
Marshal.StructureToPtr(winHandle, msg.LParam, true);
431428
msg.Result = winHandle.hwnd;
432429
return; // return here so the result isnt reset to DefWindowProc
433430

434431
case HSHELL.REDRAW:
435-
ShellLogger.Debug("TasksService: Redraw called: " + msg.LParam);
436432
if (Windows.Any(i => i.Handle == msg.LParam))
437433
{
438434
ApplicationWindow win = Windows.First(wnd => wnd.Handle == msg.LParam);
@@ -471,7 +467,7 @@ private void ShellWinProc(Message msg)
471467
ShellLogger.Debug("TasksService: TaskbarCreated received, setting ITaskbarList window");
472468
setTaskbarListHwnd(_HookWin.Handle);
473469
}
474-
else
470+
else if (msg.Msg >= (int)WM.USER)
475471
{
476472
// Handle ITaskbarList functions, most not implemented yet
477473

0 commit comments

Comments
 (0)