VNC viewer: Fixed problem with redraw, corrected mouse coordinates, preliminary keyboard support, GUI fixes.

git-svn-id: svn://kolibrios.org@5670 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2015-08-04 08:59:09 +00:00
parent cd42aa37be
commit 37f9a5a160
4 changed files with 85 additions and 38 deletions

View File

@ -14,7 +14,7 @@
encoding_CopyRect: encoding_CopyRect:
DEBUGF 1,"CopyRect\n" DEBUGF 2,"CopyRect\n"
@@: @@:
lea eax, [esi+4] lea eax, [esi+4]

View File

@ -25,10 +25,10 @@ draw_gui:
mov edi, name ; WINDOW LABEL mov edi, name ; WINDOW LABEL
mcall mcall
cmp [status], STATUS_INITIAL cmp [status], STATUS_CONNECTING
jne @f ja @f
mov ebx, 25 shl 16 + 15 mov ebx, 25 shl 16 + 14
xor ecx, ecx xor ecx, ecx
mov edx, serverstr mov edx, serverstr
mov esi, userstr-serverstr mov esi, userstr-serverstr
@ -36,13 +36,16 @@ draw_gui:
invoke edit_box_draw, URLbox ; Server textbox invoke edit_box_draw, URLbox ; Server textbox
cmp [status], STATUS_INITIAL
jne .redraw_done
mov ebx, 220 shl 16 + 85 mov ebx, 220 shl 16 + 85
mov ecx, 47 shl 16 + 16 mov ecx, 47 shl 16 + 16
mov edx, 2 mov edx, 2
mov esi, 0xCCCCCC mov esi, 0xCCCCCC
mcall 8 ; Connect button mcall 8 ; Connect button
mov ebx, 240 shl 16 + 49 mov ebx, 240 shl 16 + 52
mov edx, connectstr mov edx, connectstr
mov esi, loginstr-connectstr mov esi, loginstr-connectstr
mcall 4 ; Connect button text mcall 4 ; Connect button text
@ -51,19 +54,25 @@ draw_gui:
@@: @@:
cmp [status], STATUS_LOGIN cmp [status], STATUS_LOGIN
jne @f ja @f
mov ebx, 25 shl 16 + 15 mov ebx, 25 shl 16 + 14
xor ecx, ecx xor ecx, ecx
mov edx, userstr mov edx, userstr
mov esi, passstr-userstr mov esi, passstr-userstr
mcall 4 ; "user" text mcall 4 ; "user" text
add bl, 19 add bl, 20
mov edx, passstr mov edx, passstr
mov esi, connectstr-passstr ; "password" text mov esi, connectstr-passstr ; "password" text
mcall mcall
invoke edit_box_draw, USERbox ; username textbox
invoke edit_box_draw, PASSbox ; password textbox
cmp [status], STATUS_REQ_LOGIN
jne .redraw_done
mov ebx, 220 shl 16 + 85 mov ebx, 220 shl 16 + 85
mov ecx, 47 shl 16 + 16 mov ecx, 47 shl 16 + 16
mov edx, 3 mov edx, 3
@ -78,6 +87,9 @@ draw_gui:
jmp .redraw_done jmp .redraw_done
@@: @@:
cmp [status], STATUS_DISCONNECTED
jb .redraw_done
mov ebx, 25 shl 16 + 15 mov ebx, 25 shl 16 + 15
mov ecx, 0x80ca0000 ; red ASCIIZ string mov ecx, 0x80ca0000 ; red ASCIIZ string
mov edx, [status] mov edx, [status]
@ -119,6 +131,13 @@ draw_gui:
cmp ah, 13 ; enter (return) key cmp ah, 13 ; enter (return) key
je .connect je .connect
invoke edit_box_key, URLbox invoke edit_box_key, URLbox
@@:
cmp [status], STATUS_REQ_LOGIN
jne .loop
cmp ah, 13 ; enter (return) key
je .login
invoke edit_box_key, USERbox
invoke edit_box_key, PASSbox
@@: @@:
jmp .loop jmp .loop
@ -138,24 +157,33 @@ draw_gui:
mov eax, [URLbox.pos] mov eax, [URLbox.pos]
mov byte[serveraddr+eax], 0 mov byte[serveraddr+eax], 0
mov [status], STATUS_CONNECTING
inc [update_gui]
; Create network thread ; Create network thread
mcall 51, 1, thread_start, thread_stack mcall 51, 1, thread_start, thread_stack
cmp eax, -1 cmp eax, -1
jne @f jne @f
mov [status], STATUS_THREAD_ERR mov [status], STATUS_THREAD_ERR
inc [update_gui] ; inc [update_gui]
@@: @@:
jmp .loop jmp .loop
.login: .login:
;;; mov [status], STATUS_LOGIN
ret inc [update_gui]
jmp .loop
.mouse: .mouse:
mcall 23 mcall 23
cmp [status], STATUS_INITIAL cmp [status], STATUS_INITIAL
jne @f jne @f
invoke edit_box_mouse, URLbox invoke edit_box_mouse, URLbox
@@:
cmp [status], STATUS_REQ_LOGIN
jne @f
invoke edit_box_mouse, USERbox
invoke edit_box_mouse, PASSbox
@@: @@:
jmp .loop jmp .loop

View File

@ -127,7 +127,7 @@ thread_loop:
je servercuttext je servercuttext
DEBUGF 1, "Unknown server command: %u\n", al DEBUGF 2, "Unknown server command: %u\n", al
jmp thread_loop jmp thread_loop
framebufferupdate: framebufferupdate:
@ -187,14 +187,11 @@ rectangle_loop:
; cmp eax, 16 ; cmp eax, 16
; je encoding_ZRLE ; je encoding_ZRLE
DEBUGF 1, "\nunknown encoding: %u\n", eax DEBUGF 2, "unknown encoding: %u\n", eax
jmp thread_loop jmp thread_loop
next_rectangle: next_rectangle:
push esi inc [update_framebuffer]
call drawbuffer
pop esi
dec [rectangles] dec [rectangles]
jnz rectangle_loop jnz rectangle_loop
jmp request_fbu jmp request_fbu

View File

@ -15,7 +15,7 @@
format binary as "" format binary as ""
__DEBUG__ = 1 __DEBUG__ = 1
__DEBUG_LEVEL__ = 1 __DEBUG_LEVEL__ = 2
use32 use32
@ -60,7 +60,7 @@ struct framebuffer
ends ends
xpos = 4 xpos = 4
ypos = 22 ypos = 21
TIMEOUT = 5 ; timeout in seconds TIMEOUT = 5 ; timeout in seconds
@ -68,8 +68,9 @@ RECEIVE_BUFFER_SIZE = 8*1024*1024 ; 8 Mib
STATUS_INITIAL = 0 STATUS_INITIAL = 0
STATUS_CONNECTING = 1 STATUS_CONNECTING = 1
STATUS_LOGIN = 2 STATUS_REQ_LOGIN = 2
STATUS_CONNECTED = 3 STATUS_LOGIN = 3
STATUS_CONNECTED = 4
STATUS_DISCONNECTED = 10 STATUS_DISCONNECTED = 10
STATUS_DNS_ERR = 11 STATUS_DNS_ERR = 11
@ -112,6 +113,9 @@ START:
mcall 40, EVM_MOUSE + EVM_MOUSE_FILTER + EVM_KEY + EVM_REDRAW + EVM_BUTTON mcall 40, EVM_MOUSE + EVM_MOUSE_FILTER + EVM_KEY + EVM_REDRAW + EVM_BUTTON
mcall 66, 1, 1 ; Switch keyboard to scancode mode
mcall 26, 2, 1, keymap ; Read keymap
redraw: redraw:
mcall 12, 1 mcall 12, 1
@ -122,15 +126,19 @@ redraw:
mov edi, name mov edi, name
mcall 0 ; draw window mcall 0 ; draw window
call drawbuffer
mcall 12, 2 mcall 12, 2
draw_framebuffer:
mcall 7, framebuffer_data, dword[screen], 0
mov [update_framebuffer], 0
mainloop: mainloop:
cmp [status], STATUS_CONNECTED cmp [status], STATUS_CONNECTED
jne draw_gui jne draw_gui
cmp [update_framebuffer], 0
jne draw_framebuffer
mcall 23, 100 ; Check for event with 1s timeout mcall 23, 10 ; Check for event with 0,1s timeout
dec eax dec eax
jz redraw jz redraw
@ -142,15 +150,24 @@ mainloop:
jz mouse jz mouse
jmp mainloop jmp mainloop
drawbuffer:
mcall 7, framebuffer_data, dword[screen], 0
ret
key: key:
; DEBUGF 1, "Sending key event\n"
mcall 2 mcall 2
mov byte[KeyEvent.key+3], ah cmp ah, 224 ; ext
je mainloop ;; TODO
xor al, al
test ah, 0x80 ; key up?
jnz @f
inc al
@@:
mov byte[KeyEvent.down], al
shr eax, 8
and al, 0x7f
mov al, [keymap+eax]
mov byte[KeyEvent.key+3], al
DEBUGF 1, "Sending key: 0x%x\n", al
mcall send, [socketnum], KeyEvent, 8, 0 mcall send, [socketnum], KeyEvent, 8, 0
jmp mainloop jmp mainloop
@ -159,7 +176,6 @@ mouse:
; DEBUGF 1, "Sending mouse event\n" ; DEBUGF 1, "Sending mouse event\n"
mcall 37, 1 ; get mouse pos mcall 37, 1 ; get mouse pos
sub eax, xpos shl 16 + ypos
bswap eax bswap eax
mov [PointerEvent.x], ax mov [PointerEvent.x], ax
shr eax, 16 shr eax, 16
@ -266,17 +282,20 @@ sockaddr1:
beep db 0x85, 0x25, 0x85, 0x40, 0 beep db 0x85, 0x25, 0x85, 0x40, 0
status dd STATUS_INITIAL status dd STATUS_INITIAL
update_gui dd 0 update_gui dd 0
mouse_dd dd 0 mouse_dd dd 0
update_framebuffer dd 0
URLbox edit_box 200, 25, 16, 0xffffff, 0x6f9480, 0, 0, 0, 65535, serveraddr, mouse_dd, ed_focus, 0, 0 URLbox edit_box 235, 70, 10, 0xffffff, 0x6f9480, 0, 0, 0, 65535, serveraddr, mouse_dd, ed_focus, 0, 0
USERbox edit_box 150, 70, 10, 0xffffff, 0x6f9480, 0, 0, 0, 127, username, mouse_dd, ed_focus, 0, 0
PASSbox edit_box 150, 90, 10, 0xffffff, 0x6f9480, 0, 0, 0, 127, password, mouse_dd, 0, 0, 0
serverstr db "server:" serverstr db "server:"
userstr db "username:" userstr db "username:"
passstr db "password:" passstr db "password:"
connectstr db "connect" connectstr db "Connect"
loginstr db "login" loginstr db "Log in"
loginstr_e: loginstr_e:
sz_err_disconnected db "Server closed connection unexpectedly.", 0 sz_err_disconnected db "Server closed connection unexpectedly.", 0
@ -352,6 +371,9 @@ screen: ; Remote screen resolution
.height dw ? .height dw ?
.width dw ? .width dw ?
keymap rb 128
username rb 128
password rb 128
serveraddr rb 65536 serveraddr rb 65536
receive_buffer rb RECEIVE_BUFFER_SIZE receive_buffer rb RECEIVE_BUFFER_SIZE
framebuffer_data rb 1024*1024*3 ; framebuffer framebuffer_data rb 1024*1024*3 ; framebuffer