ReactOS  0.4.12-dev-14-gd0c8636
win32.c File Reference
#include "precomp.h"
#include "uimain.h"
Include dependency graph for win32.c:

Go to the source code of this file.

Functions

static void str_to_uni (TCHAR *sizex, char *size1)
 
static void uni_to_str (char *sizex, TCHAR *size1)
 
static int check_sck (void)
 
void mi_error (char *msg)
 
static int get_scan_code_from_ascii (int code)
 
static void mi_scroll (int dx, int dy)
 
int mi_read_keyboard_state (void)
 
static void mi_check_modifier (void)
 
static LRESULT handle_WM_SETCURSOR (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT handle_WM_NCHITTEST (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT handle_WM_MOUSEMOVE (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT handle_WM_LBUTTONDOWN (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT handle_WM_LBUTTONUP (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT handle_WM_RBUTTONDOWN (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT handle_WM_RBUTTONUP (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT handle_WM_MBUTTONDOWN (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT handle_WM_MBUTTONUP (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT handle_WM_MOUSEWHEEL (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT handle_WM_KEY (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT handle_WM_PAINT (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT handle_WM_SIZE (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT handle_WM_SIZING (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT handle_WM_HSCROLL (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static LRESULT handle_WM_VSCROLL (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
static HRGN mi_clip (HDC dc)
 
int mi_create_window (void)
 
int mi_main_loop (void)
 
void mi_warning (char *msg)
 
static void mi_show_error (char *caption)
 
void mi_paint_rect (char *data, int width, int height, int x, int y, int cx, int cy)
 
static INT GetPortNumber (PCHAR szAddress)
 
static VOID SetDomainAndUsername (PCHAR pName)
 
static BOOL ParseCommandLine (LPWSTR lpCmdLine, PRDPSETTINGS pRdpSettings, BOOL *bSkipDlg)
 
int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
 
void mi_begin_update (void)
 
void mi_end_update (void)
 
void mi_fill_rect (int x, int y, int cx, int cy, int colour)
 
void mi_line (int x1, int y1, int x2, int y2, int colour)
 
void mi_screen_copy (int x, int y, int cx, int cy, int srcx, int srcy)
 
void mi_set_clip (int x, int y, int cx, int cy)
 
void mi_reset_clip (void)
 
voidmi_create_cursor (unsigned int x, unsigned int y, int width, int height, unsigned char *andmask, unsigned char *xormask)
 
void mi_destroy_cursor (void *cursor)
 
void mi_set_cursor (void *cursor)
 
void mi_set_null_cursor (void)
 

Variables

char g_username []
 
char g_hostname []
 
char g_servername []
 
char g_password []
 
char g_shell []
 
char g_directory []
 
char g_domain []
 
int g_width
 
int g_height
 
int g_tcp_sck
 
int g_server_depth
 
int g_tcp_port_rdp
 
int pal_entries []
 
static HWND g_Wnd = 0
 
static HINSTANCE g_Instance = 0
 
static HCURSOR g_cursor = 0
 
static int g_block = 0
 
static int g_xoff = 0
 
static int g_yoff = 0
 
static int g_xscroll = 0
 
static int g_yscroll = 0
 
static int g_screen_width = 0
 
static int g_screen_height = 0
 
static int g_wnd_cwidth = 0
 
static int g_wnd_cheight = 0
 
static int g_fullscreen = 0
 
static int g_workarea = 0
 
static int g_mousex = 0
 
static int g_mousey = 0
 
static int g_clip_left = 0
 
static int g_clip_top = 0
 
static int g_clip_right = 800
 
static int g_clip_bottom = 600
 
static RECT g_wnd_clip
 

Function Documentation

◆ check_sck()

static int check_sck ( void  )
static

Definition at line 97 of file win32.c.

Referenced by WndProc().

98 {
99  fd_set rfds;
100  struct timeval tm;
101  int count;
102  int rv;
103 
104  rv = 0;
105  if (g_block == 0)
106  {
107  g_block = 1;
108  /* see if there really is data */
109  FD_ZERO(&rfds);
110  FD_SET((unsigned int)g_tcp_sck, &rfds);
111  ZeroMemory(&tm, sizeof(tm));
112  count = select(g_tcp_sck + 1, &rfds, 0, 0, &tm);
113  if (count > 0)
114  {
115  if (ui_read_wire())
116  {
117  rv = 1;
118  }
119  else
120  {
121  PostQuitMessage(0);
122  }
123  }
124  g_block = 0;
125  }
126  return rv;
127 }
Definition: winsock.h:66
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define ZeroMemory
Definition: winbase.h:1635
#define FD_ZERO(set)
Definition: winsock.h:96
#define FD_SET(fd, set)
Definition: winsock.h:89
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
Definition: select.c:41
static int g_block
Definition: win32.c:42
Definition: time.h:76
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
int g_tcp_sck
Definition: uimain.c:51
int ui_read_wire(void)
Definition: uimain.c:942

◆ get_scan_code_from_ascii()

static int get_scan_code_from_ascii ( int  code)
static

Definition at line 147 of file win32.c.

Referenced by handle_WM_KEY().

148 {
149  int rv;
150 
151  rv = 0;
152  switch (code & 0xff)
153  {
154  case 0x30: rv = 0x0b; break; // 0
155  case 0x31: rv = 0x02; break; // 1
156  case 0x32: rv = 0x03; break; // 2
157  case 0x33: rv = 0x04; break; // 3
158  case 0x34: rv = 0x05; break; // 4
159  case 0x35: rv = 0x06; break; // 5
160  case 0x36: rv = 0x07; break; // 6
161  case 0x37: rv = 0x08; break; // 7
162  case 0x38: rv = 0x09; break; // 8
163  case 0x39: rv = 0x0a; break; // 9
164 
165  case 0xbd: rv = 0x0c; break; // -
166  case 0xbb: rv = 0x0d; break; // =
167  case 0x08: rv = 0x0e; break; // backspace
168  case 0x09: rv = 0x0f; break; // tab
169  case 0xdb: rv = 0x1b; break; // ]
170  case 0xdd: rv = 0x1a; break; // [
171  case 0x14: rv = 0x3a; break; // capslock
172  case 0xba: rv = 0x27; break; // ;
173  case 0xde: rv = 0x28; break; // '
174  case 0x10: rv = 0x2a; break; // shift
175  case 0xbc: rv = 0x33; break; // ,
176  case 0xbe: rv = 0x34; break; // .
177  case 0xbf: rv = 0x35; break; // /
178  case 0x0d: rv = 0x1c; break; // enter
179  case 0x27: rv = 0x4d; break; // arrow right
180  case 0x25: rv = 0x4b; break; // arrow left
181  case 0x26: rv = 0x48; break; // arrow up
182  case 0x28: rv = 0x50; break; // arrow down
183  case 0x20: rv = 0x39; break; // space
184  case 0xdc: rv = 0x2b; break; // backslash
185  case 0xc0: rv = 0x29; break; // `
186  case 0x11: rv = 0x1d; break; // ctl
187 
188  case 0x41: rv = 0x1e; break; // a
189  case 0x42: rv = 0x30; break; // b
190  case 0x43: rv = 0x2e; break; // c
191  case 0x44: rv = 0x20; break; // d
192  case 0x45: rv = 0x12; break; // e
193  case 0x46: rv = 0x21; break; // f
194  case 0x47: rv = 0x22; break; // g
195  case 0x48: rv = 0x23; break; // h
196  case 0x49: rv = 0x17; break; // i
197  case 0x4a: rv = 0x24; break; // j
198  case 0x4b: rv = 0x25; break; // k
199  case 0x4c: rv = 0x26; break; // l
200  case 0x4d: rv = 0x32; break; // m
201  case 0x4e: rv = 0x31; break; // n
202  case 0x4f: rv = 0x18; break; // o
203  case 0x50: rv = 0x19; break; // p
204  case 0x51: rv = 0x10; break; // q
205  case 0x52: rv = 0x13; break; // r
206  case 0x53: rv = 0x1f; break; // s
207  case 0x54: rv = 0x14; break; // t
208  case 0x55: rv = 0x16; break; // u
209  case 0x56: rv = 0x2f; break; // v
210  case 0x57: rv = 0x11; break; // w
211  case 0x58: rv = 0x2d; break; // x
212  case 0x59: rv = 0x15; break; // y
213  case 0x5a: rv = 0x2c; break; // z
214  }
215  return rv;
216 }

◆ GetPortNumber()

static INT GetPortNumber ( PCHAR  szAddress)
static

Definition at line 983 of file win32.c.

Referenced by wWinMain().

984 {
985  PCHAR szPort;
986  INT iPort = TCP_PORT_RDP;
987 
988  szPort = strtok(szAddress, ":");
989 
990  if (szPort != NULL)
991  {
992  szPort = strtok(NULL, ":");
993 
994  if (szPort != NULL)
995  {
996  iPort = atoi(szPort);
997 
998  if (iPort <= 0 || iPort > 0xFFFF)
999  iPort = TCP_PORT_RDP;
1000  }
1001  }
1002 
1003  return iPort;
1004 }
signed char * PCHAR
Definition: retypes.h:7
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
#define TCP_PORT_RDP
Definition: constants.h:21
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)

◆ handle_WM_HSCROLL()

static LRESULT handle_WM_HSCROLL ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 545 of file win32.c.

Referenced by WndProc().

546 {
547  int code;
548  int oldxscroll;
549 
550  code = (int) LOWORD(wParam); /* scroll bar value */
551  if (code == SB_LINELEFT)
552  {
553  oldxscroll = g_xscroll;
554  g_xscroll--;
555  g_xscroll = UI_MAX(g_xscroll, 0);
557  mi_scroll(oldxscroll - g_xscroll, 0);
558  }
559  else if (code == SB_LINERIGHT)
560  {
561  oldxscroll = g_xscroll;
562  g_xscroll++;
565  mi_scroll(oldxscroll - g_xscroll, 0);
566  }
567  else if (code == SB_PAGELEFT)
568  {
569  oldxscroll = g_xscroll;
570  g_xscroll -= g_wnd_cwidth / 2;
571  g_xscroll = UI_MAX(g_xscroll, 0);
573  mi_scroll(oldxscroll - g_xscroll, 0);
574  }
575  else if (code == SB_PAGERIGHT)
576  {
577  oldxscroll = g_xscroll;
578  g_xscroll += g_wnd_cwidth / 2;
581  mi_scroll(oldxscroll - g_xscroll, 0);
582  }
583  else if (code == SB_BOTTOM)
584  {
585  oldxscroll = g_xscroll;
588  mi_scroll(oldxscroll - g_xscroll, 0);
589  }
590  else if (code == SB_TOP)
591  {
592  oldxscroll = g_xscroll;
593  g_xscroll = 0;
595  mi_scroll(oldxscroll - g_xscroll, 0);
596  }
597  else if (code == SB_THUMBPOSITION)
598  {
599  oldxscroll = g_xscroll;
600  g_xscroll = (signed short) HIWORD(wParam);
602  mi_scroll(oldxscroll - g_xscroll, 0);
603  }
604  return 0;
605 }
int g_width
Definition: uimain.c:42
#define SB_HORZ
Definition: winuser.h:552
static void mi_scroll(int dx, int dy)
Definition: win32.c:220
#define UI_MAX(a, b)
Definition: uimain.h:76
WPARAM wParam
Definition: combotst.c:138
static HWND g_Wnd
Definition: win32.c:39
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:91
#define UI_MIN(a, b)
Definition: uimain.h:78
#define SB_THUMBPOSITION
Definition: winuser.h:572
static int g_wnd_cwidth
Definition: win32.c:49
#define SB_PAGELEFT
Definition: winuser.h:570
int code
Definition: i386-dis.c:3591
#define SB_LINERIGHT
Definition: winuser.h:567
#define SB_TOP
Definition: winuser.h:578
#define SB_PAGERIGHT
Definition: winuser.h:571
#define SB_BOTTOM
Definition: winuser.h:577
static int g_xscroll
Definition: win32.c:45
#define HIWORD(l)
Definition: typedefs.h:246
#define SB_LINELEFT
Definition: winuser.h:566
int WINAPI SetScrollPos(_In_ HWND, _In_ int, _In_ int, _In_ BOOL)
#define LOWORD(l)
Definition: pedump.c:82
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29

◆ handle_WM_KEY()

static LRESULT handle_WM_KEY ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 389 of file win32.c.

Referenced by WndProc().

390 {
391  int scancode;
392  int ext;
393  int down;
394 
395  ext = HIWORD(lParam);
396  scancode = ext;
397  down = !(ext & 0x8000);
398  scancode &= 0xff;
399  if (scancode == 0)
400  {
401  scancode = get_scan_code_from_ascii(wParam);
402  }
403  ext &= 0x0100;
404  if (scancode == 0x0045) /* num lock */
405  {
406  ext &= ~0x0100;
407  }
408  if (down)
409  {
410  ui_key_down(scancode, ext);
411  }
412  else
413  {
414  ui_key_up(scancode, ext);
415  }
416  return 0;
417 }
void ui_key_up(int key, int ext)
Definition: uimain.c:933
WPARAM wParam
Definition: combotst.c:138
#define down(mutex)
Definition: glue.h:29
char ext[3]
Definition: mkdosfs.c:358
void ui_key_down(int key, int ext)
Definition: uimain.c:924
static int get_scan_code_from_ascii(int code)
Definition: win32.c:147
#define HIWORD(l)
Definition: typedefs.h:246
LPARAM lParam
Definition: combotst.c:139

◆ handle_WM_LBUTTONDOWN()

static LRESULT handle_WM_LBUTTONDOWN ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 309 of file win32.c.

Referenced by WndProc().

310 {
314  return 0;
315 }
void ui_mouse_button(int button, int x, int y, int down)
Definition: uimain.c:891
static int g_mousex
Definition: win32.c:53
static int g_yscroll
Definition: win32.c:46
static int g_xscroll
Definition: win32.c:45
#define HIWORD(l)
Definition: typedefs.h:246
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
static int g_mousey
Definition: win32.c:54

◆ handle_WM_LBUTTONUP()

static LRESULT handle_WM_LBUTTONUP ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 319 of file win32.c.

Referenced by WndProc().

320 {
324  return 0;
325 }
void ui_mouse_button(int button, int x, int y, int down)
Definition: uimain.c:891
static int g_mousex
Definition: win32.c:53
static int g_yscroll
Definition: win32.c:46
static int g_xscroll
Definition: win32.c:45
#define HIWORD(l)
Definition: typedefs.h:246
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
static int g_mousey
Definition: win32.c:54

◆ handle_WM_MBUTTONDOWN()

static LRESULT handle_WM_MBUTTONDOWN ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 349 of file win32.c.

Referenced by WndProc().

350 {
354  return 0;
355 }
void ui_mouse_button(int button, int x, int y, int down)
Definition: uimain.c:891
static int g_mousex
Definition: win32.c:53
static int g_yscroll
Definition: win32.c:46
static int g_xscroll
Definition: win32.c:45
#define HIWORD(l)
Definition: typedefs.h:246
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
static int g_mousey
Definition: win32.c:54

◆ handle_WM_MBUTTONUP()

static LRESULT handle_WM_MBUTTONUP ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 359 of file win32.c.

Referenced by WndProc().

360 {
364  return 0;
365 }
void ui_mouse_button(int button, int x, int y, int down)
Definition: uimain.c:891
static int g_mousex
Definition: win32.c:53
static int g_yscroll
Definition: win32.c:46
static int g_xscroll
Definition: win32.c:45
#define HIWORD(l)
Definition: typedefs.h:246
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
static int g_mousey
Definition: win32.c:54

◆ handle_WM_MOUSEMOVE()

static LRESULT handle_WM_MOUSEMOVE ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 299 of file win32.c.

Referenced by WndProc().

300 {
304  return 0;
305 }
static int g_mousex
Definition: win32.c:53
void ui_mouse_move(int x, int y)
Definition: uimain.c:883
static int g_yscroll
Definition: win32.c:46
static int g_xscroll
Definition: win32.c:45
#define HIWORD(l)
Definition: typedefs.h:246
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
static int g_mousey
Definition: win32.c:54

◆ handle_WM_MOUSEWHEEL()

static LRESULT handle_WM_MOUSEWHEEL ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 369 of file win32.c.

Referenced by WndProc().

370 {
371  int delta;
372 
373  delta = ((signed short)HIWORD(wParam)); /* GET_WHEEL_DELTA_WPARAM(wParam); */
374  if (delta > 0)
375  {
376  ui_mouse_button(4, 0, 0, 1);
377  ui_mouse_button(4, 0, 0, 0);
378  }
379  else
380  {
381  ui_mouse_button(5, 0, 0, 1);
382  ui_mouse_button(5, 0, 0, 0);
383  }
384  return 0;
385 }
WPARAM wParam
Definition: combotst.c:138
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:91
void ui_mouse_button(int button, int x, int y, int down)
Definition: uimain.c:891
#define HIWORD(l)
Definition: typedefs.h:246

◆ handle_WM_NCHITTEST()

static LRESULT handle_WM_NCHITTEST ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 283 of file win32.c.

Referenced by WndProc().

284 {
285  POINT pt;
286 
287  pt.x = LOWORD(lParam);
288  pt.y = HIWORD(lParam);
289  if (ScreenToClient(g_Wnd, &pt))
290  {
291  g_mousex = pt.x;
292  g_mousey = pt.y;
293  }
294  return DefWindowProc(hWnd, message, wParam, lParam);
295 }
Definition: tftpd.h:59
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define pt(x, y)
Definition: drawing.c:79
WPARAM wParam
Definition: combotst.c:138
static HWND g_Wnd
Definition: win32.c:39
static int g_mousex
Definition: win32.c:53
#define DefWindowProc
Definition: ros2win.h:31
#define HIWORD(l)
Definition: typedefs.h:246
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
static int g_mousey
Definition: win32.c:54

◆ handle_WM_PAINT()

static LRESULT handle_WM_PAINT ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 421 of file win32.c.

Referenced by WndProc().

422 {
423  PAINTSTRUCT ps;
424  RECT rect;
425  HBRUSH brush;
426 
427  BeginPaint(hWnd, &ps);
428  /* paint the area outside the rdp screen with one colour */
429  rect = ps.rcPaint;
430  rect.left = UI_MAX(rect.left, g_width);
431  if (!IsRectEmpty(&rect))
432  {
433  brush = CreateSolidBrush(RGB(0, 0, 255));
434  FillRect(ps.hdc, &rect, brush);
435  DeleteObject(brush);
436  }
437  rect = ps.rcPaint;
438  rect.top = UI_MAX(rect.top, g_height);
439  if (!IsRectEmpty(&rect))
440  {
441  brush = CreateSolidBrush(RGB(0, 0, 255));
442  FillRect(ps.hdc, &rect, brush);
443  DeleteObject(brush);
444  }
445  rect = ps.rcPaint;
446  EndPaint(hWnd, &ps);
448  rect.top + g_yscroll,
449  (rect.right - rect.left) + 1,
450  (rect.bottom - rect.top) + 1);
451  return 0;
452 }
int g_width
Definition: uimain.c:42
#define UI_MAX(a, b)
Definition: uimain.h:76
LONG top
Definition: windef.h:297
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LONG left
Definition: windef.h:296
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
LONG right
Definition: windef.h:298
& rect
Definition: startmenu.cpp:1413
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
int g_height
Definition: uimain.c:43
#define RGB(r, g, b)
Definition: wingdi.h:2917
static int g_yscroll
Definition: win32.c:46
void ui_invalidate(int x, int y, int cx, int cy)
Definition: uimain.c:138
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
static int g_xscroll
Definition: win32.c:45
LONG bottom
Definition: windef.h:299
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)

◆ handle_WM_RBUTTONDOWN()

static LRESULT handle_WM_RBUTTONDOWN ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 329 of file win32.c.

Referenced by WndProc().

330 {
334  return 0;
335 }
void ui_mouse_button(int button, int x, int y, int down)
Definition: uimain.c:891
static int g_mousex
Definition: win32.c:53
static int g_yscroll
Definition: win32.c:46
static int g_xscroll
Definition: win32.c:45
#define HIWORD(l)
Definition: typedefs.h:246
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
static int g_mousey
Definition: win32.c:54

◆ handle_WM_RBUTTONUP()

static LRESULT handle_WM_RBUTTONUP ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 339 of file win32.c.

Referenced by WndProc().

340 {
344  return 0;
345 }
void ui_mouse_button(int button, int x, int y, int down)
Definition: uimain.c:891
static int g_mousex
Definition: win32.c:53
static int g_yscroll
Definition: win32.c:46
static int g_xscroll
Definition: win32.c:45
#define HIWORD(l)
Definition: typedefs.h:246
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
static int g_mousey
Definition: win32.c:54

◆ handle_WM_SETCURSOR()

static LRESULT handle_WM_SETCURSOR ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 268 of file win32.c.

Referenced by WndProc().

269 {
270  if (g_mousex >= g_wnd_clip.left &&
271  g_mousey >= g_wnd_clip.top &&
274  {
276  }
277  /* need default behavoir here */
278  return DefWindowProc(hWnd, message, wParam, lParam);
279 }
Definition: tftpd.h:59
static RECT g_wnd_clip
Definition: win32.c:61
LONG top
Definition: windef.h:297
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
WPARAM wParam
Definition: combotst.c:138
static int g_mousex
Definition: win32.c:53
#define DefWindowProc
Definition: ros2win.h:31
static HCURSOR g_cursor
Definition: win32.c:41
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
LONG bottom
Definition: windef.h:299
LPARAM lParam
Definition: combotst.c:139
static int g_mousey
Definition: win32.c:54

◆ handle_WM_SIZE()

static LRESULT handle_WM_SIZE ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 456 of file win32.c.

Referenced by WndProc().

457 {
458  int oldxscroll;
459  int oldyscroll;
460 
461  if (wParam == SIZE_MINIMIZED)
462  {
463  return DefWindowProc(hWnd, message, wParam, lParam);
464  }
465  g_wnd_cwidth = LOWORD(lParam); /* client width / height */
467  g_wnd_clip.left = 0;
468  g_wnd_clip.top = 0;
472  {
475  }
476  oldxscroll = g_xscroll;
477  oldyscroll = g_yscroll;
478  if (g_wnd_cwidth >= g_width)
479  {
480  g_xscroll = 0;
481  }
482  else
483  {
485  }
486  if (g_wnd_cheight >= g_height)
487  {
488  g_yscroll = 0;
489  }
490  else
491  {
493  }
494  mi_scroll(oldxscroll - g_xscroll, oldyscroll - g_yscroll);
496  {
497  /* check the caps, num, and scroll lock here */
499  }
500  return 0;
501 }
Definition: tftpd.h:59
#define SB_VERT
Definition: winuser.h:553
#define SIZE_MAXIMIZED
Definition: winuser.h:2461
int g_width
Definition: uimain.c:42
#define SB_HORZ
Definition: winuser.h:552
#define SIZE_RESTORED
Definition: winuser.h:2459
static void mi_scroll(int dx, int dy)
Definition: win32.c:220
static RECT g_wnd_clip
Definition: win32.c:61
LONG top
Definition: windef.h:297
LONG left
Definition: windef.h:296
static void mi_check_modifier(void)
Definition: win32.c:258
LONG right
Definition: windef.h:298
WPARAM wParam
Definition: combotst.c:138
static HWND g_Wnd
Definition: win32.c:39
static int g_wnd_cheight
Definition: win32.c:50
#define UI_MIN(a, b)
Definition: uimain.h:78
#define DefWindowProc
Definition: ros2win.h:31
int g_height
Definition: uimain.c:43
static int g_wnd_cwidth
Definition: win32.c:49
#define SIZE_MINIMIZED
Definition: winuser.h:2460
static int g_yscroll
Definition: win32.c:46
static int g_xscroll
Definition: win32.c:45
BOOL WINAPI SetScrollRange(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ BOOL)
#define HIWORD(l)
Definition: typedefs.h:246
LONG bottom
Definition: windef.h:299
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

◆ handle_WM_SIZING()

static LRESULT handle_WM_SIZING ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 505 of file win32.c.

Referenced by WndProc().

506 {
507  LPRECT prect;
508  int width;
509  int height;
510  int style;
511 
512  prect = (LPRECT) lParam; /* total window rect */
513  width = (prect->right - prect->left) - (g_xoff * 2);
514  height = (prect->bottom - prect->top) - (g_yoff + g_xoff);
515  if (height < g_height || width < g_width)
516  {
517  style = GetWindowLongPtr(g_Wnd, GWL_STYLE);
518  if (!(style & WS_HSCROLL))
519  {
520  style |= WS_HSCROLL | WS_VSCROLL;
522  g_xscroll = 0;
523  g_yscroll = 0;
526  }
527  }
528  else if (height >= g_height && width >= g_width)
529  {
530  style = GetWindowLongPtr(g_Wnd, GWL_STYLE);
531  if (style & WS_HSCROLL)
532  {
533  style &= ~WS_HSCROLL;
534  style &= ~WS_VSCROLL;
536  g_xscroll = 0;
537  g_yscroll = 0;
538  }
539  }
540  return 0;
541 }
static int g_xoff
Definition: win32.c:43
GLint GLint GLsizei width
Definition: gl.h:1546
#define SB_VERT
Definition: winuser.h:553
int g_width
Definition: uimain.c:42
#define SB_HORZ
Definition: winuser.h:552
LONG top
Definition: windef.h:297
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
#define SetWindowLongPtr
Definition: treelist.c:70
static HWND g_Wnd
Definition: win32.c:39
int g_height
Definition: uimain.c:43
#define LPRECT
Definition: msvc.h:30
#define WS_HSCROLL
Definition: pedump.c:628
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define GWL_STYLE
Definition: winuser.h:846
static int g_yscroll
Definition: win32.c:46
#define WS_VSCROLL
Definition: pedump.c:627
static int g_xscroll
Definition: win32.c:45
static int g_yoff
Definition: win32.c:44
LONG bottom
Definition: windef.h:299
#define GetWindowLongPtr
Definition: treelist.c:73
Arabic default style
Definition: afstyles.h:93
int WINAPI SetScrollPos(_In_ HWND, _In_ int, _In_ int, _In_ BOOL)
LPARAM lParam
Definition: combotst.c:139

◆ handle_WM_VSCROLL()

static LRESULT handle_WM_VSCROLL ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 609 of file win32.c.

Referenced by WndProc().

610 {
611  int code;
612  int oldyscroll;
613 
614  code = (int) LOWORD(wParam); /* scroll bar value */
615  if (code == SB_LINELEFT)
616  {
617  oldyscroll = g_yscroll;
618  g_yscroll--;
619  g_yscroll = UI_MAX(g_yscroll, 0);
621  mi_scroll(0, oldyscroll - g_yscroll);
622  }
623  else if (code == SB_LINERIGHT)
624  {
625  oldyscroll = g_yscroll;
626  g_yscroll++;
629  mi_scroll(0, oldyscroll - g_yscroll);
630  }
631  else if (code == SB_PAGELEFT)
632  {
633  oldyscroll = g_yscroll;
634  g_yscroll -= g_wnd_cheight / 2;
635  g_yscroll = UI_MAX(g_yscroll, 0);
637  mi_scroll(0, oldyscroll - g_yscroll);
638  }
639  else if (code == SB_PAGERIGHT)
640  {
641  oldyscroll = g_yscroll;
642  g_yscroll += g_wnd_cheight / 2;
645  mi_scroll(0, oldyscroll - g_yscroll);
646  }
647  else if (code == SB_BOTTOM)
648  {
649  oldyscroll = g_yscroll;
652  mi_scroll(0, oldyscroll - g_yscroll);
653  }
654  else if (code == SB_TOP)
655  {
656  oldyscroll = g_yscroll;
657  g_yscroll = 0;
659  mi_scroll(0, oldyscroll - g_yscroll);
660  }
661  else if (code == SB_THUMBPOSITION)
662  {
663  oldyscroll = g_yscroll;
664  g_yscroll = (signed short) HIWORD(wParam);
666  mi_scroll(0, oldyscroll - g_yscroll);
667  }
668  return 0;
669 }
#define SB_VERT
Definition: winuser.h:553
static void mi_scroll(int dx, int dy)
Definition: win32.c:220
#define UI_MAX(a, b)
Definition: uimain.h:76
WPARAM wParam
Definition: combotst.c:138
static HWND g_Wnd
Definition: win32.c:39
static int g_wnd_cheight
Definition: win32.c:50
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:91
#define UI_MIN(a, b)
Definition: uimain.h:78
#define SB_THUMBPOSITION
Definition: winuser.h:572
int g_height
Definition: uimain.c:43
#define SB_PAGELEFT
Definition: winuser.h:570
int code
Definition: i386-dis.c:3591
#define SB_LINERIGHT
Definition: winuser.h:567
static int g_yscroll
Definition: win32.c:46
#define SB_TOP
Definition: winuser.h:578
#define SB_PAGERIGHT
Definition: winuser.h:571
#define SB_BOTTOM
Definition: winuser.h:577
#define HIWORD(l)
Definition: typedefs.h:246
#define SB_LINELEFT
Definition: winuser.h:566
int WINAPI SetScrollPos(_In_ HWND, _In_ int, _In_ int, _In_ BOOL)
#define LOWORD(l)
Definition: pedump.c:82
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29

◆ mi_begin_update()

void mi_begin_update ( void  )

Definition at line 1182 of file win32.c.

Referenced by ui_begin_update().

1183 {
1184 }

◆ mi_check_modifier()

static void mi_check_modifier ( void  )
static

Definition at line 258 of file win32.c.

Referenced by handle_WM_SIZE(), and WndProc().

259 {
260  int code;
261 
262  code = mi_read_keyboard_state();
263  ui_set_modifier_state(code);
264 }
void ui_set_modifier_state(int code)
Definition: uimain.c:639
int code
Definition: i386-dis.c:3591
int mi_read_keyboard_state(void)
Definition: win32.c:232

◆ mi_clip()

static HRGN mi_clip ( HDC  dc)
static

Definition at line 737 of file win32.c.

Referenced by mi_fill_rect(), mi_line(), and mi_paint_rect().

738 {
739  HRGN rgn;
740 
745  SelectClipRgn(dc, rgn);
748  return rgn;
749 }
static int g_xoff
Definition: win32.c:43
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
static int g_clip_top
Definition: win32.c:58
static int g_clip_bottom
Definition: win32.c:60
#define HRGN
Definition: msvc.h:39
static RECT g_wnd_clip
Definition: win32.c:61
LONG top
Definition: windef.h:297
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HDC dc
Definition: cylfrac.c:34
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
static int g_clip_right
Definition: win32.c:59
static int g_clip_left
Definition: win32.c:57
static int g_yscroll
Definition: win32.c:46
static int g_xscroll
Definition: win32.c:45
static int g_yoff
Definition: win32.c:44
LONG bottom
Definition: windef.h:299

◆ mi_create_cursor()

void* mi_create_cursor ( unsigned int  x,
unsigned int  y,
int  width,
int  height,
unsigned char andmask,
unsigned char xormask 
)

Definition at line 1345 of file win32.c.

Referenced by ui_create_cursor().

1348 {
1349  HCURSOR hCur;
1350 
1351  hCur = CreateCursor(g_Instance, x, y, width, height, andmask, xormask);
1352  if (hCur == 0)
1353  {
1354  hCur = LoadCursor(NULL, IDC_ARROW);
1355  }
1356  return hCur;
1357 }
GLint GLint GLsizei width
Definition: gl.h:1546
HICON HCURSOR
Definition: windef.h:289
INT INT y
Definition: msvc.h:62
smooth NULL
Definition: ftsmooth.c:416
HCURSOR WINAPI CreateCursor(_In_opt_ HINSTANCE, _In_ int, _In_ int, _In_ int, _In_ int, _In_ CONST VOID *, _In_ CONST VOID *)
#define LoadCursor
Definition: winuser.h:5678
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
INT x
Definition: msvc.h:62
#define IDC_ARROW
Definition: winuser.h:682
static HINSTANCE g_Instance
Definition: win32.c:40

◆ mi_create_window()

int mi_create_window ( void  )

Definition at line 754 of file win32.c.

Referenced by ui_main().

755 {
756  RECT rc;
757  WNDCLASS wc;
758  TCHAR classname[512];
759  TCHAR caption[512];
760  DWORD style;
761  int x;
762  int y;
763  int w;
764  int h;
765 
766  if (g_Wnd != 0 || g_Instance != 0)
767  {
768  return 0;
769  }
771  ZeroMemory(&wc, sizeof(wc));
772  wc.lpfnWndProc = WndProc; /* points to window procedure */
773  /* name of window class */
774  str_to_uni(classname, "rdesktop");
776  str_to_uni(caption, "ReactOS Remote Desktop");
779  /* Register the window class. */
780  if (!RegisterClass(&wc))
781  {
782  return 0; /* Failed to register window class */
783  }
784  rc.left = 0;
785  rc.right = rc.left + UI_MIN(g_width, g_screen_width);
786  rc.top = 0;
788 
789  if (g_fullscreen)
790  {
791  style = WS_POPUP;
792  }
793  else
794  {
797  }
799  {
800  style |= WS_HSCROLL | WS_VSCROLL;
801  }
802  AdjustWindowRectEx(&rc, style, 0, 0);
803  x = CW_USEDEFAULT;
804  y = CW_USEDEFAULT;
805  w = rc.right - rc.left;
806  h = rc.bottom - rc.top;
807 
808  g_Wnd = CreateWindow(wc.lpszClassName, caption,
809  style, x, y, w, h,
810  (HWND) NULL, (HMENU) NULL, g_Instance,
811  (LPVOID) NULL);
812  g_clip_left = 0;
813  g_clip_top = 0;
816  if (g_workarea)
817  {
819  }
820  else
821  {
823  }
825 
827  SetTimer(g_Wnd, 1, 333, 0);
828 
829  return 1;
830 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define CreateWindow
Definition: winuser.h:5620
static int g_clip_top
Definition: win32.c:58
static int g_workarea
Definition: win32.c:52
#define SW_SHOWMAXIMIZED
Definition: winuser.h:767
static int g_clip_bottom
Definition: win32.c:60
int g_width
Definition: uimain.c:42
BOOL WINAPI UpdateWindow(_In_ HWND)
LONG top
Definition: windef.h:297
#define IDI_MSTSC
Definition: resource.h:33
BOOL WINAPI AdjustWindowRectEx(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL, _In_ DWORD)
#define ZeroMemory
Definition: winbase.h:1635
#define WS_SIZEBOX
Definition: pedump.c:642
#define FD_READ
Definition: winsock.h:405
WCHAR classname[128]
Definition: startup.c:15
LONG left
Definition: windef.h:296
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LONG right
Definition: windef.h:298
static HWND g_Wnd
Definition: win32.c:39
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
INT INT y
Definition: msvc.h:62
#define UI_MIN(a, b)
Definition: uimain.h:78
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
static void str_to_uni(TCHAR *sizex, char *size1)
Definition: win32.c:66
INT WSAAPI WSAAsyncSelect(IN SOCKET s, IN HWND hWnd, IN UINT wMsg, IN LONG lEvent)
Definition: select.c:134
static int g_screen_height
Definition: win32.c:48
#define WS_MAXIMIZEBOX
Definition: pedump.c:632
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
int g_height
Definition: uimain.c:43
#define WS_CAPTION
Definition: pedump.c:624
char TCHAR
Definition: xmlstorage.h:189
#define WS_OVERLAPPED
Definition: pedump.c:615
static int g_screen_width
Definition: win32.c:47
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WS_HSCROLL
Definition: pedump.c:628
static int g_clip_right
Definition: win32.c:59
#define WM_APP
Definition: eventvwr.h:70
LPCSTR lpszClassName
Definition: winuser.h:3125
static int g_clip_left
Definition: win32.c:57
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define GetModuleHandle
Definition: winbase.h:3641
#define WS_MINIMIZEBOX
Definition: pedump.c:631
INT x
Definition: msvc.h:62
#define WS_POPUP
Definition: pedump.c:616
#define WS_VSCROLL
Definition: pedump.c:627
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win32.c:674
static int g_fullscreen
Definition: win32.c:51
WNDPROC lpfnWndProc
Definition: winuser.h:3117
LONG bottom
Definition: windef.h:299
#define RegisterClass
Definition: winuser.h:5702
#define LoadIcon
Definition: winuser.h:5679
static HINSTANCE g_Instance
Definition: win32.c:40
Arabic default style
Definition: afstyles.h:93
#define WS_SYSMENU
Definition: pedump.c:629
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
HICON hIcon
Definition: winuser.h:3121
int g_tcp_sck
Definition: uimain.c:51

◆ mi_destroy_cursor()

void mi_destroy_cursor ( void cursor)

Definition at line 1361 of file win32.c.

Referenced by ui_destroy_cursor().

1362 {
1363  if (g_cursor == cursor)
1364  {
1365  g_cursor = 0;
1366  }
1367  DestroyCursor(cursor);
1368 }
BOOL WINAPI DestroyCursor(_In_ HCURSOR)
Definition: cursoricon.c:2654
static HCURSOR g_cursor
Definition: win32.c:41

◆ mi_end_update()

void mi_end_update ( void  )

Definition at line 1188 of file win32.c.

Referenced by ui_end_update().

1189 {
1190 }

◆ mi_error()

void mi_error ( char msg)

Definition at line 131 of file win32.c.

Referenced by error().

132 {
133 #ifdef WITH_DEBUG
134  printf(msg);
135 #else /* WITH_DEBUG */
136  TCHAR lmsg[512];
137  TCHAR ltitle[512];
138 
139  str_to_uni(lmsg, msg);
140  str_to_uni(ltitle, "Error");
141  MessageBox(g_Wnd, lmsg, ltitle, MB_OK);
142 #endif /* WITH_DEBUG */
143 }
static HWND g_Wnd
Definition: win32.c:39
UINT msg
Definition: msvc.h:92
static void str_to_uni(TCHAR *sizex, char *size1)
Definition: win32.c:66
char TCHAR
Definition: xmlstorage.h:189
#define MessageBox
Definition: winuser.h:5688
#define MB_OK
Definition: winuser.h:784
#define printf
Definition: config.h:203

◆ mi_fill_rect()

void mi_fill_rect ( int  x,
int  y,
int  cx,
int  cy,
int  colour 
)

Definition at line 1194 of file win32.c.

Referenced by ui_rect().

1195 {
1196  HBRUSH brush;
1197  RECT rect;
1198  HDC maindc;
1199  HRGN rgn;
1200  int red;
1201  int green;
1202  int blue;
1203 
1204  if (g_server_depth == 8)
1205  {
1206  red = (pal_entries[colour & 0xff] & 0xff0000) >> 16;
1207  green = (pal_entries[colour & 0xff] & 0xff00) >> 8;
1208  blue = pal_entries[colour & 0xff] & 0xff;
1209  }
1210  else if (g_server_depth == 15)
1211  {
1212  SPLIT_COLOUR15(colour, red, green, blue);
1213  }
1214  else if (g_server_depth == 16)
1215  {
1216  SPLIT_COLOUR16(colour, red, green, blue);
1217  }
1218  else if (g_server_depth == 24 || g_server_depth == 32)
1219  {
1220  red = (colour>>16)&0xff;
1221  green = (colour>>8)&0xff;
1222  blue = colour&0xff;
1223  }
1224  maindc = GetWindowDC(g_Wnd);
1225  rgn = mi_clip(maindc);
1226  brush = CreateSolidBrush(RGB(red, green, blue));
1227  rect.left = x + g_xoff - g_xscroll;
1228  rect.top = y + g_yoff - g_yscroll;
1229  rect.right = rect.left + cx;
1230  rect.bottom = rect.top + cy;
1231  FillRect(maindc, &rect, brush);
1232  DeleteObject(brush);
1233  ReleaseDC(g_Wnd, maindc);
1234  DeleteObject(rgn);
1235 }
#define HDC
Definition: msvc.h:22
static int g_xoff
Definition: win32.c:43
#define SPLIT_COLOUR16(c, r, g, b)
Definition: uimain.h:50
int g_server_depth
Definition: uimain.c:41
#define HRGN
Definition: msvc.h:39
LONG top
Definition: windef.h:297
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
& rect
Definition: startmenu.cpp:1413
static HWND g_Wnd
Definition: win32.c:39
INT INT y
Definition: msvc.h:62
static HRGN mi_clip(HDC dc)
Definition: win32.c:737
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
GLclampf GLclampf blue
Definition: gl.h:1740
#define red
Definition: linetest.c:67
int pal_entries[]
Definition: uimain.c:52
#define RGB(r, g, b)
Definition: wingdi.h:2917
GLclampf green
Definition: gl.h:1740
static int g_yscroll
Definition: win32.c:46
INT x
Definition: msvc.h:62
HDC WINAPI GetWindowDC(_In_opt_ HWND)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
static int g_xscroll
Definition: win32.c:45
_Out_opt_ int * cx
Definition: commctrl.h:570
static int g_yoff
Definition: win32.c:44
LONG bottom
Definition: windef.h:299
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define SPLIT_COLOUR15(c, r, g, b)
Definition: uimain.h:43

◆ mi_line()

void mi_line ( int  x1,
int  y1,
int  x2,
int  y2,
int  colour 
)

Definition at line 1239 of file win32.c.

Referenced by ui_line().

1240 {
1241  HPEN pen;
1242  HDC maindc;
1243  HGDIOBJ save;
1244  HRGN rgn;
1245  int red;
1246  int green;
1247  int blue;
1248 
1249  if (g_server_depth == 8)
1250  {
1251  red = (pal_entries[colour & 0xff] & 0xff0000) >> 16;
1252  green = (pal_entries[colour & 0xff] & 0xff00) >> 8;
1253  blue = pal_entries[colour & 0xff] & 0xff;
1254  }
1255  else if (g_server_depth == 15)
1256  {
1257  SPLIT_COLOUR15(colour, red, green, blue);
1258  }
1259  else if (g_server_depth == 16)
1260  {
1261  SPLIT_COLOUR16(colour, red, green, blue);
1262  }
1263  else if (g_server_depth == 24 || g_server_depth == 32)
1264  {
1265  red = (colour>>16)&0xff;
1266  green = (colour>>8)&0xff;
1267  blue = colour&0xff;
1268  }
1269  maindc = GetWindowDC(g_Wnd);
1270  rgn = mi_clip(maindc);
1271  pen = CreatePen(PS_SOLID, 0, RGB(red, green, blue));
1272  save = SelectObject(maindc, pen);
1273  MoveToEx(maindc, x1 + g_xoff - g_xscroll, y1 + g_yoff - g_yscroll, 0);
1274  LineTo(maindc, x2 + g_xoff - g_xscroll, y2 + g_yoff - g_yscroll);
1275  SelectObject(maindc, save);
1276  DeleteObject(pen);
1277  ReleaseDC(g_Wnd, maindc);
1278  DeleteObject(rgn);
1279 }
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
Definition: winddi.h:3706
#define HDC
Definition: msvc.h:22
static int g_xoff
Definition: win32.c:43
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define SPLIT_COLOUR16(c, r, g, b)
Definition: uimain.h:50
int g_server_depth
Definition: uimain.c:41
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
#define HRGN
Definition: msvc.h:39
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
static HWND g_Wnd
Definition: win32.c:39
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
#define PS_SOLID
Definition: wingdi.h:584
static HRGN mi_clip(HDC dc)
Definition: win32.c:737
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
GLclampf GLclampf blue
Definition: gl.h:1740
#define red
Definition: linetest.c:67
int pal_entries[]
Definition: uimain.c:52
#define RGB(r, g, b)
Definition: wingdi.h:2917
GLclampf green
Definition: gl.h:1740
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG _In_ LONG y2
Definition: winddi.h:3706
static int g_yscroll
Definition: win32.c:46
HDC WINAPI GetWindowDC(_In_opt_ HWND)
static int g_xscroll
Definition: win32.c:45
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3706
static int g_yoff
Definition: win32.c:44
#define SPLIT_COLOUR15(c, r, g, b)
Definition: uimain.h:43

◆ mi_main_loop()

int mi_main_loop ( void  )

Definition at line 834 of file win32.c.

Referenced by ui_main().

835 {
836  MSG msg;
837 
838  while (GetMessage(&msg, NULL, 0, 0))
839  {
840  TranslateMessage(&msg);
841  DispatchMessage(&msg);
842  }
843  return msg.wParam;
844 }
#define DispatchMessage
Definition: winuser.h:5631
BOOL WINAPI TranslateMessage(_In_ const MSG *)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
smooth NULL
Definition: ftsmooth.c:416
#define GetMessage
Definition: winuser.h:5656
#define msg(x)
Definition: auth_time.c:54

◆ mi_paint_rect()

void mi_paint_rect ( char data,
int  width,
int  height,
int  x,
int  y,
int  cx,
int  cy 
)

Definition at line 874 of file win32.c.

Referenced by ui_invalidate().

875 {
876  HBITMAP bitmap;
877  BITMAPINFO bi;
878  HDC dc;
879  HDC maindc;
880  HGDIOBJ save;
881  HRGN rgn;
882  void * bits;
883  int i;
884  int j;
885  int colour;
886  int red;
887  int green;
888  int blue;
889  int index;
890 
891  ZeroMemory(&bi, sizeof(bi));
892  bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
893  bi.bmiHeader.biWidth = width;
894  bi.bmiHeader.biHeight = -height;
895  bi.bmiHeader.biPlanes = 1;
896  bi.bmiHeader.biBitCount = 32;
898  maindc = GetWindowDC(g_Wnd);
899  bitmap = CreateDIBSection(maindc, &bi, DIB_RGB_COLORS, (void **) &bits, 0, 0);
900  if (bitmap == 0)
901  {
902  mi_show_error("CreateDIBSection failed");
903  }
904 
905  if (g_server_depth == 8)
906  {
907  for (i = cy - 1; i >= 0; i--)
908  {
909  for (j = cx - 1; j >= 0; j--)
910  {
911  colour = ((unsigned char*)data)[i * cx + j];
912  red = (pal_entries[colour & 0xff] & 0xff0000) >> 16;
913  green = (pal_entries[colour & 0xff] & 0xff00) >> 8;
914  blue = pal_entries[colour & 0xff] & 0xff;
915  MAKE_COLOUR32(colour, red, green, blue);
916  ((unsigned int*)bits)[i * cx + j] = colour;
917  }
918  }
919  }
920  else if (g_server_depth == 15)
921  {
922  for (i = cy - 1; i >= 0; i--)
923  {
924  for (j = cx - 1; j >= 0; j--)
925  {
926  colour = ((unsigned short*)data)[i * cx + j];
927  SPLIT_COLOUR15(colour, red, green, blue);
928  MAKE_COLOUR32(colour, red, green, blue);
929  ((unsigned int*)bits)[i * cx + j] = colour;
930  }
931  }
932  }
933  else if (g_server_depth == 16)
934  {
935  for (i = cy - 1; i >= 0; i--)
936  {
937  for (j = cx - 1; j >= 0; j--)
938  {
939  colour = ((unsigned short*)data)[i * cx + j];
940  SPLIT_COLOUR16(colour, red, green, blue);
941  MAKE_COLOUR32(colour, red, green, blue);
942  ((unsigned int*)bits)[i * cx + j] = colour;
943  }
944  }
945  }
946  else if (g_server_depth == 24)
947  {
948  for (i = cy - 1; i >= 0; i--)
949  {
950  for (j = cx - 1; j >= 0; j--)
951  {
952  index = (i * cx + j) * 3;
953  red = ((unsigned char*)data)[index + 2];
954  green = ((unsigned char*)data)[index + 1];
955  blue = ((unsigned char*)data)[index];
956  MAKE_COLOUR32(colour, red, green, blue);
957  ((unsigned int*)bits)[i * cx + j] = colour;
958  }
959  }
960  }
961  else if (g_server_depth == 32)
962  {
963  memcpy(bits, data, cx*cy*4);
964  }
965  dc = CreateCompatibleDC(maindc);
966  if (dc == 0)
967  {
968  mi_show_error("CreateCompatibleDC failed");
969  }
970  save = SelectObject(dc, bitmap);
971  rgn = mi_clip(maindc);
972  BitBlt(maindc, x + g_xoff - g_xscroll, y + g_yoff - g_yscroll, cx, cy, dc,
973  0, 0, SRCCOPY);
974  SelectObject(dc, save);
975  DeleteObject(bitmap);
976  DeleteDC(dc);
977  ReleaseDC(g_Wnd, maindc);
978  DeleteObject(rgn);
979 
980 }
#define HDC
Definition: msvc.h:22
static int g_xoff
Definition: win32.c:43
GLint GLint GLsizei width
Definition: gl.h:1546
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint 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 GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
#define SPLIT_COLOUR16(c, r, g, b)
Definition: uimain.h:50
#define MAKE_COLOUR32(c, r, g, b)
Definition: uimain.h:66
#define HBITMAP
Definition: msvc.h:28
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1453
int g_server_depth
Definition: uimain.c:41
#define HRGN
Definition: msvc.h:39
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define ZeroMemory
Definition: winbase.h:1635
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC dc
Definition: cylfrac.c:34
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:416
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
static HWND g_Wnd
Definition: win32.c:39
INT INT y
Definition: msvc.h:62
static HRGN mi_clip(HDC dc)
Definition: win32.c:737
GLenum GLclampf GLint i
Definition: glfuncs.h:14
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
DWORD biCompression
Definition: amvideo.idl:35
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
GLclampf GLclampf blue
Definition: gl.h:1740
#define red
Definition: linetest.c:67
int pal_entries[]
Definition: uimain.c:52
GLclampf green
Definition: gl.h:1740
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define index(s, c)
Definition: various.h:29
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
static int g_yscroll
Definition: win32.c:46
BOOL WINAPI DeleteDC(_In_ HDC)
INT x
Definition: msvc.h:62
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
HDC WINAPI GetWindowDC(_In_opt_ HWND)
static int g_xscroll
Definition: win32.c:45
static void mi_show_error(char *caption)
Definition: win32.c:854
_Out_opt_ int * cx
Definition: commctrl.h:570
static int g_yoff
Definition: win32.c:44
static HBITMAP bitmap
Definition: clipboard.c:1344
#define DIB_RGB_COLORS
Definition: wingdi.h:365
#define BI_RGB
Definition: precomp.h:35
#define SRCCOPY
Definition: wingdi.h:331
#define SPLIT_COLOUR15(c, r, g, b)
Definition: uimain.h:43

◆ mi_read_keyboard_state()

int mi_read_keyboard_state ( void  )

Definition at line 232 of file win32.c.

Referenced by mi_check_modifier(), and read_keyboard_state().

233 {
234  short keydata;
235  int code;
236 
237  code = 0;
238  keydata = GetKeyState(VK_SCROLL);
239  if (keydata & 0x0001)
240  {
241  code |= 1;
242  }
243  keydata = GetKeyState(VK_NUMLOCK);
244  if (keydata & 0x0001)
245  {
246  code |= 2;
247  }
248  keydata = GetKeyState(VK_CAPITAL);
249  if (keydata & 0x0001)
250  {
251  code |= 4;
252  }
253  return code;
254 }
SHORT WINAPI GetKeyState(_In_ int)
int code
Definition: i386-dis.c:3591
#define VK_SCROLL
Definition: winuser.h:2234
#define VK_NUMLOCK
Definition: winuser.h:2233
#define VK_CAPITAL
Definition: winuser.h:2160

◆ mi_reset_clip()

void mi_reset_clip ( void  )

Definition at line 1335 of file win32.c.

Referenced by ui_reset_clip().

1336 {
1337  g_clip_left = 0;
1338  g_clip_top = 0;
1341 }
static int g_clip_top
Definition: win32.c:58
static int g_clip_bottom
Definition: win32.c:60
int g_width
Definition: uimain.c:42
int g_height
Definition: uimain.c:43
static int g_clip_right
Definition: win32.c:59
static int g_clip_left
Definition: win32.c:57

◆ mi_screen_copy()

void mi_screen_copy ( int  x,
int  y,
int  cx,
int  cy,
int  srcx,
int  srcy 
)

Definition at line 1283 of file win32.c.

Referenced by ui_screenblt().

1284 {
1285  RECT rect;
1286  RECT clip_rect;
1287  RECT draw_rect;
1288  HRGN rgn;
1289  int ok_to_ScrollWindowEx;
1290 
1291  ok_to_ScrollWindowEx = 1;
1292 
1293  if (!ok_to_ScrollWindowEx)
1294  {
1295  rgn = CreateRectRgn(x - g_xscroll, y - g_yscroll,
1296  (x - g_xscroll) + cx,
1297  (y - g_yscroll) + cy);
1298  InvalidateRgn(g_Wnd, rgn, 0);
1299  DeleteObject(rgn);
1300  }
1301  else
1302  {
1303  /* this is all in client coords */
1304  rect.left = srcx - g_xscroll;
1305  rect.top = srcy - g_yscroll;
1306  rect.right = rect.left + cx;
1307  rect.bottom = rect.top + cy;
1308  clip_rect.left = g_clip_left - g_xscroll;
1309  clip_rect.top = g_clip_top - g_yscroll;
1310  clip_rect.right = g_clip_right - g_xscroll;
1311  clip_rect.bottom = g_clip_bottom - g_yscroll;
1312  if (IntersectRect(&draw_rect, &clip_rect, &g_wnd_clip))
1313  {
1314  rgn = CreateRectRgn(0, 0, 0, 0);
1315  ScrollWindowEx(g_Wnd, x - srcx, y - srcy, &rect, &draw_rect,
1316  rgn, 0, SW_ERASE);
1317  InvalidateRgn(g_Wnd, rgn, 0);
1318  DeleteObject(rgn);
1319  }
1320  }
1321 }
static int g_clip_top
Definition: win32.c:58
static int g_clip_bottom
Definition: win32.c:60
#define HRGN
Definition: msvc.h:39
static RECT g_wnd_clip
Definition: win32.c:61
LONG top
Definition: windef.h:297
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
& rect
Definition: startmenu.cpp:1413
static HWND g_Wnd
Definition: win32.c:39
INT INT y
Definition: msvc.h:62
#define SW_ERASE
Definition: winuser.h:2534
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
BOOL WINAPI InvalidateRgn(_In_ HWND, _In_opt_ HRGN, _In_ BOOL)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
static int g_clip_right
Definition: win32.c:59
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
static int g_clip_left
Definition: win32.c:57
static int g_yscroll
Definition: win32.c:46
INT x
Definition: msvc.h:62
static int g_xscroll
Definition: win32.c:45
_Out_opt_ int * cx
Definition: commctrl.h:570
LONG bottom
Definition: windef.h:299

◆ mi_scroll()

static void mi_scroll ( int  dx,
int  dy 
)
static

Definition at line 220 of file win32.c.

Referenced by handle_WM_HSCROLL(), handle_WM_SIZE(), and handle_WM_VSCROLL().

221 {
222  HRGN rgn;
223 
224  rgn = CreateRectRgn(0, 0, 0, 0);
225  ScrollWindowEx(g_Wnd, dx, dy, 0, 0, rgn, 0, SW_ERASE);
226  InvalidateRgn(g_Wnd, rgn, 0);
227  DeleteObject(rgn);
228 }
#define HRGN
Definition: msvc.h:39
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
static HWND g_Wnd
Definition: win32.c:39
#define SW_ERASE
Definition: winuser.h:2534
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
BOOL WINAPI InvalidateRgn(_In_ HWND, _In_opt_ HRGN, _In_ BOOL)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
INT INT dy
Definition: msvc.h:65
INT dx
Definition: msvc.h:65

◆ mi_set_clip()

void mi_set_clip ( int  x,
int  y,
int  cx,
int  cy 
)

Definition at line 1325 of file win32.c.

Referenced by ui_set_clip().

1326 {
1327  g_clip_left = x;
1328  g_clip_top = y;
1331 }
static int g_clip_top
Definition: win32.c:58
static int g_clip_bottom
Definition: win32.c:60
INT INT y
Definition: msvc.h:62
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
static int g_clip_right
Definition: win32.c:59
static int g_clip_left
Definition: win32.c:57
INT x
Definition: msvc.h:62
_Out_opt_ int * cx
Definition: commctrl.h:570

◆ mi_set_cursor()

void mi_set_cursor ( void cursor)

Definition at line 1372 of file win32.c.

Referenced by ui_set_cursor().

1373 {
1374  g_cursor = cursor;
1376 }
static HCURSOR g_cursor
Definition: win32.c:41
const char cursor[]
Definition: icontest.c:13
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)

◆ mi_set_null_cursor()

void mi_set_null_cursor ( void  )

Definition at line 1380 of file win32.c.

Referenced by ui_set_null_cursor().

1381 {
1382 }

◆ mi_show_error()

static void mi_show_error ( char caption)
static

Definition at line 854 of file win32.c.

Referenced by mi_paint_rect().

855 {
856  LPVOID lpMsgBuf;
857  TCHAR lcaption[512];
858 
861  (LPTSTR) &lpMsgBuf, 0, NULL);
862 #ifdef WITH_DEBUG
863  printf(lpMsgBuf);
864 #else /* WITH_DEBUG */
865  str_to_uni(lcaption, caption);
866  MessageBox(g_Wnd, (LPTSTR) lpMsgBuf, lcaption,
868 #endif /* WITH_DEBUG */
869  LocalFree(lpMsgBuf);
870 }
#define LANG_NEUTRAL
Definition: nls.h:22
#define SUBLANG_DEFAULT
Definition: nls.h:168
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static HWND g_Wnd
Definition: win32.c:39
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
smooth NULL
Definition: ftsmooth.c:416
static void str_to_uni(TCHAR *sizex, char *size1)
Definition: win32.c:66
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
char TCHAR
Definition: xmlstorage.h:189
#define FormatMessage
Definition: winbase.h:3609
#define MB_ICONINFORMATION
Definition: winuser.h:796
#define MessageBox
Definition: winuser.h:5688
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define MB_OK
Definition: winuser.h:784
#define MAKELANGID(p, s)
Definition: nls.h:15
#define printf
Definition: config.h:203

◆ mi_warning()

void mi_warning ( char msg)

Definition at line 848 of file win32.c.

Referenced by unimpl(), and warning().

849 {
850 }

◆ ParseCommandLine()

static BOOL ParseCommandLine ( LPWSTR  lpCmdLine,
PRDPSETTINGS  pRdpSettings,
BOOL bSkipDlg 
)
static

Definition at line 1034 of file win32.c.

Referenced by wWinMain().

1037 {
1038  LPWSTR lpStr = lpCmdLine;
1039  WCHAR szSeps[] = L"/";
1040  LPWSTR lpToken;
1041  BOOL bRet = TRUE;
1042 
1043  *bSkipDlg = TRUE;
1044 
1045  if (*lpCmdLine != L'/')
1046  {
1047  LoadRdpSettingsFromFile(pRdpSettings, lpCmdLine);
1048  }
1049  else
1050  {
1051  /* default to screen size, 16bpp */
1052  SetIntegerToSettings(pRdpSettings, L"session bpp", 16);
1053  SetIntegerToSettings(pRdpSettings, L"desktopwidth", GetSystemMetrics(SM_CXSCREEN));
1054  SetIntegerToSettings(pRdpSettings, L"desktopheight", GetSystemMetrics(SM_CYSCREEN));
1055 
1056  lpToken = wcstok(lpStr, szSeps);
1057  while (lpToken)
1058  {
1059  if (wcsncmp(lpToken, L"edit", 4) == 0)
1060  {
1061  lpToken += 5;
1062  LoadRdpSettingsFromFile(pRdpSettings, lpToken);
1063  *bSkipDlg = FALSE;
1064  break;
1065  }
1066 
1067  if (*lpToken == L'v')
1068  {
1069  lpToken += 2;
1070  SetStringToSettings(pRdpSettings, L"full address", lpToken);
1071  }
1072  else if (*lpToken == L'w')
1073  {
1074  lpToken += 2;
1075  SetIntegerToSettings(pRdpSettings, L"desktopwidth", _wtoi(lpToken));
1076  }
1077  else if (*lpToken == L'h')
1078  {
1079  lpToken += 2;
1080  SetIntegerToSettings(pRdpSettings, L"desktopheight", _wtoi(lpToken));
1081  }
1082  else if (*lpToken == L'f')
1083  {
1084  SetIntegerToSettings(pRdpSettings, L"screen mode id", 2);
1085  }
1086 
1087  lpToken = wcstok(NULL, szSeps);
1088  }
1089  }
1090 
1091  return bRet;
1092 }
BOOL SetIntegerToSettings(PRDPSETTINGS pRdpSettings, LPWSTR lpKey, INT Value)
Definition: settings.c:86
#define TRUE
Definition: types.h:120
BOOL SetStringToSettings(PRDPSETTINGS pRdpSettings, LPWSTR lpKey, LPWSTR lpValue)
Definition: settings.c:115
__wchar_t WCHAR
Definition: xmlstorage.h:180
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
_Check_return_ _CRTIMP wchar_t *__cdecl wcstok(_Inout_opt_z_ wchar_t *_Str, _In_z_ const wchar_t *_Delim)
#define SM_CXSCREEN
Definition: winuser.h:949
smooth NULL
Definition: ftsmooth.c:416
#define SM_CYSCREEN
Definition: winuser.h:950
unsigned int BOOL
Definition: ntddk_ex.h:94
int WINAPI GetSystemMetrics(_In_ int)
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
static const WCHAR L[]
Definition: oid.c:1087
BOOL LoadRdpSettingsFromFile(PRDPSETTINGS pRdpSettings, LPWSTR lpFile)
Definition: settings.c:418
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ SetDomainAndUsername()

static VOID SetDomainAndUsername ( PCHAR  pName)
static

Definition at line 1007 of file win32.c.

Referenced by wWinMain().

1008 {
1009  PCHAR pDomain;
1010  PCHAR pUsername;
1011 
1012  strcpy(g_domain, "");
1013  strcpy(g_username, "");
1014 
1015  pDomain = strtok(pName, "\\");
1016 
1017  if(pDomain == NULL)
1018  return;
1019 
1020  pUsername = strtok(NULL, "\\");
1021 
1022  if(pUsername == NULL)
1023  {
1024  strcpy(g_username, pDomain);
1025  return;
1026  }
1027 
1028  strcpy(g_username, pUsername);
1029  strcpy(g_domain, pDomain);
1030  return;
1031 }
signed char * PCHAR
Definition: retypes.h:7
smooth NULL
Definition: ftsmooth.c:416
static LPSTR pName
Definition: security.c:75
char g_domain[]
Definition: uimain.c:31
char * strtok(char *String, const char *Delimiters)
Definition: utclib.c:338
char g_username[]
Definition: uimain.c:25
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

◆ str_to_uni()

static void str_to_uni ( TCHAR sizex,
char size1 
)
static

Definition at line 66 of file win32.c.

Referenced by mi_create_window(), mi_error(), and mi_show_error().

67 {
68  int len;
69  int i;
70 
71  len = strlen(size1);
72  for (i = 0; i < len; i++)
73  {
74  sizex[i] = size1[i];
75  }
76  sizex[len] = 0;
77 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLclampf GLint i
Definition: glfuncs.h:14
GLenum GLsizei len
Definition: glext.h:6722

◆ uni_to_str()

static void uni_to_str ( char sizex,
TCHAR size1 
)
static

Definition at line 81 of file win32.c.

Referenced by wWinMain().

82 {
83  int len;
84  int i;
85 
86  len = lstrlen(size1);
87  for (i = 0; i < len; i++)
88  {
89  sizex[i] = (char)size1[i];
90  }
91  sizex[len] = 0;
92 }
GLenum GLclampf GLint i
Definition: glfuncs.h:14
unsigned char
Definition: typeof.h:27
GLenum GLsizei len
Definition: glext.h:6722
#define lstrlen
Definition: winbase.h:3690

◆ WndProc()

LRESULT CALLBACK WndProc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 674 of file win32.c.

Referenced by mi_create_window().

675 {
676  switch (message)
677  {
678  case WM_SETCURSOR:
679  return handle_WM_SETCURSOR(hWnd, message, wParam, lParam);
680  case 0x0084: /* WinCE don't have this WM_NCHITTEST: */
681  return handle_WM_NCHITTEST(hWnd, message, wParam, lParam);
682  case WM_MOUSEMOVE:
683  return handle_WM_MOUSEMOVE(hWnd, message, wParam, lParam);
684  case WM_LBUTTONDOWN:
685  return handle_WM_LBUTTONDOWN(hWnd, message, wParam, lParam);
686  case WM_LBUTTONUP:
687  return handle_WM_LBUTTONUP(hWnd, message, wParam, lParam);
688  case WM_RBUTTONDOWN:
689  return handle_WM_RBUTTONDOWN(hWnd, message, wParam, lParam);
690  case WM_RBUTTONUP:
691  return handle_WM_RBUTTONUP(hWnd, message, wParam, lParam);
692  case WM_MBUTTONDOWN:
693  return handle_WM_MBUTTONDOWN(hWnd, message, wParam, lParam);
694  case WM_MBUTTONUP:
695  return handle_WM_MBUTTONUP(hWnd, message, wParam, lParam);
696  /* some windows compilers don't have these defined like vc6 */
697  case 0x020a: /* WM_MOUSEWHEEL: */
698  return handle_WM_MOUSEWHEEL(hWnd, message, wParam, lParam);
699  case WM_KEYDOWN:
700  case WM_KEYUP:
701  case WM_SYSKEYDOWN:
702  case WM_SYSKEYUP:
703  return handle_WM_KEY(hWnd, message, wParam, lParam);
704  case WM_CHAR:
705  case WM_DEADCHAR:
706  case WM_SYSCHAR:
707  case WM_SYSDEADCHAR:
708  break;
709  case WM_PAINT:
710  return handle_WM_PAINT(hWnd, message, wParam, lParam);
711  case WM_DESTROY:
712  PostQuitMessage(0);
713  break;
714  case WM_APP + 1:
715  case WM_TIMER:
716  check_sck();
717  break;
718  case WM_SIZE:
719  return handle_WM_SIZE(hWnd, message, wParam, lParam);
720  case 532: /* not defined in wince WM_SIZING: */
721  return handle_WM_SIZING(hWnd, message, wParam, lParam);
722  case WM_HSCROLL:
723  return handle_WM_HSCROLL(hWnd, message, wParam, lParam);
724  case WM_VSCROLL:
725  return handle_WM_VSCROLL(hWnd, message, wParam, lParam);
726  case WM_SETFOCUS:
728  return DefWindowProc(hWnd, message, wParam, lParam);
729  default:
730  return DefWindowProc(hWnd, message, wParam, lParam);
731  }
732  return 0;
733 }
#define WM_MBUTTONUP
Definition: winuser.h:1759
Definition: tftpd.h:59
#define WM_CHAR
Definition: winuser.h:1693
#define WM_LBUTTONDOWN
Definition: winuser.h:1752
static LRESULT handle_WM_MOUSEMOVE(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win32.c:299
static LRESULT handle_WM_SETCURSOR(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win32.c:268
static LRESULT handle_WM_SIZE(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win32.c:456
static void mi_check_modifier(void)
Definition: win32.c:258
static LRESULT handle_WM_MBUTTONDOWN(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win32.c:349
WPARAM wParam
Definition: combotst.c:138
static LRESULT handle_WM_PAINT(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win32.c:421
#define WM_SETCURSOR
Definition: winuser.h:1618
#define WM_SYSCHAR
Definition: winuser.h:1697
static LRESULT handle_WM_SIZING(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win32.c:505
static LRESULT handle_WM_RBUTTONDOWN(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win32.c:329
#define WM_KEYDOWN
Definition: winuser.h:1691
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
static LRESULT handle_WM_MOUSEWHEEL(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win32.c:369
#define WM_RBUTTONDOWN
Definition: winuser.h:1755
#define WM_DEADCHAR
Definition: winuser.h:1694
#define WM_SIZE
Definition: winuser.h:1593
static int check_sck(void)
Definition: win32.c:97
static LRESULT handle_WM_LBUTTONDOWN(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win32.c:309
#define WM_TIMER
Definition: winuser.h:1718
#define WM_KEYUP
Definition: winuser.h:1692
static LRESULT handle_WM_RBUTTONUP(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win32.c:339
#define WM_RBUTTONUP
Definition: winuser.h:1756
#define WM_PAINT
Definition: winuser.h:1602
#define WM_APP
Definition: eventvwr.h:70
static LRESULT handle_WM_HSCROLL(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win32.c:545
static LRESULT handle_WM_LBUTTONUP(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win32.c:319
static LRESULT handle_WM_NCHITTEST(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win32.c:283
#define WM_SYSDEADCHAR
Definition: winuser.h:1698
#define WM_SYSKEYUP
Definition: winuser.h:1696
#define WM_LBUTTONUP
Definition: winuser.h:1753
#define WM_MBUTTONDOWN
Definition: winuser.h:1758
static LRESULT handle_WM_MBUTTONUP(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win32.c:359
#define WM_MOUSEMOVE
Definition: winuser.h:1751
#define WM_HSCROLL
Definition: winuser.h:1719
#define WM_SYSKEYDOWN
Definition: winuser.h:1695
#define WM_SETFOCUS
Definition: winuser.h:1595
LPARAM lParam
Definition: combotst.c:139
static LRESULT handle_WM_KEY(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win32.c:389
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
static LRESULT handle_WM_VSCROLL(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: win32.c:609
#define WM_VSCROLL
Definition: winuser.h:1720

◆ wWinMain()

int WINAPI wWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPWSTR  lpCmdLine,
int  nShowCmd 
)

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 1096 of file win32.c.

1100 {
1101  PRDPSETTINGS pRdpSettings;
1102  WSADATA d;
1103  int ret = 1;
1104 
1105  if (WSAStartup(MAKEWORD(2, 0), &d) == 0)
1106  {
1107  pRdpSettings = HeapAlloc(GetProcessHeap(),
1108  0,
1109  sizeof(RDPSETTINGS));
1110  if (pRdpSettings)
1111  {
1112  pRdpSettings->pSettings = NULL;
1113  pRdpSettings->NumSettings = 0;
1114 
1115  if (InitRdpSettings(pRdpSettings))
1116  {
1117  BOOL bSkipDlg = FALSE;
1118 
1119  if (*lpCmdLine)
1120  ParseCommandLine(lpCmdLine, pRdpSettings,&bSkipDlg);
1121  else
1122  LoadRdpSettingsFromFile(pRdpSettings, NULL);
1123 
1124  if (bSkipDlg || OpenRDPConnectDialog(hInstance,
1125  pRdpSettings))
1126  {
1127  char szValue[MAXVALUE];
1128  DWORD dwSize = MAXVALUE;
1129 
1130  uni_to_str(szValue, GetStringFromSettings(pRdpSettings, L"full address"));
1131 
1132  /* GetPortNumber also removes possible trailing port number from address */
1133  g_tcp_port_rdp = GetPortNumber(szValue);
1134  strcpy(g_servername, szValue);
1135  uni_to_str(szValue, GetStringFromSettings(pRdpSettings, L"username"));
1136  SetDomainAndUsername(szValue);
1137  strcpy(g_password, "");
1138  if (GetComputerNameA(szValue, &dwSize))
1139  strcpy(g_hostname, szValue);
1140  else
1142  g_server_depth = GetIntegerFromSettings(pRdpSettings, L"session bpp");
1145  g_width = GetIntegerFromSettings(pRdpSettings, L"desktopwidth");
1146  g_height = GetIntegerFromSettings(pRdpSettings, L"desktopheight");
1147  if (GetIntegerFromSettings(pRdpSettings, L"screen mode id") == 2)
1148  {
1149  g_fullscreen = 1;
1150  g_xoff = 0;
1151  g_yoff = 0;
1152  }
1153  else
1154  {
1157  }
1158 
1159  ui_main();
1160  ret = 0;
1161  }
1162 
1164  0,
1165  pRdpSettings->pSettings);
1166  }
1167 
1169  0,
1170  pRdpSettings);
1171  }
1172 
1173  WSACleanup();
1174  }
1175 
1176  return ret;
1177 }
static void uni_to_str(char *sizex, TCHAR *size1)
Definition: win32.c:81
static int g_xoff
Definition: win32.c:43
int g_tcp_port_rdp
Definition: tcp.c:75
#define MAKEWORD(a, b)
Definition: typedefs.h:247
BOOL InitRdpSettings(PRDPSETTINGS pRdpSettings)
Definition: settings.c:475
int g_server_depth
Definition: uimain.c:41
char g_password[]
Definition: uimain.c:28
LPWSTR GetStringFromSettings(PRDPSETTINGS pSettings, LPWSTR lpValue)
Definition: settings.c:171
int g_width
Definition: uimain.c:42
static VOID SetDomainAndUsername(PCHAR pName)
Definition: win32.c:1007
int ui_main(void)
Definition: uimain.c:951
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
#define SM_CXEDGE
Definition: winuser.h:998
static BOOL ParseCommandLine(LPWSTR lpCmdLine, PRDPSETTINGS pRdpSettings, BOOL *bSkipDlg)
Definition: win32.c:1034
INT GetIntegerFromSettings(PRDPSETTINGS pSettings, LPWSTR lpValue)
Definition: settings.c:144
BOOL WINAPI GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:322
#define SM_CXSCREEN
Definition: winuser.h:949
char * tcp_get_address(void)
Definition: tcp.c:866
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
smooth NULL
Definition: ftsmooth.c:416
#define SM_CYEDGE
Definition: winuser.h:999
BOOL OpenRDPConnectDialog(HINSTANCE hInstance, PRDPSETTINGS pRdpSettings)
static int g_screen_height
Definition: win32.c:48
int g_height
Definition: uimain.c:43
#define SM_CYSCREEN
Definition: winuser.h:950
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
#define SM_CYCAPTION
Definition: winuser.h:953
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define d
Definition: ke_i.h:81
static int g_screen_width
Definition: win32.c:47
PSETTINGS pSettings
Definition: precomp.h:45
char g_hostname[]
Definition: uimain.c:26
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static const WCHAR L[]
Definition: oid.c:1087
BOOL LoadRdpSettingsFromFile(PRDPSETTINGS pRdpSettings, LPWSTR lpFile)
Definition: settings.c:418
static int g_fullscreen
Definition: win32.c:51
static int g_yoff
Definition: win32.c:44
INT NumSettings
Definition: precomp.h:46
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define MAXVALUE
Definition: precomp.h:29
static INT GetPortNumber(PCHAR szAddress)
Definition: win32.c:983
#define HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
char g_servername[]
Definition: uimain.c:27

Variable Documentation

◆ g_block

int g_block = 0
static

Definition at line 42 of file win32.c.

Referenced by check_sck().

◆ g_clip_bottom

int g_clip_bottom = 600
static

Definition at line 60 of file win32.c.

Referenced by mi_clip(), mi_create_window(), mi_reset_clip(), mi_screen_copy(), and mi_set_clip().

◆ g_clip_left

int g_clip_left = 0
static

Definition at line 57 of file win32.c.

Referenced by mi_clip(), mi_create_window(), mi_reset_clip(), mi_screen_copy(), and mi_set_clip().

◆ g_clip_right

int g_clip_right = 800
static

Definition at line 59 of file win32.c.

Referenced by mi_clip(), mi_create_window(), mi_reset_clip(), mi_screen_copy(), and mi_set_clip().

◆ g_clip_top

int g_clip_top = 0
static

Definition at line 58 of file win32.c.

Referenced by mi_clip(), mi_create_window(), mi_reset_clip(), mi_screen_copy(), and mi_set_clip().

◆ g_cursor

HCURSOR g_cursor = 0
static

Definition at line 41 of file win32.c.

Referenced by handle_WM_SETCURSOR(), mi_destroy_cursor(), and mi_set_cursor().

◆ g_directory

char g_directory[]

Definition at line 30 of file uimain.c.

Referenced by ui_main().

◆ g_domain

char g_domain[]

Definition at line 31 of file uimain.c.

Referenced by SetDomainAndUsername(), and ui_main().

◆ g_fullscreen

int g_fullscreen = 0
static

Definition at line 51 of file win32.c.

Referenced by mi_create_window(), and wWinMain().

◆ g_height

◆ g_hostname

char g_hostname[]

◆ g_Instance

HINSTANCE g_Instance = 0
static

Definition at line 40 of file win32.c.

◆ g_mousex

◆ g_mousey

◆ g_password

char g_password[]

Definition at line 28 of file uimain.c.

Referenced by ui_main(), and wWinMain().

◆ g_screen_height

int g_screen_height = 0
static

Definition at line 48 of file win32.c.

Referenced by mi_create_window(), and wWinMain().

◆ g_screen_width

int g_screen_width = 0
static

Definition at line 47 of file win32.c.

Referenced by mi_create_window(), and wWinMain().

◆ g_server_depth

◆ g_servername

char g_servername[]

Definition at line 27 of file uimain.c.

Referenced by parse_parameters(), ui_main(), ui_main_loop(), and wWinMain().

◆ g_shell

char g_shell[]

Definition at line 29 of file uimain.c.

Referenced by ui_main().

◆ g_tcp_port_rdp

int g_tcp_port_rdp

Definition at line 75 of file tcp.c.

Referenced by wWinMain().

◆ g_tcp_sck

int g_tcp_sck

Definition at line 51 of file uimain.c.

Referenced by check_sck(), mi_create_window(), and ui_select().

◆ g_username

◆ g_width

◆ g_Wnd

HWND g_Wnd = 0
static

Definition at line 39 of file win32.c.

◆ g_wnd_cheight

int g_wnd_cheight = 0
static

Definition at line 50 of file win32.c.

Referenced by handle_WM_SIZE(), and handle_WM_VSCROLL().

◆ g_wnd_clip

RECT g_wnd_clip
static

Definition at line 61 of file win32.c.

◆ g_wnd_cwidth

int g_wnd_cwidth = 0
static

Definition at line 49 of file win32.c.

Referenced by handle_WM_HSCROLL(), and handle_WM_SIZE().

◆ g_workarea

int g_workarea = 0
static

Definition at line 52 of file win32.c.

Referenced by mi_create_window().

◆ g_xoff

int g_xoff = 0
static

Definition at line 43 of file win32.c.

Referenced by handle_WM_SIZING(), mi_clip(), mi_fill_rect(), mi_line(), mi_paint_rect(), and wWinMain().

◆ g_xscroll

◆ g_yoff

int g_yoff = 0
static

Definition at line 44 of file win32.c.

Referenced by handle_WM_SIZING(), mi_clip(), mi_fill_rect(), mi_line(), mi_paint_rect(), and wWinMain().

◆ g_yscroll

◆ pal_entries

int pal_entries[]

Definition at line 52 of file uimain.c.

Referenced by IntAnimatePalette(), mi_fill_rect(), mi_line(), mi_paint_rect(), and ui_create_colourmap().