main_timer.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #include "main.h"
  2. #include "stats.h"
  3. // Display update, and menu popping up (vs killing)
  4. LRESULT Main_OnTimer(HWND hwnd, UINT id)
  5. {
  6. #ifdef BENSKI_TEST_WM_PRINTCLIENT
  7. if (id == 9999)
  8. {
  9. PrintWindow(hPLWindow);
  10. }
  11. #endif
  12. if (id == 99)
  13. {
  14. // 250 ms after a fs application has settled on
  15. KillTimer(hMainWindow, 99);
  16. g_dropaot_timer_set = 0;
  17. dropAOT();
  18. return 0;
  19. }
  20. if (id == 100)
  21. {
  22. // 250 ms after a fs application has settled off
  23. KillTimer(hMainWindow, 100);
  24. g_restoreaot_timer_set = 0;
  25. restoreAOT();
  26. return 0;
  27. }
  28. if (id == 101)
  29. {
  30. KillTimer(hMainWindow, 101);
  31. // 250ms after wm_displaychange, enforce config_keeponscreen, but not if the display change was because of a
  32. // fullscreen app, like a game
  33. if (!g_fsapp) set_aot(-1);
  34. }
  35. if (id == 200)
  36. {
  37. KillTimer(hMainWindow, 200);
  38. if (!deferring_show)
  39. return 0;
  40. deferring_show = 0;
  41. if (g_showcode == SW_SHOWMINIMIZED && config_taskbar)
  42. {
  43. ShowWindow(hMainWindow, SW_SHOWNORMAL);
  44. }
  45. ShowWindow(hMainWindow, g_showcode);
  46. return 0;
  47. }
  48. if (id == STATS_TIMER)
  49. {
  50. stats.IncrementStat(Stats::TIME_RUNNING);
  51. if (playing) stats.IncrementStat(Stats::TIME_PLAYING);
  52. if (!config_minimized) stats.IncrementStat(Stats::TIME_VISIBLE);
  53. if (!config_minimized && playing) stats.IncrementStat(Stats::TIME_VISIBLE_PLAYING);
  54. //if (config_mb_open && !config_minimized) stats_timemb++;
  55. //if (config_mb_open && !config_minimized && playing) stats_timembplaying++;
  56. }
  57. // removing the playing only check on this so rating menu updates will appear even when stopped
  58. if ((id == UPDATE_DISPLAY_TIMER) || (id == UPDATE_DISPLAY_TIMER + 2) || (id == UPDATE_DISPLAY_TIMER + 4))
  59. {
  60. if (playing)
  61. {
  62. int a = (in_getouttime()) / 1000;
  63. int l = in_getlength();
  64. if (!config_minimized && (config_mw_open || config_pe_open))
  65. {
  66. static int t = -1;
  67. static int la = -123;
  68. static int ll = -15055;
  69. if (paused)
  70. {
  71. if (t == -1) t = 10;
  72. else t--;
  73. }
  74. else t = -1;
  75. if (a != la || l != ll || (paused && t == 10) || id == UPDATE_DISPLAY_TIMER + 4) ui_drawtime(a, 0);
  76. la = a;
  77. ll = l;
  78. }
  79. if (g_brate != last_brate)
  80. draw_bitmixrate(last_brate = g_brate, g_srate);
  81. }
  82. if (g_need_titleupd || (id == UPDATE_DISPLAY_TIMER + 2))
  83. {
  84. if (id == UPDATE_DISPLAY_TIMER + 2)
  85. KillTimer(hMainWindow, id);
  86. g_need_titleupd = 0;
  87. PlayList_getcurrent_tupdate(FileName, FileTitle);
  88. {
  89. if (!do_volbar_active && !do_posbar_active && !do_panbar_active)
  90. draw_songname(FileTitle, &ui_songposition, playing ? in_getlength() : PlayList_getcurrentlength());
  91. }
  92. set_caption(!playing, L"%s - %S", (config_dotasknum?FileTitleNum:FileTitle), app_name);
  93. plEditSelect(PlayList_getPosition() | (1 << 30));
  94. }
  95. if (playing && g_need_infoupd)
  96. {
  97. int r = g_need_infoupd;
  98. g_need_infoupd = 0;
  99. if (r & 8)
  100. {
  101. last_brate = g_brate;
  102. draw_bitmixrate(g_brate, g_srate);
  103. draw_monostereo(g_nch);
  104. }
  105. if (r & 2)
  106. draw_playicon(4);
  107. else if (r & 1)
  108. draw_playicon(1);
  109. else
  110. draw_playicon(8);
  111. }
  112. }
  113. if (id == UPDATE_DISPLAY_TIMER + 1 && !config_minimized && !config_windowshade && config_mw_open)
  114. if (config_autoscrollname&1)
  115. {
  116. ui_doscrolling();
  117. }
  118. if (id == 666)
  119. {
  120. KillTimer(hwnd, 666);
  121. SendMessageW(hwnd, WM_COMMAND, WINAMP_MAINMENU, 0);
  122. }
  123. if (id == UPDATE_DISPLAY_TIMER + 1)
  124. {
  125. if (config_autoscrollname&2)
  126. do_caption_autoscroll();
  127. }
  128. return 1;
  129. }