Quake II RTX doxygen  1.0 dev
client.c File Reference
#include "client.h"

Go to the source code of this file.

Macros

#define WINDOW_CLASS_NAME   "Quake 2 Pro"
 
#define MODE_SIZE   (1 << 0)
 
#define MODE_POS   (1 << 1)
 
#define MODE_STYLE   (1 << 2)
 
#define MODE_REPOSITION   (1 << 3)
 
#define BTN_DN(i)   (1<<(i*2+0))
 
#define BTN_UP(i)   (1<<(i*2+1))
 

Functions

static qboolean Win_InitMouse (void)
 
static void Win_ClipCursor (void)
 
static void Win_SetPosition (void)
 
void Win_ModeChanged (void)
 
static int modecmp (const void *p1, const void *p2)
 
static qboolean mode_is_sane (const DEVMODE *dm)
 
static qboolean modes_are_equal (const DEVMODE *base, const DEVMODE *compare)
 
char * VID_GetDefaultModeList (void)
 
static qboolean mode_is_current (const DEVMODE *dm)
 
static LONG set_fullscreen_mode (void)
 
void Win_SetMode (void)
 
void VID_UpdateGamma (const byte *table)
 
static void Win_DisableAltTab (void)
 
static void Win_EnableAltTab (void)
 
static void win_noalttab_changed (cvar_t *self)
 
static void Win_Activate (WPARAM wParam)
 
STATIC LRESULT CALLBACK LowLevelKeyboardProc (int nCode, WPARAM wParam, LPARAM lParam)
 
static void win_disablewinkey_changed (cvar_t *self)
 
static void legacy_key_event (WPARAM wParam, LPARAM lParam, qboolean down)
 
static void mouse_wheel_event (int delta)
 
static void mouse_hwheel_event (int delta)
 
static void legacy_mouse_event (WPARAM wParam)
 
static BOOL check_cursor_pos (void)
 
static void raw_mouse_event (PRAWMOUSE rm)
 
static void raw_input_event (HANDLE handle)
 
static void pos_changing_event (HWND wnd, WINDOWPOS *pos)
 
static void pos_changed_event (HWND wnd, WINDOWPOS *pos)
 
STATIC LONG WINAPI Win_MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
void VID_SetMode (void)
 
void VID_PumpEvents (void)
 
static void win_style_changed (cvar_t *self)
 
void Win_Init (void)
 
void Win_Shutdown (void)
 
static void Win_HideCursor (void)
 
static void Win_ShowCursor (void)
 
static void Win_AcquireMouse (void)
 
static void Win_DeAcquireMouse (void)
 
static qboolean Win_GetMouseMotion (int *dx, int *dy)
 
static BOOL register_raw_mouse (DWORD flags)
 
static void Win_ShutdownMouse (void)
 
static void win_xpfix_changed (cvar_t *self)
 
static void win_rawmouse_changed (cvar_t *self)
 
static void Win_GrabMouse (qboolean grab)
 
static void Win_WarpMouse (int x, int y)
 
char * VID_GetClipboardData (void)
 
void VID_SetClipboardData (const char *data)
 
void VID_FillInputAPI (inputAPI_t *api)
 

Variables

win_state_t win
 
static cvar_t * vid_flip_on_switch
 
static cvar_t * vid_hwgamma
 
static cvar_t * win_noalttab
 
static cvar_t * win_disablewinkey
 
static cvar_t * win_noresize
 
static cvar_t * win_notitle
 
static cvar_t * win_alwaysontop
 
static cvar_t * win_xpfix
 
static cvar_t * win_rawmouse
 
static const byte scantokey [2][96]
 

Macro Definition Documentation

◆ BTN_DN

#define BTN_DN (   i)    (1<<(i*2+0))

Definition at line 719 of file client.c.

◆ BTN_UP

#define BTN_UP (   i)    (1<<(i*2+1))

Definition at line 720 of file client.c.

◆ MODE_POS

#define MODE_POS   (1 << 1)

Definition at line 29 of file client.c.

◆ MODE_REPOSITION

#define MODE_REPOSITION   (1 << 3)

Definition at line 31 of file client.c.

◆ MODE_SIZE

#define MODE_SIZE   (1 << 0)

Definition at line 28 of file client.c.

◆ MODE_STYLE

#define MODE_STYLE   (1 << 2)

Definition at line 30 of file client.c.

◆ WINDOW_CLASS_NAME

#define WINDOW_CLASS_NAME   "Quake 2 Pro"

Definition at line 25 of file client.c.

Function Documentation

◆ check_cursor_pos()

static BOOL check_cursor_pos ( void  )
static

Definition at line 706 of file client.c.

707 {
708  POINT pt;
709 
710  if (win.mouse.grabbed)
711  return TRUE;
712 
713  if (!GetCursorPos(&pt))
714  return FALSE;
715 
716  return PtInRect(&win.screen_rc, pt);
717 }

Referenced by raw_mouse_event().

◆ legacy_key_event()

static void legacy_key_event ( WPARAM  wParam,
LPARAM  lParam,
qboolean  down 
)
static

Definition at line 598 of file client.c.

599 {
600  int scancode = (lParam >> 16) & 255;
601  int extended = (lParam >> 24) & 1;
602  byte result;
603 
604  if (scancode < 96)
605  result = scantokey[extended][scancode];
606  else
607  result = 0;
608 
609  if (!result) {
610  Com_DPrintf("%s: unknown %sscancode %d\n",
611  __func__, extended ? "extended " : "", scancode);
612  return;
613  }
614 
615  if (result == K_LALT || result == K_RALT)
616  Key_Event(K_ALT, down, win.lastMsgTime);
617  else if (result == K_LCTRL || result == K_RCTRL)
618  Key_Event(K_CTRL, down, win.lastMsgTime);
619  else if (result == K_LSHIFT || result == K_RSHIFT)
620  Key_Event(K_SHIFT, down, win.lastMsgTime);
621 
622  Key_Event(result, down, win.lastMsgTime);
623 }

Referenced by Win_MainWndProc().

◆ legacy_mouse_event()

static void legacy_mouse_event ( WPARAM  wParam)
static

Definition at line 670 of file client.c.

671 {
672  int i, mask, temp = 0;
673 
674  if (wParam & MK_LBUTTON)
675  temp |= 1;
676 
677  if (wParam & MK_RBUTTON)
678  temp |= 2;
679 
680  if (wParam & MK_MBUTTON)
681  temp |= 4;
682 
683  if (wParam & MK_XBUTTON1)
684  temp |= 8;
685 
686  if (wParam & MK_XBUTTON2)
687  temp |= 16;
688 
689  if (temp == win.mouse.state)
690  return;
691 
692  // perform button actions
693  for (i = 0, mask = 1; i < MOUSE_BUTTONS; i++, mask <<= 1) {
694  if ((temp & mask) && !(win.mouse.state & mask)) {
695  Key_Event(K_MOUSE1 + i, qtrue, win.lastMsgTime);
696  }
697  if (!(temp & mask) && (win.mouse.state & mask)) {
698  Key_Event(K_MOUSE1 + i, qfalse, win.lastMsgTime);
699  }
700  }
701 
702  win.mouse.state = temp;
703 }

Referenced by Win_MainWndProc().

◆ LowLevelKeyboardProc()

STATIC LRESULT CALLBACK LowLevelKeyboardProc ( int  nCode,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 513 of file client.c.

514 {
515  PKBDLLHOOKSTRUCT kb = (PKBDLLHOOKSTRUCT)lParam;
516  unsigned key;
517 
518  if (nCode != HC_ACTION) {
519  goto ignore;
520  }
521 
522  switch (kb->vkCode) {
523  case VK_LWIN:
524  key = K_LWINKEY;
525  break;
526  case VK_RWIN:
527  key = K_RWINKEY;
528  break;
529  default:
530  goto ignore;
531  }
532 
533  switch (wParam) {
534  case WM_KEYDOWN:
535  Key_Event(key, qtrue, kb->time);
536  return TRUE;
537  case WM_KEYUP:
538  Key_Event(key, qfalse, kb->time);
539  return TRUE;
540  default:
541  break;
542  }
543 
544 ignore:
545  return CallNextHookEx(NULL, nCode, wParam, lParam);
546 }

Referenced by win_disablewinkey_changed().

◆ mode_is_current()

static qboolean mode_is_current ( const DEVMODE *  dm)
static

Definition at line 268 of file client.c.

269 {
270  DEVMODE current;
271 
272  memset(&current, 0, sizeof(current));
273  current.dmSize = sizeof(current);
274 
275  if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &current))
276  return qfalse;
277 
278  return modes_are_equal(&current, dm);
279 }

Referenced by set_fullscreen_mode(), and Win_Activate().

◆ mode_is_sane()

static qboolean mode_is_sane ( const DEVMODE *  dm)
static

Definition at line 156 of file client.c.

157 {
158  // should have all these flags set
159  if (~dm->dmFields & (DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY))
160  return qfalse;
161 
162  // grayscale and interlaced modes are not supported
163  if (dm->dmDisplayFlags & (DM_GRAYSCALE | DM_INTERLACED))
164  return qfalse;
165 
166  // according to MSDN, frequency can be 0 or 1 for some weird hardware
167  if (dm->dmDisplayFrequency == 0 || dm->dmDisplayFrequency == 1)
168  return qfalse;
169 
170  return qtrue;
171 }

Referenced by modes_are_equal(), set_fullscreen_mode(), and VID_GetDefaultModeList().

◆ modecmp()

static int modecmp ( const void p1,
const void p2 
)
static

Definition at line 134 of file client.c.

135 {
136  const DEVMODE *dm1 = (const DEVMODE *)p1;
137  const DEVMODE *dm2 = (const DEVMODE *)p2;
138  DWORD size1 = dm1->dmPelsWidth * dm1->dmPelsHeight;
139  DWORD size2 = dm2->dmPelsWidth * dm2->dmPelsHeight;
140 
141  // sort from highest resolution to lowest
142  if (size1 < size2)
143  return 1;
144  if (size1 > size2)
145  return -1;
146 
147  // sort from highest frequency to lowest
148  if (dm1->dmDisplayFrequency < dm2->dmDisplayFrequency)
149  return 1;
150  if (dm1->dmDisplayFrequency > dm2->dmDisplayFrequency)
151  return -1;
152 
153  return 0;
154 }

Referenced by VID_GetDefaultModeList().

◆ modes_are_equal()

static qboolean modes_are_equal ( const DEVMODE *  base,
const DEVMODE *  compare 
)
static

Definition at line 173 of file client.c.

174 {
175  if (!mode_is_sane(base))
176  return qfalse;
177 
178  if ((compare->dmFields & DM_PELSWIDTH) && base->dmPelsWidth != compare->dmPelsWidth)
179  return qfalse;
180 
181  if ((compare->dmFields & DM_PELSHEIGHT) && base->dmPelsHeight != compare->dmPelsHeight)
182  return qfalse;
183 
184  if ((compare->dmFields & DM_BITSPERPEL) && base->dmBitsPerPel != compare->dmBitsPerPel)
185  return qfalse;
186 
187  if ((compare->dmFields & DM_DISPLAYFREQUENCY) && base->dmDisplayFrequency != compare->dmDisplayFrequency)
188  return qfalse;
189 
190  return qtrue;
191 }

Referenced by mode_is_current(), set_fullscreen_mode(), and VID_GetDefaultModeList().

◆ mouse_hwheel_event()

static void mouse_hwheel_event ( int  delta)
static

Definition at line 651 of file client.c.

652 {
653  UINT key;
654 
655  // FIXME: handle WHEEL_DELTA and partial scrolls...
656  if (delta > 0) {
657  key = K_MWHEELRIGHT;
658  } else if (delta < 0) {
659  key = K_MWHEELLEFT;
660  } else {
661  return;
662  }
663 
664  Key_Event(key, qtrue, win.lastMsgTime);
665  Key_Event(key, qfalse, win.lastMsgTime);
666 }

Referenced by raw_mouse_event(), and Win_MainWndProc().

◆ mouse_wheel_event()

static void mouse_wheel_event ( int  delta)
static

Definition at line 625 of file client.c.

626 {
627  UINT lines, key;
628 
629  // FIXME: handle WHEEL_DELTA and partial scrolls...
630  if (delta > 0) {
631  key = K_MWHEELUP;
632  } else if (delta < 0) {
633  key = K_MWHEELDOWN;
634  } else {
635  return;
636  }
637 
638  if (Key_GetDest() & KEY_CONSOLE) {
639  SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &lines, 0);
640  clamp(lines, 1, 9);
641  } else {
642  lines = 1;
643  }
644 
645  do {
646  Key_Event(key, qtrue, win.lastMsgTime);
647  Key_Event(key, qfalse, win.lastMsgTime);
648  } while (--lines);
649 }

Referenced by raw_mouse_event(), and Win_MainWndProc().

◆ pos_changed_event()

static void pos_changed_event ( HWND  wnd,
WINDOWPOS *  pos 
)
static

Definition at line 821 of file client.c.

822 {
823  RECT rc;
824 
825  // get window position
826  GetWindowRect(wnd, &rc);
827  win.rc.x = rc.left;
828  win.rc.y = rc.top;
829 
830  // get size of client area
831  GetClientRect(wnd, &rc);
832  win.rc.width = rc.right - rc.left;
833  win.rc.height = rc.bottom - rc.top;
834 
835  // get rectangle of client area in screen coordinates
836  MapWindowPoints(wnd, NULL, (POINT *)&rc, 2);
837  win.screen_rc = rc;
838  win.center_x = (rc.right + rc.left) / 2;
839  win.center_y = (rc.top + rc.bottom) / 2;
840 
841  // set mode_changed flags unless in full screen
842  if (win.flags & QVF_FULLSCREEN)
843  return;
844 
845  if (!pos) {
846  win.mode_changed |= MODE_STYLE;
847  return;
848  }
849 
850  if (!(pos->flags & SWP_NOSIZE))
851  win.mode_changed |= MODE_SIZE;
852 
853  if (!(pos->flags & SWP_NOMOVE))
854  win.mode_changed |= MODE_POS;
855 }

Referenced by Win_MainWndProc().

◆ pos_changing_event()

static void pos_changing_event ( HWND  wnd,
WINDOWPOS *  pos 
)
static

Definition at line 783 of file client.c.

784 {
785  int w, h, nc_w, nc_h;
786  LONG style;
787  RECT rc;
788 
789  if (win.flags & QVF_FULLSCREEN)
790  return;
791 
792  if (pos->flags & SWP_NOSIZE)
793  return;
794 
795  style = GetWindowLong(wnd, GWL_STYLE);
796 
797  // calculate size of non-client area
798  rc.left = 0;
799  rc.top = 0;
800  rc.right = 1;
801  rc.bottom = 1;
802 
803  AdjustWindowRect(&rc, style, FALSE);
804 
805  nc_w = rc.right - rc.left - 1;
806  nc_h = rc.bottom - rc.top - 1;
807 
808  // align client area
809  w = (pos->cx - nc_w) & ~7;
810  h = (pos->cy - nc_h) & ~1;
811 
812  // don't allow too small size
813  if (w < 320) w = 320;
814  if (h < 240) h = 240;
815 
816  // convert back to window size
817  pos->cx = w + nc_w;
818  pos->cy = h + nc_h;
819 }

Referenced by Win_MainWndProc().

◆ raw_input_event()

static void raw_input_event ( HANDLE  handle)
static

Definition at line 764 of file client.c.

765 {
766  BYTE buffer[64];
767  UINT len, ret;
768  PRAWINPUT ri;
769 
770  len = sizeof(buffer);
771  ret = GetRawInputData(handle, RID_INPUT, buffer, &len, sizeof(RAWINPUTHEADER));
772  if (ret == (UINT) - 1) {
773  Com_EPrintf("GetRawInputData failed with error %#lx\n", GetLastError());
774  return;
775  }
776 
777  ri = (PRAWINPUT)buffer;
778  if (ri->header.dwType == RIM_TYPEMOUSE) {
779  raw_mouse_event(&ri->data.mouse);
780  }
781 }

Referenced by Win_MainWndProc().

◆ raw_mouse_event()

static void raw_mouse_event ( PRAWMOUSE  rm)
static

Definition at line 722 of file client.c.

723 {
724  int i;
725 
726  if (!check_cursor_pos()) {
727  // cursor is over non-client area
728  // perform just button up actions
729  for (i = 0; i < MOUSE_BUTTONS; i++) {
730  if (rm->usButtonFlags & BTN_UP(i)) {
731  Key_Event(K_MOUSE1 + i, qfalse, win.lastMsgTime);
732  }
733  }
734  return;
735  }
736 
737  if (rm->usButtonFlags) {
738  // perform button actions
739  for (i = 0; i < MOUSE_BUTTONS; i++) {
740  if (rm->usButtonFlags & BTN_DN(i)) {
741  Key_Event(K_MOUSE1 + i, qtrue, win.lastMsgTime);
742  }
743  if (rm->usButtonFlags & BTN_UP(i)) {
744  Key_Event(K_MOUSE1 + i, qfalse, win.lastMsgTime);
745  }
746  }
747 
748  if (rm->usButtonFlags & RI_MOUSE_WHEEL) {
749  mouse_wheel_event((short)rm->usButtonData);
750  }
751 
752  // this flag is undocumented, but confirmed to work on Win7
753  if (rm->usButtonFlags & 0x0800) {
754  mouse_hwheel_event((short)rm->usButtonData);
755  }
756  }
757 
758  if ((rm->usFlags & (MOUSE_MOVE_RELATIVE | MOUSE_MOVE_ABSOLUTE)) == MOUSE_MOVE_RELATIVE) {
759  win.mouse.mx += rm->lLastX;
760  win.mouse.my += rm->lLastY;
761  }
762 }

Referenced by raw_input_event().

◆ register_raw_mouse()

static BOOL register_raw_mouse ( DWORD  flags)
static

Definition at line 1210 of file client.c.

1211 {
1212  RAWINPUTDEVICE rid;
1213 
1214  memset(&rid, 0, sizeof(rid));
1215  rid.usUsagePage = 0x01;
1216  rid.usUsage = 0x02;
1217  rid.dwFlags = flags;
1218  rid.hwndTarget = win.wnd;
1219 
1220  return RegisterRawInputDevices(&rid, 1, sizeof(rid));
1221 }

Referenced by Win_InitMouse(), and Win_ShutdownMouse().

◆ set_fullscreen_mode()

static LONG set_fullscreen_mode ( void  )
static

Definition at line 281 of file client.c.

282 {
283  DEVMODE desktop, dm;
284  LONG ret;
285  int freq, depth;
286 
287  memset(&desktop, 0, sizeof(desktop));
288  desktop.dmSize = sizeof(desktop);
289 
290  EnumDisplaySettings(NULL, ENUM_REGISTRY_SETTINGS, &desktop);
291 
292  // parse vid_modelist specification
293  if (VID_GetFullscreen(&win.rc, &freq, &depth)) {
294  Com_DPrintf("...setting fullscreen mode: %dx%d\n",
295  win.rc.width, win.rc.height);
296  } else if (mode_is_sane(&desktop)) {
297  win.rc.width = desktop.dmPelsWidth;
298  win.rc.height = desktop.dmPelsHeight;
299  Com_DPrintf("...falling back to desktop mode: %dx%d\n",
300  win.rc.width, win.rc.height);
301  } else {
302  Com_DPrintf("...falling back to default mode: %dx%d\n",
303  win.rc.width, win.rc.height);
304  }
305 
306  memset(&dm, 0, sizeof(dm));
307  dm.dmSize = sizeof(dm);
308  dm.dmPelsWidth = win.rc.width;
309  dm.dmPelsHeight = win.rc.height;
310  dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
311 
312  if (freq) {
313  dm.dmDisplayFrequency = freq;
314  dm.dmFields |= DM_DISPLAYFREQUENCY;
315  Com_DPrintf("...using display frequency of %d\n", freq);
316  } else if (modes_are_equal(&desktop, &dm)) {
317  dm.dmDisplayFrequency = desktop.dmDisplayFrequency;
318  dm.dmFields |= DM_DISPLAYFREQUENCY;
319  Com_DPrintf("...using desktop display frequency of %d\n", freq);
320  }
321 
322  if (depth) {
323  dm.dmBitsPerPel = depth;
324  dm.dmFields |= DM_BITSPERPEL;
325  Com_DPrintf("...using bitdepth of %d\n", depth);
326  } else if (mode_is_sane(&desktop)) {
327  dm.dmBitsPerPel = desktop.dmBitsPerPel;
328  dm.dmFields |= DM_BITSPERPEL;
329  Com_DPrintf("...using desktop bitdepth of %lu\n", desktop.dmBitsPerPel);
330  }
331 
332  if (mode_is_current(&dm)) {
333  Com_DPrintf("...skipping CDS\n");
334  ret = DISP_CHANGE_SUCCESSFUL;
335  } else {
336  Com_DPrintf("...calling CDS: ");
337  ret = ChangeDisplaySettings(&dm, CDS_FULLSCREEN);
338  if (ret != DISP_CHANGE_SUCCESSFUL) {
339  Com_DPrintf("failed with error %ld\n", ret);
340  return ret;
341  }
342  Com_DPrintf("ok\n");
343  }
344 
345  win.dm = dm;
346  win.flags |= QVF_FULLSCREEN;
347  Win_SetPosition();
348  win.mode_changed = 0;
349 
350  return ret;
351 }

Referenced by Win_SetMode().

◆ VID_FillInputAPI()

void VID_FillInputAPI ( inputAPI_t *  api)

Definition at line 1388 of file client.c.

1389 {
1390  api->Init = Win_InitMouse;
1391  api->Shutdown = Win_ShutdownMouse;
1392  api->Grab = Win_GrabMouse;
1393  api->Warp = Win_WarpMouse;
1394  api->GetEvents = NULL;
1395  api->GetMotion = Win_GetMouseMotion;
1396 }

Referenced by IN_Init().

◆ VID_GetClipboardData()

char* VID_GetClipboardData ( void  )

Definition at line 1327 of file client.c.

1328 {
1329  HANDLE clipdata;
1330  char *cliptext, *data;
1331 
1332  if (!OpenClipboard(NULL)) {
1333  Com_DPrintf("Couldn't open clipboard.\n");
1334  return NULL;
1335  }
1336 
1337  data = NULL;
1338  if ((clipdata = GetClipboardData(CF_TEXT)) != NULL) {
1339  if ((cliptext = GlobalLock(clipdata)) != NULL) {
1340  data = Z_CopyString(cliptext);
1341  GlobalUnlock(clipdata);
1342  }
1343  }
1344 
1345  CloseClipboard();
1346  return data;
1347 }

Referenced by Con_Paste().

◆ VID_GetDefaultModeList()

char* VID_GetDefaultModeList ( void  )

Definition at line 198 of file client.c.

199 {
200  DEVMODE desktop, dm, *modes;
201  int i, j, num_modes, max_modes;
202  size_t size, len;
203  char *buf;
204 
205  memset(&desktop, 0, sizeof(desktop));
206  desktop.dmSize = sizeof(desktop);
207 
208  if (!EnumDisplaySettings(NULL, ENUM_REGISTRY_SETTINGS, &desktop))
209  return Z_CopyString(VID_MODELIST);
210 
211  modes = NULL;
212  num_modes = 0;
213  max_modes = 0;
214  for (i = 0; i < 4096; i++) {
215  memset(&dm, 0, sizeof(dm));
216  dm.dmSize = sizeof(dm);
217  if (!EnumDisplaySettings(NULL, i, &dm))
218  break;
219 
220  // sanity check
221  if (!mode_is_sane(&dm))
222  continue;
223 
224  // completely ignore non-desktop bit depths for now
225  if (dm.dmBitsPerPel != desktop.dmBitsPerPel)
226  continue;
227 
228  // skip duplicate modes
229  for (j = 0; j < num_modes; j++)
230  if (modes_are_equal(&modes[j], &dm))
231  break;
232  if (j != num_modes)
233  continue;
234 
235  if (num_modes == max_modes) {
236  max_modes += 32;
237  modes = Z_Realloc(modes, sizeof(modes[0]) * max_modes);
238  }
239 
240  modes[num_modes++] = dm;
241  }
242 
243  if (!num_modes)
244  return Z_CopyString(VID_MODELIST);
245 
246  qsort(modes, num_modes, sizeof(modes[0]), modecmp);
247 
248  size = 8 + num_modes * 32 + 1;
249  buf = Z_Malloc(size);
250 
251  len = Q_strlcpy(buf, "desktop ", size);
252  for (i = 0; i < num_modes; i++) {
253  len += Q_scnprintf(buf + len, size - len, "%lux%lu@%lu",
254  modes[i].dmPelsWidth,
255  modes[i].dmPelsHeight,
256  modes[i].dmDisplayFrequency);
257  if (len < size - 1 && i < num_modes - 1)
258  buf[len++] = ' ';
259  }
260  buf[len] = 0;
261 
262  Z_Free(modes);
263 
264  return buf;
265 }

Referenced by CL_InitRefresh().

◆ VID_PumpEvents()

void VID_PumpEvents ( void  )

Definition at line 971 of file client.c.

972 {
973  MSG msg;
974 
975  while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
976  if (msg.message == WM_QUIT) {
977  Com_Quit(NULL, ERR_DISCONNECT);
978  break;
979  }
980  win.lastMsgTime = msg.time;
981  TranslateMessage(&msg);
982  DispatchMessage(&msg);
983  }
984 
985  if (win.mode_changed) {
986  if (win.mode_changed & MODE_REPOSITION) {
987  Win_SetPosition();
988  }
989  if (win.mode_changed & (MODE_SIZE | MODE_POS | MODE_STYLE)) {
990  VID_SetGeometry(&win.rc);
991  if (win.mouse.grabbed) {
992  Win_ClipCursor();
993  }
994  }
995  if (win.mode_changed & MODE_SIZE) {
996  Win_ModeChanged();
997  }
998  win.mode_changed = 0;
999  }
1000 }

Referenced by CL_LoadState(), and CL_RunRefresh().

◆ VID_SetClipboardData()

void VID_SetClipboardData ( const char *  data)

Definition at line 1354 of file client.c.

1355 {
1356  HANDLE clipdata;
1357  char *cliptext;
1358  size_t length;
1359 
1360  if (!data || !*data) {
1361  return;
1362  }
1363 
1364  if (!OpenClipboard(NULL)) {
1365  Com_DPrintf("Couldn't open clipboard.\n");
1366  return;
1367  }
1368 
1369  EmptyClipboard();
1370 
1371  length = strlen(data) + 1;
1372  if ((clipdata = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, length)) != NULL) {
1373  if ((cliptext = GlobalLock(clipdata)) != NULL) {
1374  memcpy(cliptext, data, length);
1375  GlobalUnlock(clipdata);
1376  SetClipboardData(CF_TEXT, clipdata);
1377  }
1378  }
1379 
1380  CloseClipboard();
1381 }

Referenced by CopyAddress().

◆ VID_SetMode()

void VID_SetMode ( void  )

Definition at line 960 of file client.c.

961 {
962  Win_SetMode();
963  Win_ModeChanged();
964 }

Referenced by CL_RunRefresh(), and VID_Init().

◆ VID_UpdateGamma()

void VID_UpdateGamma ( const byte *  table)

Definition at line 413 of file client.c.

414 {
415  WORD v;
416  int i;
417 
418  if (win.flags & QVF_GAMMARAMP) {
419  for (i = 0; i < 256; i++) {
420  v = table[i] << 8;
421  win.gamma_cust[0][i] = v;
422  win.gamma_cust[1][i] = v;
423  win.gamma_cust[2][i] = v;
424  }
425 
426  SetDeviceGammaRamp(win.dc, win.gamma_cust);
427  }
428 }

Referenced by gl_gamma_changed().

◆ Win_AcquireMouse()

static void Win_AcquireMouse ( void  )
static

Definition at line 1142 of file client.c.

1143 {
1144  int parms[3];
1145 
1146  if (win.mouse.parmsvalid) {
1147  if (win_xpfix->integer) {
1148  parms[0] = parms[1] = parms[2] = 0;
1149  } else {
1150  parms[0] = parms[1] = 0;
1151  parms[2] = 1;
1152  }
1153  win.mouse.restoreparms = SystemParametersInfo(
1154  SPI_SETMOUSE, 0, parms, 0);
1155  }
1156 
1157  Win_ClipCursor();
1158  SetCapture(win.wnd);
1159 
1160  SetWindowText(win.wnd, "[" PRODUCT "]");
1161 }

Referenced by Win_GrabMouse(), and win_xpfix_changed().

◆ Win_Activate()

static void Win_Activate ( WPARAM  wParam)
static

Definition at line 457 of file client.c.

458 {
459  active_t active;
460 
461  if (HIWORD(wParam)) {
462  // we don't want to act like we're active if we're minimized
463  active = ACT_MINIMIZED;
464  } else {
465  if (LOWORD(wParam)) {
466  active = ACT_ACTIVATED;
467  } else {
468  active = ACT_RESTORED;
469  }
470  }
471 
472  CL_Activate(active);
473 
474  if (win_noalttab->integer) {
475  if (active == ACT_ACTIVATED) {
477  } else {
479  }
480  }
481 
482  if (win.flags & QVF_GAMMARAMP) {
483  if (active == ACT_ACTIVATED) {
484  SetDeviceGammaRamp(win.dc, win.gamma_cust);
485  } else {
486  SetDeviceGammaRamp(win.dc, win.gamma_orig);
487  }
488  }
489 
490  if (win.flags & QVF_FULLSCREEN) {
491  if (active == ACT_ACTIVATED) {
492  ShowWindow(win.wnd, SW_RESTORE);
493  } else {
494  ShowWindow(win.wnd, SW_MINIMIZE);
495  }
496 
497  if (vid_flip_on_switch->integer) {
498  if (active == ACT_ACTIVATED) {
499  if (!mode_is_current(&win.dm)) {
500  ChangeDisplaySettings(&win.dm, CDS_FULLSCREEN);
501  }
502  } else {
503  ChangeDisplaySettings(NULL, 0);
504  }
505  }
506  }
507 
508  if (active == ACT_ACTIVATED) {
509  SetForegroundWindow(win.wnd);
510  }
511 }

Referenced by Win_MainWndProc().

◆ Win_ClipCursor()

static void Win_ClipCursor ( void  )
static

Definition at line 1135 of file client.c.

1136 {
1137  SetCursorPos(win.center_x, win.center_y);
1138  ClipCursor(&win.screen_rc);
1139 }

Referenced by VID_PumpEvents(), Win_AcquireMouse(), and Win_SetPosition().

◆ Win_DeAcquireMouse()

static void Win_DeAcquireMouse ( void  )
static

Definition at line 1164 of file client.c.

1165 {
1166  if (win.mouse.restoreparms)
1167  SystemParametersInfo(SPI_SETMOUSE, 0, win.mouse.originalparms, 0);
1168 
1169  SetCursorPos(win.center_x, win.center_y);
1170 
1171  ClipCursor(NULL);
1172  ReleaseCapture();
1173 
1174  SetWindowText(win.wnd, PRODUCT);
1175 }

Referenced by Win_GrabMouse(), and Win_ShutdownMouse().

◆ Win_DisableAltTab()

static void Win_DisableAltTab ( void  )
static

Definition at line 430 of file client.c.

431 {
432  if (!win.alttab_disabled) {
433  RegisterHotKey(0, 0, MOD_ALT, VK_TAB);
434  RegisterHotKey(0, 1, MOD_ALT, VK_RETURN);
435  win.alttab_disabled = qtrue;
436  }
437 }

Referenced by Win_Activate(), and win_noalttab_changed().

◆ win_disablewinkey_changed()

static void win_disablewinkey_changed ( cvar_t *  self)
static

Definition at line 548 of file client.c.

549 {
550  if (self->integer) {
551  win.kbdHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, hGlobalInstance, 0);
552  if (!win.kbdHook) {
553  Com_EPrintf("Couldn't set low-level keyboard hook, error %#lX\n", GetLastError());
554  Cvar_Set("win_disablewinkey", "0");
555  }
556  } else {
557  if (win.kbdHook) {
558  UnhookWindowsHookEx(win.kbdHook);
559  win.kbdHook = NULL;
560  }
561  }
562 }

Referenced by Win_Init().

◆ Win_EnableAltTab()

static void Win_EnableAltTab ( void  )
static

Definition at line 439 of file client.c.

440 {
441  if (win.alttab_disabled) {
442  UnregisterHotKey(0, 0);
443  UnregisterHotKey(0, 1);
444  win.alttab_disabled = qfalse;
445  }
446 }

Referenced by Win_Activate(), and win_noalttab_changed().

◆ Win_GetMouseMotion()

static qboolean Win_GetMouseMotion ( int dx,
int dy 
)
static

Definition at line 1177 of file client.c.

1178 {
1179  POINT pt;
1180 
1181  if (!win.mouse.initialized) {
1182  return qfalse;
1183  }
1184 
1185  if (!win.mouse.grabbed) {
1186  return qfalse;
1187  }
1188 
1189  if (win.mouse.initialized == WIN_MOUSE_RAW) {
1190  *dx = win.mouse.mx;
1191  *dy = win.mouse.my;
1192  win.mouse.mx = 0;
1193  win.mouse.my = 0;
1194  return qtrue;
1195  }
1196 
1197  // find mouse movement
1198  if (!GetCursorPos(&pt)) {
1199  return qfalse;
1200  }
1201 
1202  *dx = pt.x - win.center_x;
1203  *dy = pt.y - win.center_y;
1204 
1205  // force the mouse to the center, so there's room to move
1206  SetCursorPos(win.center_x, win.center_y);
1207  return qtrue;
1208 }

Referenced by VID_FillInputAPI().

◆ Win_GrabMouse()

static void Win_GrabMouse ( qboolean  grab)
static

Definition at line 1288 of file client.c.

1289 {
1290  if (!win.mouse.initialized) {
1291  return;
1292  }
1293 
1294  if (win.mouse.grabbed == grab) {
1295  if (win.mouse.initialized == WIN_MOUSE_LEGACY) {
1296  SetCursorPos(win.center_x, win.center_y);
1297  }
1298  win.mouse.mx = 0;
1299  win.mouse.my = 0;
1300  return;
1301  }
1302 
1303  if (grab) {
1304  Win_AcquireMouse();
1305  Win_HideCursor();
1306  } else {
1308  Win_ShowCursor();
1309  }
1310 
1311  win.mouse.grabbed = grab;
1312  win.mouse.state = 0;
1313  win.mouse.mx = 0;
1314  win.mouse.my = 0;
1315 }

Referenced by VID_FillInputAPI().

◆ Win_HideCursor()

static void Win_HideCursor ( void  )
static

Definition at line 1122 of file client.c.

1123 {
1124  while (ShowCursor(FALSE) >= 0)
1125  ;
1126 }

Referenced by Win_GrabMouse().

◆ Win_Init()

void Win_Init ( void  )

Definition at line 1014 of file client.c.

1015 {
1016  WNDCLASSEX wc;
1017 
1018  // register variables
1019  vid_flip_on_switch = Cvar_Get("vid_flip_on_switch", "0", 0);
1020  vid_hwgamma = Cvar_Get("vid_hwgamma", "0", CVAR_REFRESH);
1021  win_noalttab = Cvar_Get("win_noalttab", "0", CVAR_ARCHIVE);
1023  win_disablewinkey = Cvar_Get("win_disablewinkey", "0", 0);
1025  win_noresize = Cvar_Get("win_noresize", "0", 0);
1026  win_noresize->changed = win_style_changed;
1027  win_notitle = Cvar_Get("win_notitle", "0", 0);
1028  win_notitle->changed = win_style_changed;
1029  win_alwaysontop = Cvar_Get("win_alwaysontop", "0", 0);
1031  win_xpfix = Cvar_Get("win_xpfix", "0", 0);
1032  win_rawmouse = Cvar_Get("win_rawmouse", "1", 0);
1033 
1035 
1036  // register the frame class
1037  memset(&wc, 0, sizeof(wc));
1038  wc.cbSize = sizeof(wc);
1039  wc.lpfnWndProc = (WNDPROC)Win_MainWndProc;
1040  wc.hInstance = hGlobalInstance;
1041  wc.hIcon = LoadImage(hGlobalInstance, MAKEINTRESOURCE(IDI_APP),
1042  IMAGE_ICON, 32, 32, LR_CREATEDIBSECTION);
1043  wc.hIconSm = LoadImage(hGlobalInstance, MAKEINTRESOURCE(IDI_APP),
1044  IMAGE_ICON, 16, 16, LR_CREATEDIBSECTION);
1045  wc.hCursor = LoadCursor(NULL, IDC_ARROW);
1046  wc.hbrBackground = GetStockObject(BLACK_BRUSH);
1047  wc.lpszClassName = _T(WINDOW_CLASS_NAME);
1048 
1049  if (!RegisterClassEx(&wc)) {
1050  Com_Error(ERR_FATAL, "Couldn't register main window class");
1051  }
1052 
1053  // create the window
1054  win.wnd = CreateWindow(
1055  _T(WINDOW_CLASS_NAME),
1056  _T(PRODUCT),
1057  0, //style
1058  0, 0, 0, 0,
1059  NULL,
1060  NULL,
1062  NULL);
1063 
1064  if (!win.wnd) {
1065  Com_Error(ERR_FATAL, "Couldn't create main window");
1066  }
1067 
1068  win.dc = GetDC(win.wnd);
1069  if (!win.dc) {
1070  Com_Error(ERR_FATAL, "Couldn't get DC of the main window");
1071  }
1072 
1073  // init gamma ramp
1074  if (vid_hwgamma->integer) {
1075  if (GetDeviceGammaRamp(win.dc, win.gamma_orig)) {
1076  Com_DPrintf("...enabling hardware gamma\n");
1077  win.flags |= QVF_GAMMARAMP;
1078  memcpy(win.gamma_cust, win.gamma_orig, sizeof(win.gamma_cust));
1079  } else {
1080  Com_DPrintf("...hardware gamma not supported\n");
1081  Cvar_Set("vid_hwgamma", "0");
1082  }
1083  }
1084 }

Referenced by SetupGL(), and VID_Init().

◆ Win_InitMouse()

static qboolean Win_InitMouse ( void  )
static

Definition at line 1257 of file client.c.

1258 {
1259  if (!win.wnd) {
1260  return qfalse;
1261  }
1262 
1263  win.mouse.initialized = WIN_MOUSE_LEGACY;
1264 
1265  if (win_rawmouse->integer) {
1266  if (!register_raw_mouse(/*RIDEV_NOLEGACY*/ 0)) {
1267  Com_EPrintf("RegisterRawInputDevices failed with error %#lx\n", GetLastError());
1268  Cvar_Set("win_rawmouse", "0");
1269  } else {
1270  Com_Printf("Raw mouse initialized.\n");
1271  win.mouse.initialized = WIN_MOUSE_RAW;
1272  }
1273  }
1274 
1275  if (win.mouse.initialized == WIN_MOUSE_LEGACY) {
1276  win.mouse.parmsvalid = SystemParametersInfo(SPI_GETMOUSE, 0,
1277  win.mouse.originalparms, 0);
1278  win_xpfix->changed = win_xpfix_changed;
1279  Com_Printf("Legacy mouse initialized.\n");
1280  }
1281 
1283 
1284  return qtrue;
1285 }

Referenced by VID_FillInputAPI(), and win_rawmouse_changed().

◆ Win_MainWndProc()

STATIC LONG WINAPI Win_MainWndProc ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 858 of file client.c.

859 {
860  switch (uMsg) {
861  case WM_MOUSEWHEEL:
862  if (win.mouse.initialized == WIN_MOUSE_LEGACY)
863  mouse_wheel_event((short)HIWORD(wParam));
864  break;
865 
866  case WM_MOUSEHWHEEL:
867  if (win.mouse.initialized == WIN_MOUSE_LEGACY)
868  mouse_hwheel_event((short)HIWORD(wParam));
869  break;
870 
871  case WM_MOUSEMOVE:
872  if (win.mouse.initialized)
873  UI_MouseEvent((short)LOWORD(lParam), (short)HIWORD(lParam));
874  // fall through
875 
876  case WM_LBUTTONDOWN:
877  case WM_LBUTTONUP:
878  case WM_RBUTTONDOWN:
879  case WM_RBUTTONUP:
880  case WM_MBUTTONDOWN:
881  case WM_MBUTTONUP:
882  case WM_XBUTTONDOWN:
883  case WM_XBUTTONUP:
884  if (win.mouse.initialized == WIN_MOUSE_LEGACY)
885  legacy_mouse_event(wParam);
886  break;
887 
888  case WM_HOTKEY:
889  return FALSE;
890 
891  case WM_INPUT:
892  if (wParam == RIM_INPUT && win.mouse.initialized == WIN_MOUSE_RAW)
893  raw_input_event((HANDLE)lParam);
894  break;
895 
896  case WM_CLOSE:
897  PostQuitMessage(0);
898  return FALSE;
899 
900  case WM_ACTIVATE:
901  Win_Activate(wParam);
902  break;
903 
904  case WM_WINDOWPOSCHANGING:
905  pos_changing_event(hWnd, (WINDOWPOS *)lParam);
906  break;
907 
908  case WM_WINDOWPOSCHANGED:
909  pos_changed_event(hWnd, (WINDOWPOS *)lParam);
910  return FALSE;
911 
912  case WM_STYLECHANGED:
913  case WM_THEMECHANGED:
914  pos_changed_event(hWnd, NULL);
915  break;
916 
917  case WM_SYSCOMMAND:
918  switch (wParam & 0xFFF0) {
919  case SC_SCREENSAVE:
920  return FALSE;
921  case SC_MAXIMIZE:
922  if (!vid_fullscreen->integer)
924  return FALSE;
925  }
926  break;
927 
928  case WM_KEYDOWN:
929  case WM_SYSKEYDOWN:
930  legacy_key_event(wParam, lParam, qtrue);
931  return FALSE;
932 
933  case WM_KEYUP:
934  case WM_SYSKEYUP:
935  legacy_key_event(wParam, lParam, qfalse);
936  return FALSE;
937 
938  case WM_SYSCHAR:
939  case WM_CHAR:
940  return FALSE;
941 
942  case WM_ERASEBKGND:
943  if (win.flags & QVF_FULLSCREEN)
944  return FALSE;
945  break;
946 
947  default:
948  break;
949  }
950 
951  // pass all unhandled messages to DefWindowProc
952  return DefWindowProc(hWnd, uMsg, wParam, lParam);
953 }

Referenced by Win_Init().

◆ Win_ModeChanged()

void Win_ModeChanged ( void  )

Definition at line 123 of file client.c.

124 {
125 #if USE_REF == REF_SOFT
126  void SWimp_ModeChanged(void);
128 #endif
129  R_ModeChanged(win.rc.width, win.rc.height, win.flags,
130  win.pitch, win.buffer);
131  SCR_ModeChanged();
132 }

Referenced by VID_Init(), VID_PumpEvents(), and VID_SetMode().

◆ win_noalttab_changed()

static void win_noalttab_changed ( cvar_t *  self)
static

Definition at line 448 of file client.c.

449 {
450  if (self->integer) {
452  } else {
454  }
455 }

Referenced by Win_Init().

◆ win_rawmouse_changed()

static void win_rawmouse_changed ( cvar_t *  self)
static

Definition at line 1249 of file client.c.

1250 {
1251  if (win.mouse.initialized) {
1253  Win_InitMouse();
1254  }
1255 }

Referenced by Win_InitMouse().

◆ Win_SetMode()

void Win_SetMode ( void  )

Definition at line 358 of file client.c.

359 {
360  // set full screen mode if requested
361  if (vid_fullscreen->integer > 0) {
362  LONG ret;
363 
364  ret = set_fullscreen_mode();
365  switch (ret) {
366  case DISP_CHANGE_SUCCESSFUL:
367  return;
368  case DISP_CHANGE_FAILED:
369  Com_EPrintf("Display driver failed the %dx%d video mode.\n", win.rc.width, win.rc.height);
370  break;
371  case DISP_CHANGE_BADMODE:
372  Com_EPrintf("Video mode %dx%d is not supported.\n", win.rc.width, win.rc.height);
373  break;
374  default:
375  Com_EPrintf("Video mode %dx%d failed with error %ld.\n", win.rc.width, win.rc.height, ret);
376  break;
377  }
378 
379  // fall back to windowed mode
380  Cvar_Reset(vid_fullscreen);
381  }
382 
383  ChangeDisplaySettings(NULL, 0);
384 
385  // parse vid_geometry specification
386  VID_GetGeometry(&win.rc);
387 
388  // align client area
389  win.rc.width &= ~7;
390  win.rc.height &= ~1;
391 
392  // don't allow too small size
393  if (win.rc.width < 320) win.rc.width = 320;
394  if (win.rc.height < 240) win.rc.height = 240;
395 
396  Com_DPrintf("...setting windowed mode: %dx%d%+d%+d\n",
397  win.rc.width, win.rc.height, win.rc.x, win.rc.y);
398 
399  memset(&win.dm, 0, sizeof(win.dm));
400  win.flags &= ~QVF_FULLSCREEN;
401  Win_SetPosition();
402  win.mode_changed = 0;
403 
404  // set vid_geometry back
405  VID_SetGeometry(&win.rc);
406 }

Referenced by VID_Init(), and VID_SetMode().

◆ Win_SetPosition()

static void Win_SetPosition ( void  )
static

Definition at line 56 of file client.c.

57 {
58  RECT r;
59  LONG style;
60  int x, y, w, h;
61  HWND after;
62 
63  // get previous window style
64  style = GetWindowLong(win.wnd, GWL_STYLE);
65  style &= ~(WS_OVERLAPPEDWINDOW | WS_POPUP | WS_DLGFRAME);
66 
67  // set new style bits
68  if (win.flags & QVF_FULLSCREEN) {
69  after = HWND_TOPMOST;
70  style |= WS_POPUP;
71  } else {
72  if (win_alwaysontop->integer) {
73  after = HWND_TOPMOST;
74  } else {
75  after = HWND_NOTOPMOST;
76  }
77  style |= WS_OVERLAPPED;
78  if (win_notitle->integer) {
79  if (win_noresize->integer) {
80  style |= WS_DLGFRAME;
81  } else {
82  style |= WS_THICKFRAME;
83  }
84  } else {
85  style |= WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
86  if (!win_noresize->integer) {
87  style |= WS_THICKFRAME;
88  }
89  }
90  }
91 
92  // adjust for non-client area
93  r.left = 0;
94  r.top = 0;
95  r.right = win.rc.width;
96  r.bottom = win.rc.height;
97 
98  AdjustWindowRect(&r, style, FALSE);
99 
100  // figure out position
101  x = win.rc.x;
102  y = win.rc.y;
103  w = r.right - r.left;
104  h = r.bottom - r.top;
105 
106  // set new window style and position
107  SetWindowLong(win.wnd, GWL_STYLE, style);
108  SetWindowPos(win.wnd, after, x, y, w, h, SWP_FRAMECHANGED | SWP_SHOWWINDOW);
109  UpdateWindow(win.wnd);
110  SetForegroundWindow(win.wnd);
111  SetFocus(win.wnd);
112 
113  if (win.mouse.grabbed) {
114  Win_ClipCursor();
115  }
116 }

Referenced by set_fullscreen_mode(), VID_PumpEvents(), and Win_SetMode().

◆ Win_ShowCursor()

static void Win_ShowCursor ( void  )
static

Definition at line 1128 of file client.c.

1129 {
1130  while (ShowCursor(TRUE) < 0)
1131  ;
1132 }

Referenced by Win_GrabMouse(), and Win_ShutdownMouse().

◆ Win_Shutdown()

void Win_Shutdown ( void  )

Definition at line 1091 of file client.c.

1092 {
1093  if (win.flags & QVF_GAMMARAMP) {
1094  SetDeviceGammaRamp(win.dc, win.gamma_orig);
1095  }
1096 
1097  // prevents leaving empty slots in the taskbar
1098  ShowWindow(win.wnd, SW_SHOWNORMAL);
1099  ReleaseDC(win.wnd, win.dc);
1100  DestroyWindow(win.wnd);
1101  UnregisterClass(_T(WINDOW_CLASS_NAME), hGlobalInstance);
1102 
1103  if (win.kbdHook) {
1104  UnhookWindowsHookEx(win.kbdHook);
1105  }
1106 
1107  if (win.flags & QVF_FULLSCREEN) {
1108  ChangeDisplaySettings(NULL, 0);
1109  }
1110 
1111  memset(&win, 0, sizeof(win));
1112 }

Referenced by SetupGL(), VID_Init(), and VID_Shutdown().

◆ Win_ShutdownMouse()

static void Win_ShutdownMouse ( void  )
static

Definition at line 1223 of file client.c.

1224 {
1225  if (!win.mouse.initialized) {
1226  return;
1227  }
1228 
1230  Win_ShowCursor();
1231 
1232  if (win.mouse.initialized == WIN_MOUSE_RAW) {
1233  register_raw_mouse(RIDEV_REMOVE);
1234  }
1235 
1236  win_xpfix->changed = NULL;
1237  win_rawmouse->changed = NULL;
1238 
1239  memset(&win.mouse, 0, sizeof(win.mouse));
1240 }

Referenced by VID_FillInputAPI(), and win_rawmouse_changed().

◆ win_style_changed()

static void win_style_changed ( cvar_t *  self)
static

Definition at line 1002 of file client.c.

1003 {
1004  if (win.wnd && !(win.flags & QVF_FULLSCREEN)) {
1005  win.mode_changed |= MODE_REPOSITION;
1006  }
1007 }

Referenced by Win_Init().

◆ Win_WarpMouse()

static void Win_WarpMouse ( int  x,
int  y 
)
static

Definition at line 1317 of file client.c.

1318 {
1319  SetCursorPos(win.screen_rc.left + x, win.screen_rc.top + y);
1320 }

Referenced by VID_FillInputAPI().

◆ win_xpfix_changed()

static void win_xpfix_changed ( cvar_t *  self)
static

Definition at line 1242 of file client.c.

1243 {
1244  if (win.mouse.grabbed) {
1245  Win_AcquireMouse();
1246  }
1247 }

Referenced by Win_InitMouse().

Variable Documentation

◆ scantokey

const byte scantokey[2][96]
static

Definition at line 564 of file client.c.

Referenced by legacy_key_event().

◆ vid_flip_on_switch

cvar_t* vid_flip_on_switch
static

Definition at line 35 of file client.c.

Referenced by Win_Activate(), and Win_Init().

◆ vid_hwgamma

cvar_t* vid_hwgamma
static

Definition at line 36 of file client.c.

Referenced by Win_Init().

◆ win

◆ win_alwaysontop

cvar_t* win_alwaysontop
static

Definition at line 41 of file client.c.

Referenced by Win_Init(), and Win_SetPosition().

◆ win_disablewinkey

cvar_t* win_disablewinkey
static

Definition at line 38 of file client.c.

Referenced by Win_Init().

◆ win_noalttab

cvar_t* win_noalttab
static

Definition at line 37 of file client.c.

Referenced by Win_Activate(), and Win_Init().

◆ win_noresize

cvar_t* win_noresize
static

Definition at line 39 of file client.c.

Referenced by Win_Init(), and Win_SetPosition().

◆ win_notitle

cvar_t* win_notitle
static

Definition at line 40 of file client.c.

Referenced by Win_Init(), and Win_SetPosition().

◆ win_rawmouse

cvar_t* win_rawmouse
static

Definition at line 43 of file client.c.

Referenced by Win_Init(), Win_InitMouse(), and Win_ShutdownMouse().

◆ win_xpfix

cvar_t* win_xpfix
static

Definition at line 42 of file client.c.

Referenced by Win_AcquireMouse(), Win_Init(), Win_InitMouse(), and Win_ShutdownMouse().

LowLevelKeyboardProc
STATIC LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
Definition: client.c:513
Win_ShutdownMouse
static void Win_ShutdownMouse(void)
Definition: client.c:1223
Win_DeAcquireMouse
static void Win_DeAcquireMouse(void)
Definition: client.c:1164
handle
static void * handle
Definition: dynamic.c:52
Win_ModeChanged
void Win_ModeChanged(void)
Definition: client.c:123
VID_SetGeometry
void VID_SetGeometry(vrect_t *rc)
Definition: refresh.c:192
Cvar_Set
cvar_t * Cvar_Set(const char *var_name, const char *value)
Definition: cvar.c:466
win_noresize
static cvar_t * win_noresize
Definition: client.c:39
mouse_hwheel_event
static void mouse_hwheel_event(int delta)
Definition: client.c:651
UI_MouseEvent
void UI_MouseEvent(int x, int y)
Definition: ui.c:404
Win_EnableAltTab
static void Win_EnableAltTab(void)
Definition: client.c:439
Win_WarpMouse
static void Win_WarpMouse(int x, int y)
Definition: client.c:1317
win_xpfix_changed
static void win_xpfix_changed(cvar_t *self)
Definition: client.c:1242
Win_GetMouseMotion
static qboolean Win_GetMouseMotion(int *dx, int *dy)
Definition: client.c:1177
VID_GetGeometry
qboolean VID_GetGeometry(vrect_t *rc)
Definition: refresh.c:144
Cvar_Get
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags)
Definition: cvar.c:257
Win_GrabMouse
static void Win_GrabMouse(qboolean grab)
Definition: client.c:1288
Win_SetPosition
static void Win_SetPosition(void)
Definition: client.c:56
BTN_DN
#define BTN_DN(i)
Definition: client.c:719
win_style_changed
static void win_style_changed(cvar_t *self)
Definition: client.c:1002
raw_mouse_event
static void raw_mouse_event(PRAWMOUSE rm)
Definition: client.c:722
raw_input_event
static void raw_input_event(HANDLE handle)
Definition: client.c:764
set_fullscreen_mode
static LONG set_fullscreen_mode(void)
Definition: client.c:281
MODE_POS
#define MODE_POS
Definition: client.c:29
Win_ShowCursor
static void Win_ShowCursor(void)
Definition: client.c:1128
win_rawmouse_changed
static void win_rawmouse_changed(cvar_t *self)
Definition: client.c:1249
hGlobalInstance
HINSTANCE hGlobalInstance
Definition: system.c:28
Win_SetMode
void Win_SetMode(void)
Definition: client.c:358
win_noalttab_changed
static void win_noalttab_changed(cvar_t *self)
Definition: client.c:448
mode_is_current
static qboolean mode_is_current(const DEVMODE *dm)
Definition: client.c:268
win_disablewinkey_changed
static void win_disablewinkey_changed(cvar_t *self)
Definition: client.c:548
MODE_SIZE
#define MODE_SIZE
Definition: client.c:28
SWimp_ModeChanged
void SWimp_ModeChanged(void)
Definition: swimp.c:65
CL_Activate
void CL_Activate(active_t active)
Definition: main.c:2905
MODE_STYLE
#define MODE_STYLE
Definition: client.c:30
Win_HideCursor
static void Win_HideCursor(void)
Definition: client.c:1122
VID_GetFullscreen
qboolean VID_GetFullscreen(vrect_t *rc, int *freq_p, int *depth_p)
Definition: refresh.c:56
Win_DisableAltTab
static void Win_DisableAltTab(void)
Definition: client.c:430
Com_Error
void Com_Error(error_type_t type, const char *fmt,...)
Definition: g_main.c:258
win_xpfix
static cvar_t * win_xpfix
Definition: client.c:42
mouse_wheel_event
static void mouse_wheel_event(int delta)
Definition: client.c:625
pos_changing_event
static void pos_changing_event(HWND wnd, WINDOWPOS *pos)
Definition: client.c:783
pos_changed_event
static void pos_changed_event(HWND wnd, WINDOWPOS *pos)
Definition: client.c:821
Z_Free
void Z_Free(void *ptr)
Definition: zone.c:147
WINDOW_CLASS_NAME
#define WINDOW_CLASS_NAME
Definition: client.c:25
vid_hwgamma
static cvar_t * vid_hwgamma
Definition: client.c:36
win_notitle
static cvar_t * win_notitle
Definition: client.c:40
Q_strlcpy
size_t Q_strlcpy(char *dst, const char *src, size_t size)
Definition: shared.c:715
check_cursor_pos
static BOOL check_cursor_pos(void)
Definition: client.c:706
legacy_key_event
static void legacy_key_event(WPARAM wParam, LPARAM lParam, qboolean down)
Definition: client.c:598
UINT
CONST PIXELFORMATDESCRIPTOR UINT
Definition: wgl.c:26
BTN_UP
#define BTN_UP(i)
Definition: client.c:720
Win_Activate
static void Win_Activate(WPARAM wParam)
Definition: client.c:457
win_rawmouse
static cvar_t * win_rawmouse
Definition: client.c:43
Win_AcquireMouse
static void Win_AcquireMouse(void)
Definition: client.c:1142
modecmp
static int modecmp(const void *p1, const void *p2)
Definition: client.c:134
mode_is_sane
static qboolean mode_is_sane(const DEVMODE *dm)
Definition: client.c:156
VID_ToggleFullscreen
void VID_ToggleFullscreen(void)
Definition: refresh.c:204
Key_Event
void Key_Event(unsigned key, qboolean down, unsigned time)
Definition: keys.c:627
SCR_ModeChanged
void SCR_ModeChanged(void)
Definition: screen.c:1278
scantokey
static const byte scantokey[2][96]
Definition: client.c:564
Com_Quit
void Com_Quit(const char *reason, error_type_t type)
Definition: common.c:609
modes_are_equal
static qboolean modes_are_equal(const DEVMODE *base, const DEVMODE *compare)
Definition: client.c:173
Key_GetDest
keydest_t Key_GetDest(void)
Definition: keys.c:168
win_alwaysontop
static cvar_t * win_alwaysontop
Definition: client.c:41
win_disablewinkey
static cvar_t * win_disablewinkey
Definition: client.c:38
msg
const char * msg
Definition: win.h:25
MODE_REPOSITION
#define MODE_REPOSITION
Definition: client.c:31
Win_MainWndProc
STATIC LONG WINAPI Win_MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: client.c:858
register_raw_mouse
static BOOL register_raw_mouse(DWORD flags)
Definition: client.c:1210
legacy_mouse_event
static void legacy_mouse_event(WPARAM wParam)
Definition: client.c:670
vid_flip_on_switch
static cvar_t * vid_flip_on_switch
Definition: client.c:35
vid_fullscreen
cvar_t * vid_fullscreen
Definition: refresh.c:33
R_ModeChanged
void(* R_ModeChanged)(int width, int height, int flags, int rowbytes, void *pixels)
Definition: refresh.c:426
win_noalttab
static cvar_t * win_noalttab
Definition: client.c:37
Z_Realloc
void * Z_Realloc(void *ptr, size_t size)
Definition: zone.c:178
Q_scnprintf
size_t Q_scnprintf(char *dest, size_t size, const char *fmt,...)
Definition: shared.c:867
Win_ClipCursor
static void Win_ClipCursor(void)
Definition: client.c:1135
win
win_state_t win
Definition: client.c:33
Win_InitMouse
static qboolean Win_InitMouse(void)
Definition: client.c:1257