ReactOS  0.4.15-dev-3733-g974a0f0
appswitch.c File Reference
#include <user32.h>
Include dependency graph for appswitch.c:

Go to the source code of this file.

Macros

#define DIALOG_MARGIN   8
 
#define CX_ICON   32
 
#define CY_ICON   32
 
#define ICON_MARGIN   4
 
#define CX_ITEM   (CX_ICON + 2 * ICON_MARGIN)
 
#define CY_ITEM   (CY_ICON + 2 * ICON_MARGIN)
 
#define ITEM_MARGIN   4
 
#define CX_ITEM_SPACE   (CX_ITEM + 2 * ITEM_MARGIN)
 
#define CY_ITEM_SPACE   (CY_ITEM + 2 * ITEM_MARGIN)
 
#define CY_TEXT_MARGIN   4
 
#define MAX_WINDOWS   120
 
#define ICON_TIMEOUT   100
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (user32)
 
BOOL LoadCoolSwitchSettings (void)
 
void ResizeAndCenter (HWND hwnd, int width, int height)
 
void CompleteSwitch (BOOL doSwitch)
 
BOOL CALLBACK EnumerateCallback (HWND window, LPARAM lParam)
 
static HWND GetNiceRootOwner (HWND hwnd)
 
BOOL IsAltTabWindow (HWND hwnd)
 
static BOOL CALLBACK EnumWindowsProc (HWND hwnd, LPARAM lParam)
 
void ProcessMouseMessage (UINT message, LPARAM lParam)
 
void OnPaint (HWND hWnd)
 
DWORD CreateSwitcherWindow (HINSTANCE hInstance)
 
DWORD GetDialogFont (VOID)
 
void PrepareWindow (VOID)
 
BOOL ProcessHotKey (VOID)
 
void RotateTasks (BOOL bShift)
 
static void MoveLeft (void)
 
static void MoveRight (void)
 
static void MoveUp (void)
 
static void MoveDown (void)
 
VOID DestroyAppWindows (VOID)
 
LRESULT WINAPI DoAppSwitch (WPARAM wParam, LPARAM lParam)
 
LRESULT WINAPI SwitchWndProc_common (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL unicode)
 
LRESULT WINAPI SwitchWndProcA (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
LRESULT WINAPI SwitchWndProcW (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

HWND switchdialog = NULL
 
HFONT dialogFont
 
int selectedWindow = 0
 
BOOL isOpen = FALSE
 
int fontHeight =0
 
WCHAR windowText [1024]
 
HWND windowList [MAX_WINDOWS]
 
HICON iconList [MAX_WINDOWS]
 
int windowCount = 0
 
int cxBorder
 
int cyBorder
 
int nItems
 
int nCols
 
int nRows
 
int itemsW
 
int itemsH
 
int totalW
 
int totalH
 
int xOffset
 
int yOffset
 
POINT ptStart
 
int nShift = 0
 
BOOL Esc = FALSE
 
BOOL CoolSwitch = TRUE
 
int CoolSwitchRows = 3
 
int CoolSwitchColumns = 7
 
const DWORD Style = WS_POPUP | WS_BORDER | WS_DISABLED
 
const DWORD ExStyle = WS_EX_TOPMOST | WS_EX_DLGMODALFRAME | WS_EX_TOOLWINDOW
 

Macro Definition Documentation

◆ CX_ICON

#define CX_ICON   32

Definition at line 24 of file appswitch.c.

◆ CX_ITEM

#define CX_ITEM   (CX_ICON + 2 * ICON_MARGIN)

Definition at line 28 of file appswitch.c.

◆ CX_ITEM_SPACE

#define CX_ITEM_SPACE   (CX_ITEM + 2 * ITEM_MARGIN)

Definition at line 32 of file appswitch.c.

◆ CY_ICON

#define CY_ICON   32

Definition at line 25 of file appswitch.c.

◆ CY_ITEM

#define CY_ITEM   (CY_ICON + 2 * ICON_MARGIN)

Definition at line 29 of file appswitch.c.

◆ CY_ITEM_SPACE

#define CY_ITEM_SPACE   (CY_ITEM + 2 * ITEM_MARGIN)

Definition at line 33 of file appswitch.c.

◆ CY_TEXT_MARGIN

#define CY_TEXT_MARGIN   4

Definition at line 35 of file appswitch.c.

◆ DIALOG_MARGIN

#define DIALOG_MARGIN   8

Definition at line 22 of file appswitch.c.

◆ ICON_MARGIN

#define ICON_MARGIN   4

Definition at line 26 of file appswitch.c.

◆ ICON_TIMEOUT

#define ICON_TIMEOUT   100

◆ ITEM_MARGIN

#define ITEM_MARGIN   4

Definition at line 30 of file appswitch.c.

◆ MAX_WINDOWS

#define MAX_WINDOWS   120

Definition at line 39 of file appswitch.c.

Function Documentation

◆ CompleteSwitch()

void CompleteSwitch ( BOOL  doSwitch)

Definition at line 113 of file appswitch.c.

114 {
115  if (!isOpen)
116  return;
117 
118  isOpen = FALSE;
119 
120  TRACE("[ATbot] CompleteSwitch Hiding Window.\n");
122 
123  if(doSwitch)
124  {
126  return;
127 
128  // FIXME: workaround because reactos fails to activate the previous window correctly.
129  //if(selectedWindow != 0)
130  {
132 
134 
135  TRACE("[ATbot] CompleteSwitch Switching to 0x%08x (%ls)\n", hwnd, windowText);
136 
138  }
139  }
140 
141  windowCount = 0;
142 }
HWND switchdialog
Definition: appswitch.c:42
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
int windowCount
Definition: appswitch.c:53
BOOL isOpen
Definition: appswitch.c:45
BOOL WINAPI ShowWindowAsync(_In_ HWND, _In_ int)
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
#define _countof(array)
Definition: sndvol32.h:68
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
WCHAR windowText[1024]
Definition: appswitch.c:49
HWND windowList[MAX_WINDOWS]
Definition: appswitch.c:51
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
int selectedWindow
Definition: appswitch.c:44
VOID WINAPI SwitchToThisWindow(HWND hwnd, BOOL fAltTab)
Definition: window.c:82

Referenced by DoAppSwitch(), ProcessMouseMessage(), and SwitchWndProc_common().

◆ CreateSwitcherWindow()

DWORD CreateSwitcherWindow ( HINSTANCE  hInstance)

Definition at line 397 of file appswitch.c.

398 {
400  WC_SWITCH,
401  L"",
405  400, 150,
406  NULL, NULL,
407  hInstance, NULL);
408  if (!switchdialog)
409  {
410  TRACE("[ATbot] Task Switcher Window failed to create.\n");
411  return 0;
412  }
413 
414  isOpen = FALSE;
415  return 1;
416 }
#define WS_DISABLED
Definition: pedump.c:621
HWND switchdialog
Definition: appswitch.c:42
BOOL isOpen
Definition: appswitch.c:45
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
HINSTANCE hInstance
Definition: charmap.c:20
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
#define WC_SWITCH
Definition: undocuser.h:12
#define CW_USEDEFAULT
Definition: winuser.h:225
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
#define TRACE(s)
Definition: solgame.cpp:4
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define WS_EX_TOPMOST
Definition: pedump.c:647
#define WS_BORDER
Definition: pedump.c:625
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112

Referenced by ProcessHotKey().

◆ DestroyAppWindows()

VOID DestroyAppWindows ( VOID  )

Definition at line 572 of file appswitch.c.

573 {
574  // for every item of the icon list:
575  INT i;
576  for (i = 0; i < windowCount; ++i)
577  {
578  // destroy the icon
580  iconList[i] = NULL;
581  }
582 }
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
int windowCount
Definition: appswitch.c:53
int32_t INT
Definition: typedefs.h:58
HICON iconList[MAX_WINDOWS]
Definition: appswitch.c:52
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NULL
Definition: types.h:112

Referenced by DoAppSwitch(), and SwitchWndProc_common().

◆ DoAppSwitch()

LRESULT WINAPI DoAppSwitch ( WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 584 of file appswitch.c.

585 {
586  HWND hwndActive;
587  MSG msg;
588 
589  // FIXME: Is loading timing OK?
591 
592  if (!CoolSwitch)
593  return 0;
594 
595  // Already in the loop.
596  if (switchdialog || Esc) return 0;
597 
598  if (lParam == VK_ESCAPE)
599  {
600  Esc = TRUE;
601 
602  windowCount = 0;
604 
605  if (windowCount < 2)
606  return 0;
607 
609 
610  hwndActive = GetActiveWindow();
611 
612  if (hwndActive == NULL)
613  {
614  Esc = FALSE;
615  return 0;
616  }
617  }
618 
619  // Capture current active window.
620  hwndActive = GetActiveWindow();
621  if (hwndActive)
622  SetCapture(hwndActive);
623 
624  switch (lParam)
625  {
626  case VK_TAB:
627  if (!GetDialogFont() || !ProcessHotKey())
628  goto Exit;
629  break;
630 
631  case VK_ESCAPE:
632  break;
633 
634  default:
635  goto Exit;
636  }
637 
638  if (!hwndActive)
639  goto Exit;
640 
641  // Main message loop:
642  while (1)
643  {
644  for (;;)
645  {
646  if (PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE ))
647  {
648  if (!CallMsgFilterW( &msg, MSGF_NEXTWINDOW )) break;
649  /* remove the message from the queue */
650  PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE );
651  }
652  else
653  WaitMessage();
654  }
655 
656  switch (msg.message)
657  {
658  case WM_KEYUP:
659  {
660  PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE );
661  if (msg.wParam == VK_MENU)
662  {
664  }
665  else if (msg.wParam == VK_RETURN)
666  {
668  }
669  else if (msg.wParam == VK_ESCAPE)
670  {
671  TRACE("DoAppSwitch VK_ESCAPE 2\n");
673  }
674  goto Exit; //break;
675  }
676 
677  case WM_SYSKEYDOWN:
678  {
679  PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE );
680  if (HIWORD(msg.lParam) & KF_ALTDOWN)
681  {
682  if ( msg.wParam == VK_TAB )
683  {
684  if (Esc) break;
685  if (GetKeyState(VK_SHIFT) < 0)
686  {
687  MoveLeft();
688  }
689  else
690  {
691  MoveRight();
692  }
693  }
694  else if ( msg.wParam == VK_ESCAPE )
695  {
696  if (!Esc) break;
698  }
699  else if ( msg.wParam == VK_LEFT )
700  {
701  MoveLeft();
702  }
703  else if ( msg.wParam == VK_RIGHT )
704  {
705  MoveRight();
706  }
707  else if ( msg.wParam == VK_UP )
708  {
709  MoveUp();
710  }
711  else if ( msg.wParam == VK_DOWN )
712  {
713  MoveDown();
714  }
715  }
716  break;
717  }
718 
719  case WM_LBUTTONUP:
720  PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE );
721  ProcessMouseMessage(msg.message, msg.lParam);
722  goto Exit;
723 
724  default:
725  if (PeekMessageW( &msg, 0, msg.message, msg.message, PM_REMOVE ))
726  {
729  }
730  break;
731  }
732  }
733 Exit:
734  ReleaseCapture();
736  if (Esc) DestroyAppWindows();
737  switchdialog = NULL;
738  selectedWindow = 0;
739  windowCount = 0;
740  Esc = FALSE;
741  return 0;
742 }
BOOL WINAPI TranslateMessage(_In_ const MSG *)
void CompleteSwitch(BOOL doSwitch)
Definition: appswitch.c:113
HWND switchdialog
Definition: appswitch.c:42
#define TRUE
Definition: types.h:120
BOOL WINAPI WaitMessage(void)
Definition: ntwrapper.h:350
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
BOOL Esc
Definition: appswitch.c:64
int windowCount
Definition: appswitch.c:53
#define VK_LEFT
Definition: winuser.h:2204
#define VK_TAB
Definition: winuser.h:2179
#define VK_DOWN
Definition: winuser.h:2207
#define VK_MENU
Definition: winuser.h:2184
#define VK_ESCAPE
Definition: winuser.h:2194
BOOL WINAPI DestroyWindow(_In_ HWND)
#define VK_RETURN
Definition: winuser.h:2181
static void MoveDown(void)
Definition: appswitch.c:556
#define PM_NOREMOVE
Definition: winuser.h:1185
#define MSGF_NEXTWINDOW
Definition: winuser.h:1169
BOOL WINAPI CallMsgFilterW(_In_ LPMSG, _In_ INT)
#define VK_UP
Definition: winuser.h:2205
#define FALSE
Definition: types.h:117
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
static void MoveUp(void)
Definition: appswitch.c:541
#define VK_SHIFT
Definition: winuser.h:2182
SHORT WINAPI GetKeyState(_In_ int)
static void MoveLeft(void)
Definition: appswitch.c:527
#define TRACE(s)
Definition: solgame.cpp:4
static void Exit(void)
Definition: sock.c:1331
#define WM_KEYUP
Definition: winuser.h:1703
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC, _In_ LPARAM)
DWORD GetDialogFont(VOID)
Definition: appswitch.c:418
SHORT WINAPI GetAsyncKeyState(_In_ int)
#define VK_RIGHT
Definition: winuser.h:2206
HWND WINAPI SetCapture(_In_ HWND hWnd)
BOOL LoadCoolSwitchSettings(void)
Definition: appswitch.c:74
BOOL ProcessHotKey(VOID)
Definition: appswitch.c:455
#define WM_LBUTTONUP
Definition: winuser.h:1764
static void MoveRight(void)
Definition: appswitch.c:535
#define NULL
Definition: types.h:112
#define KF_ALTDOWN
Definition: winuser.h:2429
void ProcessMouseMessage(UINT message, LPARAM lParam)
Definition: appswitch.c:277
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2889
void RotateTasks(BOOL bShift)
Definition: appswitch.c:490
#define WM_SYSKEYDOWN
Definition: winuser.h:1706
#define HIWORD(l)
Definition: typedefs.h:247
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1186
BOOL CoolSwitch
Definition: appswitch.c:66
int selectedWindow
Definition: appswitch.c:44
LPARAM lParam
Definition: combotst.c:139
HWND WINAPI GetActiveWindow(void)
Definition: winpos.c:138
static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
Definition: appswitch.c:267
VOID DestroyAppWindows(VOID)
Definition: appswitch.c:572

Referenced by DefWndHandleSysCommand().

◆ EnumerateCallback()

BOOL CALLBACK EnumerateCallback ( HWND  window,
LPARAM  lParam 
)

Definition at line 144 of file appswitch.c.

145 {
146  HICON hIcon = NULL;
147  LRESULT bAlive;
148 
150 
151  // First try to get the big icon assigned to the window
152 #define ICON_TIMEOUT 100 // in milliseconds
153  bAlive = SendMessageTimeoutW(window, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG | SMTO_BLOCK,
155  if (!hIcon)
156  {
157  // If no icon is assigned, try to get the icon assigned to the windows' class
159  if (!hIcon)
160  {
161  // If we still don't have an icon, see if we can do with the small icon,
162  // or a default application icon
163  if (bAlive)
164  {
165  SendMessageTimeoutW(window, WM_GETICON, ICON_SMALL2, 0,
167  (PDWORD_PTR)&hIcon);
168  }
169 #undef ICON_TIMEOUT
170  if (!hIcon)
171  {
172  // using windows logo icon as default
173  hIcon = gpsi->hIconWindows;
174  if (!hIcon)
175  {
176  //if all attempts to get icon fails go to the next window
177  return TRUE;
178  }
179  }
180  }
181  }
182 
185  windowCount++;
186 
187  // If we got to the max number of windows, we won't be able to add any more
188  return (windowCount < MAX_WINDOWS);
189 }
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define MAX_WINDOWS
Definition: appswitch.c:39
int windowCount
Definition: appswitch.c:53
PSERVERINFO gpsi
Definition: main.c:27
#define SMTO_ABORTIFHUNG
Definition: winuser.h:1213
HICON iconList[MAX_WINDOWS]
Definition: appswitch.c:52
ULONG_PTR * PDWORD_PTR
Definition: basetsd.h:184
static IHTMLWindow2 * window
Definition: events.c:77
#define GCL_HICON
Definition: winuser.h:661
HICON WINAPI CopyIcon(_In_ HICON)
Definition: cursoricon.c:1980
HICON hIcon
Definition: msconfig.c:44
#define NULL
Definition: types.h:112
LRESULT WINAPI SendMessageTimeoutW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM, _In_ UINT, _In_ UINT, _Out_opt_ PDWORD_PTR)
HWND windowList[MAX_WINDOWS]
Definition: appswitch.c:51
#define ICON_TIMEOUT
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
#define SMTO_BLOCK
Definition: winuser.h:1214
#define GetClassLongPtrW
Definition: winuser.h:4544
#define ICON_BIG
Definition: tnclass.cpp:51

Referenced by EnumWindowsProc().

◆ EnumWindowsProc()

static BOOL CALLBACK EnumWindowsProc ( HWND  hwnd,
LPARAM  lParam 
)
static

Definition at line 267 of file appswitch.c.

268 {
269  if (IsAltTabWindow(hwnd))
270  {
272  return FALSE;
273  }
274  return TRUE;
275 }
BOOL CALLBACK EnumerateCallback(HWND window, LPARAM lParam)
Definition: appswitch.c:144
#define TRUE
Definition: types.h:120
BOOL IsAltTabWindow(HWND hwnd)
Definition: appswitch.c:217
#define FALSE
Definition: types.h:117
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
LPARAM lParam
Definition: combotst.c:139

Referenced by DoAppSwitch(), and ProcessHotKey().

◆ GetDialogFont()

DWORD GetDialogFont ( VOID  )

Definition at line 418 of file appswitch.c.

419 {
420  HDC tDC;
421  TEXTMETRIC tm;
422 
424 
425  tDC = GetDC(0);
426  GetTextMetrics(tDC, &tm);
427  fontHeight = tm.tmHeight;
428  ReleaseDC(0, tDC);
429 
430  return 1;
431 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
HFONT dialogFont
Definition: appswitch.c:43
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
#define GetTextMetrics
Definition: wingdi.h:4474
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
int fontHeight
Definition: appswitch.c:47
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
Definition: time.h:68
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)

Referenced by DoAppSwitch().

◆ GetNiceRootOwner()

static HWND GetNiceRootOwner ( HWND  hwnd)
static

Definition at line 191 of file appswitch.c.

192 {
193  HWND hwndOwner;
194  DWORD ExStyle, OwnerExStyle;
195 
196  for (;;)
197  {
198  // A window with WS_EX_APPWINDOW is treated as if it has no owner
200  if (ExStyle & WS_EX_APPWINDOW)
201  break;
202 
203  // Is the owner visible?
204  // An window with WS_EX_TOOLWINDOW is treated as if it weren't visible
205  hwndOwner = GetWindow(hwnd, GW_OWNER);
206  OwnerExStyle = GetWindowLong(hwndOwner, GWL_EXSTYLE);
207  if (!IsWindowVisible(hwndOwner) || (OwnerExStyle & WS_EX_TOOLWINDOW))
208  break;
209 
210  hwnd = hwndOwner;
211  }
212 
213  return hwnd;
214 }
#define GWL_EXSTYLE
Definition: winuser.h:845
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
unsigned long DWORD
Definition: ntddk_ex.h:95
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define GetWindowLong
Definition: winuser.h:5776
#define GW_OWNER
Definition: winuser.h:761
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define WS_EX_APPWINDOW
Definition: winuser.h:383
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
const DWORD ExStyle
Definition: appswitch.c:72

Referenced by IsAltTabWindow().

◆ IsAltTabWindow()

BOOL IsAltTabWindow ( HWND  hwnd)

Definition at line 217 of file appswitch.c.

218 {
219  DWORD ExStyle;
220  RECT rc;
221  HWND hwndTry, hwndWalk;
222  WCHAR szClass[64];
223 
224  // must be visible
225  if (!IsWindowVisible(hwnd))
226  return FALSE;
227 
228  // must not be WS_EX_TOOLWINDOW
231  return FALSE;
232 
233  // must be not empty rect
234  GetWindowRect(hwnd, &rc);
235  if (IsRectEmpty(&rc))
236  return FALSE;
237 
238  // check special windows
239  if (!GetClassNameW(hwnd, szClass, _countof(szClass)) ||
240  wcscmp(szClass, L"Shell_TrayWnd") == 0 ||
241  wcscmp(szClass, L"Progman") == 0)
242  {
243  return TRUE;
244  }
245 
246  // get 'nice' root owner
247  hwndWalk = GetNiceRootOwner(hwnd);
248 
249  // walk back from hwndWalk toward hwnd
250  for (;;)
251  {
252  hwndTry = GetLastActivePopup(hwndWalk);
253  if (hwndTry == hwndWalk)
254  break;
255 
256  ExStyle = GetWindowLong(hwndTry, GWL_EXSTYLE);
257  if (IsWindowVisible(hwndTry) && !(ExStyle & WS_EX_TOOLWINDOW))
258  break;
259 
260  hwndWalk = hwndTry;
261  }
262 
263  return hwnd == hwndTry; // Reached?
264 }
static HWND GetNiceRootOwner(HWND hwnd)
Definition: appswitch.c:191
#define TRUE
Definition: types.h:120
#define GWL_EXSTYLE
Definition: winuser.h:845
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
HWND WINAPI GetLastActivePopup(_In_ HWND)
int WINAPI GetClassNameW(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName, _In_ int nMaxCount)
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
unsigned long DWORD
Definition: ntddk_ex.h:95
#define GetWindowLong
Definition: winuser.h:5776
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
BOOL WINAPI IsWindowVisible(_In_ HWND)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
const DWORD ExStyle
Definition: appswitch.c:72

Referenced by EnumWindowsProc().

◆ LoadCoolSwitchSettings()

BOOL LoadCoolSwitchSettings ( void  )

Definition at line 74 of file appswitch.c.

75 {
76  CoolSwitch = TRUE;
77  CoolSwitchRows = 3;
79 
80  // FIXME: load the settings from registry
81 
82  TRACE("CoolSwitch: %d\n", CoolSwitch);
83  TRACE("CoolSwitchRows: %d\n", CoolSwitchRows);
84  TRACE("CoolSwitchColumns: %d\n", CoolSwitchColumns);
85 
86  return TRUE;
87 }
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4
int CoolSwitchColumns
Definition: appswitch.c:68
int CoolSwitchRows
Definition: appswitch.c:67
BOOL CoolSwitch
Definition: appswitch.c:66

Referenced by DoAppSwitch().

◆ MoveDown()

static void MoveDown ( void  )
static

Definition at line 556 of file appswitch.c.

557 {
558  INT iRow = selectedWindow / nCols;
559  INT iCol = selectedWindow % nCols;
560 
561  ++iRow;
562  if (iRow >= nRows)
563  iRow = 0;
564 
565  selectedWindow = iRow * nCols + iCol;
569 }
HWND switchdialog
Definition: appswitch.c:42
int nCols
Definition: appswitch.c:56
#define TRUE
Definition: types.h:120
int windowCount
Definition: appswitch.c:53
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define NULL
Definition: types.h:112
int nRows
Definition: appswitch.c:56
int selectedWindow
Definition: appswitch.c:44

Referenced by DoAppSwitch().

◆ MoveLeft()

static void MoveLeft ( void  )
static

Definition at line 527 of file appswitch.c.

528 {
530  if (selectedWindow < 0)
533 }
HWND switchdialog
Definition: appswitch.c:42
#define TRUE
Definition: types.h:120
int windowCount
Definition: appswitch.c:53
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define NULL
Definition: types.h:112
int selectedWindow
Definition: appswitch.c:44

Referenced by DoAppSwitch().

◆ MoveRight()

static void MoveRight ( void  )
static

Definition at line 535 of file appswitch.c.

536 {
539 }
HWND switchdialog
Definition: appswitch.c:42
#define TRUE
Definition: types.h:120
int windowCount
Definition: appswitch.c:53
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define NULL
Definition: types.h:112
int selectedWindow
Definition: appswitch.c:44

Referenced by DoAppSwitch().

◆ MoveUp()

static void MoveUp ( void  )
static

Definition at line 541 of file appswitch.c.

542 {
543  INT iRow = selectedWindow / nCols;
544  INT iCol = selectedWindow % nCols;
545 
546  --iRow;
547  if (iRow < 0)
548  iRow = nRows - 1;
549 
550  selectedWindow = iRow * nCols + iCol;
554 }
HWND switchdialog
Definition: appswitch.c:42
int nCols
Definition: appswitch.c:56
#define TRUE
Definition: types.h:120
int windowCount
Definition: appswitch.c:53
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define NULL
Definition: types.h:112
int nRows
Definition: appswitch.c:56
int selectedWindow
Definition: appswitch.c:44

Referenced by DoAppSwitch().

◆ OnPaint()

void OnPaint ( HWND  hWnd)

Definition at line 304 of file appswitch.c.

305 {
306  HDC dialogDC;
307  PAINTSTRUCT paint;
308  RECT cRC, textRC;
309  int i, xPos, yPos, CharCount;
310  HFONT dcFont;
311  HICON hIcon;
312  HPEN hPen;
313  COLORREF Color;
314 
315  // check
316  if (nCols == 0 || nItems == 0)
317  return;
318 
319  // begin painting
320  dialogDC = BeginPaint(hWnd, &paint);
321  if (dialogDC == NULL)
322  return;
323 
324  // fill the client area
325  GetClientRect(hWnd, &cRC);
326  FillRect(dialogDC, &cRC, (HBRUSH)(COLOR_3DFACE + 1));
327 
328  // if the selection index exceeded the display items, then
329  // do display item shifting
330  if (selectedWindow >= nItems)
331  nShift = selectedWindow - nItems + 1;
332  else
333  nShift = 0;
334 
335  for (i = 0; i < nItems; ++i)
336  {
337  // get the icon to display
338  hIcon = iconList[i + nShift];
339 
340  // calculate the position where we start drawing
341  xPos = DIALOG_MARGIN + CX_ITEM_SPACE * (i % nCols) + ITEM_MARGIN;
342  yPos = DIALOG_MARGIN + CY_ITEM_SPACE * (i / nCols) + ITEM_MARGIN;
343 
344  // centering
346  {
347  xPos += (itemsW - nItems * CX_ITEM_SPACE) / 2;
348  }
349 
350  // if this position is selected,
351  if (selectedWindow == i + nShift)
352  {
353  // create a solid pen
355  hPen = CreatePen(PS_SOLID, 1, Color);
356 
357  // draw a rectangle with using the pen
358  SelectObject(dialogDC, hPen);
360  Rectangle(dialogDC, xPos, yPos, xPos + CX_ITEM, yPos + CY_ITEM);
361  Rectangle(dialogDC, xPos + 1, yPos + 1,
362  xPos + CX_ITEM - 1, yPos + CY_ITEM - 1);
363 
364  // delete the pen
365  DeleteObject(hPen);
366  }
367 
368  // draw icon
369  DrawIconEx(dialogDC, xPos + ICON_MARGIN, yPos + ICON_MARGIN,
371  }
372 
373  // set the text rectangle
376 
377  // draw the sunken button around text
378  DrawFrameControl(dialogDC, &textRC, DFC_BUTTON,
380 
381  // get text
384 
385  // draw text
386  dcFont = SelectObject(dialogDC, dialogFont);
388  SetBkMode(dialogDC, TRANSPARENT);
389  DrawTextW(dialogDC, windowText, CharCount, &textRC,
391  SelectObject(dialogDC, dcFont);
392 
393  // end painting
394  EndPaint(hWnd, &paint);
395 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
HFONT dialogFont
Definition: appswitch.c:43
static HICON
Definition: imagelist.c:84
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define DFC_BUTTON
Definition: winuser.h:476
#define COLOR_HIGHLIGHT
Definition: winuser.h:920
#define CX_ICON
Definition: appswitch.c:24
int nCols
Definition: appswitch.c:56
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define NULL_BRUSH
Definition: wingdi.h:901
static HDC
Definition: imagelist.c:92
HWND hWnd
Definition: settings.c:17
#define ITEM_MARGIN
Definition: appswitch.c:30
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define ICON_MARGIN
Definition: appswitch.c:26
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
DWORD WINAPI GetSysColor(_In_ int)
struct Color Color
#define PS_SOLID
Definition: wingdi.h:586
#define DFCS_PUSHED
Definition: winuser.h:503
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1056
#define COLOR_3DFACE
Definition: winuser.h:923
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define CX_ITEM_SPACE
Definition: appswitch.c:32
#define TRANSPARENT
Definition: wingdi.h:950
int nItems
Definition: appswitch.c:56
#define DT_END_ELLIPSIS
Definition: winuser.h:529
int totalW
Definition: appswitch.c:58
HICON iconList[MAX_WINDOWS]
Definition: appswitch.c:52
#define DT_VCENTER
Definition: winuser.h:543
#define DIALOG_MARGIN
Definition: appswitch.c:22
int itemsW
Definition: appswitch.c:57
#define CY_ITEM
Definition: appswitch.c:29
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:1997
int itemsH
Definition: appswitch.c:57
DWORD COLORREF
Definition: windef.h:300
int totalH
Definition: appswitch.c:58
#define _countof(array)
Definition: sndvol32.h:68
int nShift
Definition: appswitch.c:62
int CoolSwitchColumns
Definition: appswitch.c:68
#define DI_NORMAL
Definition: wingdi.h:72
#define CY_ICON
Definition: appswitch.c:25
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:911
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DT_SINGLELINE
Definition: winuser.h:540
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
HICON hIcon
Definition: msconfig.c:44
#define DFCS_BUTTONPUSH
Definition: winuser.h:501
#define NULL
Definition: types.h:112
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
WCHAR windowText[1024]
Definition: appswitch.c:49
#define CX_ITEM
Definition: appswitch.c:28
HWND windowList[MAX_WINDOWS]
Definition: appswitch.c:51
#define DT_CENTER
Definition: winuser.h:527
#define COLOR_BTNTEXT
Definition: winuser.h:927
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int selectedWindow
Definition: appswitch.c:44
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17
#define CY_ITEM_SPACE
Definition: appswitch.c:33

Referenced by SwitchWndProc_common().

◆ PrepareWindow()

void PrepareWindow ( VOID  )

Definition at line 433 of file appswitch.c.

434 {
436 
439  if (nRows > CoolSwitchRows)
440  {
442  nItems = nRows * nCols;
443  }
444 
447 
448  totalW = itemsW + 2 * DIALOG_MARGIN;
449  totalH = itemsH + 2 * DIALOG_MARGIN;
451 
453 }
void ResizeAndCenter(HWND hwnd, int width, int height)
Definition: appswitch.c:89
HWND switchdialog
Definition: appswitch.c:42
int nCols
Definition: appswitch.c:56
int windowCount
Definition: appswitch.c:53
#define CY_TEXT_MARGIN
Definition: appswitch.c:35
#define CX_ITEM_SPACE
Definition: appswitch.c:32
int nItems
Definition: appswitch.c:56
int totalW
Definition: appswitch.c:58
#define DIALOG_MARGIN
Definition: appswitch.c:22
int itemsW
Definition: appswitch.c:57
int fontHeight
Definition: appswitch.c:47
int itemsH
Definition: appswitch.c:57
int totalH
Definition: appswitch.c:58
int CoolSwitchColumns
Definition: appswitch.c:68
int CoolSwitchRows
Definition: appswitch.c:67
int nRows
Definition: appswitch.c:56
#define CY_ITEM_SPACE
Definition: appswitch.c:33

Referenced by SwitchWndProc_common().

◆ ProcessHotKey()

BOOL ProcessHotKey ( VOID  )

Definition at line 455 of file appswitch.c.

456 {
457  if (!isOpen)
458  {
459  windowCount = 0;
461 
462  if (windowCount == 0)
463  return FALSE;
464 
465  if (windowCount == 1)
466  {
468  return FALSE;
469  }
470 
472  return FALSE;
473 
474  selectedWindow = 1;
475 
476  TRACE("[ATbot] HotKey Received. Opening window.\n");
479  isOpen = TRUE;
480  }
481  else
482  {
483  TRACE("[ATbot] HotKey Received Rotating.\n");
486  }
487  return TRUE;
488 }
HWND switchdialog
Definition: appswitch.c:42
DWORD CreateSwitcherWindow(HINSTANCE hInstance)
Definition: appswitch.c:397
#define TRUE
Definition: types.h:120
int windowCount
Definition: appswitch.c:53
BOOL isOpen
Definition: appswitch.c:45
HINSTANCE User32Instance
Definition: dllmain.c:27
BOOL WINAPI ShowWindowAsync(_In_ HWND, _In_ int)
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC, _In_ LPARAM)
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define NULL
Definition: types.h:112
HWND windowList[MAX_WINDOWS]
Definition: appswitch.c:51
int selectedWindow
Definition: appswitch.c:44
VOID WINAPI SwitchToThisWindow(HWND hwnd, BOOL fAltTab)
Definition: window.c:82
static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
Definition: appswitch.c:267

Referenced by DoAppSwitch().

◆ ProcessMouseMessage()

void ProcessMouseMessage ( UINT  message,
LPARAM  lParam 
)

Definition at line 277 of file appswitch.c.

278 {
279  int xPos = LOWORD(lParam);
280  int yPos = HIWORD(lParam);
281 
282  int xIndex = (xPos - DIALOG_MARGIN) / CX_ITEM_SPACE;
283  int yIndex = (yPos - DIALOG_MARGIN) / CY_ITEM_SPACE;
284 
285  if (xIndex < 0 || nCols <= xIndex ||
286  yIndex < 0 || nRows <= yIndex)
287  {
288  return;
289  }
290 
291  selectedWindow = (yIndex*nCols) + xIndex;
292  if (message == WM_MOUSEMOVE)
293  {
295  //RedrawWindow(switchdialog, NULL, NULL, 0);
296  }
297  else
298  {
299  selectedWindow = (yIndex*nCols) + xIndex;
301  }
302 }
Definition: tftpd.h:59
void CompleteSwitch(BOOL doSwitch)
Definition: appswitch.c:113
HWND switchdialog
Definition: appswitch.c:42
int nCols
Definition: appswitch.c:56
#define TRUE
Definition: types.h:120
#define CX_ITEM_SPACE
Definition: appswitch.c:32
#define DIALOG_MARGIN
Definition: appswitch.c:22
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define WM_MOUSEMOVE
Definition: winuser.h:1762
#define NULL
Definition: types.h:112
int nRows
Definition: appswitch.c:56
#define HIWORD(l)
Definition: typedefs.h:247
int selectedWindow
Definition: appswitch.c:44
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define CY_ITEM_SPACE
Definition: appswitch.c:33

Referenced by DoAppSwitch(), and SwitchWndProc_common().

◆ ResizeAndCenter()

void ResizeAndCenter ( HWND  hwnd,
int  width,
int  height 
)

Definition at line 89 of file appswitch.c.

90 {
91  int x, y;
92  RECT Rect;
93 
94  int screenwidth = GetSystemMetrics(SM_CXSCREEN);
95  int screenheight = GetSystemMetrics(SM_CYSCREEN);
96 
97  x = (screenwidth - width) / 2;
98  y = (screenheight - height) / 2;
99 
100  SetRect(&Rect, x, y, x + width, y + height);
102 
103  x = Rect.left;
104  y = Rect.top;
105  width = Rect.right - Rect.left;
106  height = Rect.bottom - Rect.top;
108 
109  ptStart.x = x;
110  ptStart.y = y;
111 }
GLint GLint GLsizei width
Definition: gl.h:1546
POINT ptStart
Definition: appswitch.c:60
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
BOOL WINAPI AdjustWindowRectEx(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL, _In_ DWORD)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define SM_CXSCREEN
Definition: winuser.h:953
#define FALSE
Definition: types.h:117
#define SM_CYSCREEN
Definition: winuser.h:954
const DWORD Style
Definition: appswitch.c:71
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4022
struct Rect Rect
const DWORD ExStyle
Definition: appswitch.c:72

Referenced by PrepareWindow().

◆ RotateTasks()

void RotateTasks ( BOOL  bShift)

Definition at line 490 of file appswitch.c.

491 {
492  HWND hwndFirst, hwndLast;
493  DWORD Size;
494 
495  if (windowCount < 2 || !Esc)
496  return;
497 
498  hwndFirst = windowList[0];
499  hwndLast = windowList[windowCount - 1];
500 
501  if (bShift)
502  {
503  SetWindowPos(hwndLast, HWND_TOP, 0, 0, 0, 0,
506 
507  SwitchToThisWindow(hwndLast, TRUE);
508 
509  Size = (windowCount - 1) * sizeof(HWND);
511  windowList[0] = hwndLast;
512  }
513  else
514  {
515  SetWindowPos(hwndFirst, hwndLast, 0, 0, 0, 0,
518 
520 
521  Size = (windowCount - 1) * sizeof(HWND);
523  windowList[windowCount - 1] = hwndFirst;
524  }
525 }
#define TRUE
Definition: types.h:120
BOOL Esc
Definition: appswitch.c:64
int windowCount
Definition: appswitch.c:53
volatile BOOLEAN bShift
Definition: shell.c:71
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define HWND_TOP
Definition: winuser.h:1197
#define MoveMemory
Definition: winbase.h:1661
#define SWP_ASYNCWINDOWPOS
Definition: winuser.h:1243
#define SWP_NOACTIVATE
Definition: winuser.h:1232
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SWP_NOSIZE
Definition: winuser.h:1235
#define SWP_NOREPOSITION
Definition: winuser.h:1240
HWND windowList[MAX_WINDOWS]
Definition: appswitch.c:51
#define SWP_NOMOVE
Definition: winuser.h:1234
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
VOID WINAPI SwitchToThisWindow(HWND hwnd, BOOL fAltTab)
Definition: window.c:82
#define SWP_NOOWNERZORDER
Definition: winuser.h:1239

Referenced by DoAppSwitch().

◆ SwitchWndProc_common()

LRESULT WINAPI SwitchWndProc_common ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL  unicode 
)

Definition at line 747 of file appswitch.c.

748 {
749  PWND pWnd;
750  PALTTABINFO ati;
751  pWnd = ValidateHwnd(hWnd);
752  if (pWnd)
753  {
754  if (!pWnd->fnid)
755  {
757  }
758  }
759 
760  switch (uMsg)
761  {
762  case WM_NCCREATE:
763  if (!(ati = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ati))))
764  return 0;
765  SetWindowLongPtrW( hWnd, 0, (LONG_PTR)ati );
766  return TRUE;
767 
768  case WM_SHOWWINDOW:
769  if (wParam)
770  {
771  PrepareWindow();
773  ati->cbSize = sizeof(ALTTABINFO);
774  ati->cItems = nItems;
775  ati->cColumns = nCols;
776  ati->cRows = nRows;
777  if (nCols)
778  {
779  ati->iColFocus = (selectedWindow - nShift) % nCols;
780  ati->iRowFocus = (selectedWindow - nShift) / nCols;
781  }
782  else
783  {
784  ati->iColFocus = 0;
785  ati->iRowFocus = 0;
786  }
787  ati->cxItem = CX_ITEM_SPACE;
788  ati->cyItem = CY_ITEM_SPACE;
789  ati->ptStart = ptStart;
790  }
791  return 0;
792 
793  case WM_MOUSEMOVE:
795  return 0;
796 
797  case WM_ACTIVATE:
798  if (wParam == WA_INACTIVE)
799  {
801  }
802  return 0;
803 
804  case WM_PAINT:
805  OnPaint(hWnd);
806  return 0;
807 
808  case WM_DESTROY:
809  isOpen = FALSE;
811  HeapFree( GetProcessHeap(), 0, ati );
812  SetWindowLongPtrW( hWnd, 0, 0 );
815  return 0;
816  }
817  return DefWindowProcW(hWnd, uMsg, wParam, lParam);
818 }
void CompleteSwitch(BOOL doSwitch)
Definition: appswitch.c:113
POINT ptStart
Definition: appswitch.c:60
int nCols
Definition: appswitch.c:56
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
BOOL isOpen
Definition: appswitch.c:45
#define WM_SHOWWINDOW
Definition: winuser.h:1615
#define GetWindowLongPtrW
Definition: winuser.h:4809
#define FNID_DESTROY
Definition: ntuser.h:868
#define WM_NCCREATE
Definition: winuser.h:1670
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
struct tagALTTABINFO * PALTTABINFO
POINT ptStart
Definition: winuser.h:3685
#define FALSE
Definition: types.h:117
DWORD fnid
Definition: ntuser.h:679
#define CX_ITEM_SPACE
Definition: appswitch.c:32
int nItems
Definition: appswitch.c:56
struct tagALTTABINFO ALTTABINFO
#define WM_DESTROY
Definition: winuser.h:1596
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define FNID_SWITCH
Definition: ntuser.h:835
int nShift
Definition: appswitch.c:62
#define WM_PAINT
Definition: winuser.h:1607
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:359
void PrepareWindow(VOID)
Definition: appswitch.c:433
Definition: ntuser.h:663
#define WM_ACTIVATE
Definition: winuser.h:1599
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WM_MOUSEMOVE
Definition: winuser.h:1762
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
void ProcessMouseMessage(UINT message, LPARAM lParam)
Definition: appswitch.c:277
int nRows
Definition: appswitch.c:56
DWORD cbSize
Definition: winuser.h:3677
BOOL NTAPI NtUserSetWindowFNID(HWND hWnd, WORD fnID)
Definition: window.c:4099
#define SetWindowLongPtrW
Definition: winuser.h:5326
#define WA_INACTIVE
Definition: winuser.h:2602
void OnPaint(HWND hWnd)
Definition: appswitch.c:304
int selectedWindow
Definition: appswitch.c:44
LPARAM lParam
Definition: combotst.c:139
#define HeapFree(x, y, z)
Definition: compat.h:594
VOID DestroyAppWindows(VOID)
Definition: appswitch.c:572
#define CY_ITEM_SPACE
Definition: appswitch.c:33

Referenced by SwitchWndProcA(), and SwitchWndProcW().

◆ SwitchWndProcA()

LRESULT WINAPI SwitchWndProcA ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 820 of file appswitch.c.

821 {
822  return SwitchWndProc_common(hWnd, uMsg, wParam, lParam, FALSE);
823 }
HWND hWnd
Definition: settings.c:17
LRESULT WINAPI SwitchWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL unicode)
Definition: appswitch.c:747
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
LPARAM lParam
Definition: combotst.c:139

Referenced by RegisterClientPFN().

◆ SwitchWndProcW()

LRESULT WINAPI SwitchWndProcW ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 825 of file appswitch.c.

826 {
827  return SwitchWndProc_common(hWnd, uMsg, wParam, lParam, TRUE);
828 }
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
LRESULT WINAPI SwitchWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL unicode)
Definition: appswitch.c:747
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139

Referenced by RegisterClientPFN().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( user32  )

Variable Documentation

◆ CoolSwitch

BOOL CoolSwitch = TRUE

Definition at line 66 of file appswitch.c.

Referenced by DoAppSwitch(), and LoadCoolSwitchSettings().

◆ CoolSwitchColumns

int CoolSwitchColumns = 7

Definition at line 68 of file appswitch.c.

Referenced by LoadCoolSwitchSettings(), OnPaint(), and PrepareWindow().

◆ CoolSwitchRows

int CoolSwitchRows = 3

Definition at line 67 of file appswitch.c.

Referenced by LoadCoolSwitchSettings(), and PrepareWindow().

◆ cxBorder

int cxBorder

Definition at line 55 of file appswitch.c.

◆ cyBorder

int cyBorder

Definition at line 55 of file appswitch.c.

◆ dialogFont

HFONT dialogFont

Definition at line 43 of file appswitch.c.

Referenced by GetDialogFont(), and OnPaint().

◆ Esc

BOOL Esc = FALSE

Definition at line 64 of file appswitch.c.

Referenced by DoAppSwitch(), and RotateTasks().

◆ ExStyle

◆ fontHeight

int fontHeight =0

Definition at line 47 of file appswitch.c.

Referenced by add_font(), GetDialogFont(), PrepareWindow(), and realize_font().

◆ iconList

HICON iconList[MAX_WINDOWS]

Definition at line 52 of file appswitch.c.

Referenced by DestroyAppWindows(), EnumerateCallback(), and OnPaint().

◆ isOpen

BOOL isOpen = FALSE

◆ itemsH

int itemsH

Definition at line 57 of file appswitch.c.

Referenced by OnPaint(), and PrepareWindow().

◆ itemsW

int itemsW

Definition at line 57 of file appswitch.c.

Referenced by OnPaint(), and PrepareWindow().

◆ nCols

◆ nItems

◆ nRows

◆ nShift

int nShift = 0

Definition at line 62 of file appswitch.c.

Referenced by OnPaint(), and SwitchWndProc_common().

◆ ptStart

◆ selectedWindow

◆ Style

◆ switchdialog

◆ totalH

int totalH

Definition at line 58 of file appswitch.c.

Referenced by OnPaint(), and PrepareWindow().

◆ totalW

int totalW

Definition at line 58 of file appswitch.c.

Referenced by OnPaint(), and PrepareWindow().

◆ windowCount

◆ windowList

HWND windowList[MAX_WINDOWS]

Definition at line 51 of file appswitch.c.

Referenced by CompleteSwitch(), EnumerateCallback(), OnPaint(), ProcessHotKey(), and RotateTasks().

◆ windowText

◆ xOffset

◆ yOffset