Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
libvncserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rasky
libvncserver
Commits
d44e3af6
Commit
d44e3af6
authored
Oct 18, 2001
by
dscho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add rfbDrawLine, rfbDrawPixel and vncev, an xev "lookalike"
parent
8e9f427a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
175 additions
and
1 deletion
+175
-1
Makefile
Makefile
+3
-0
TODO
TODO
+1
-0
draw.c
draw.c
+46
-1
main.c
main.c
+3
-0
rfb.h
rfb.h
+3
-0
vncev.c
vncev.c
+119
-0
No files found.
Makefile
View file @
d44e3af6
...
@@ -76,6 +76,9 @@ pnmshow24: pnmshow24.o libvncserver.a
...
@@ -76,6 +76,9 @@ pnmshow24: pnmshow24.o libvncserver.a
fontsel
:
fontsel.o libvncserver.a
fontsel
:
fontsel.o libvncserver.a
$(CC)
-o
fontsel fontsel.o
-L
.
-lvncserver
-lz
-ljpeg
$(CC)
-o
fontsel fontsel.o
-L
.
-lvncserver
-lz
-ljpeg
vncev
:
vncev.o libvncserver.a
$(CC)
-o
vncev vncev.o
-L
.
-lvncserver
-lz
-ljpeg
clean
:
clean
:
rm
-f
$(OBJS)
*
~ core
"#"
*
*
.bak
*
.orig storepasswd.o
\
rm
-f
$(OBJS)
*
~ core
"#"
*
*
.bak
*
.orig storepasswd.o
\
mac.o example.o pnmshow.o pnmshow24.o sratest.o
\
mac.o example.o pnmshow.o pnmshow24.o sratest.o
\
...
...
TODO
View file @
d44e3af6
immediate:
immediate:
----------
----------
in keysym tester mouse buttons make copy rect, but text is not marked as mod.
cursor drawing: set optional grain to mark bigger rectangles as drawn (else
cursor drawing: set optional grain to mark bigger rectangles as drawn (else
you end up with thousands of one-pixel-rectangles to encode).
you end up with thousands of one-pixel-rectangles to encode).
selectbox: scroll bars
selectbox: scroll bars
...
...
draw.c
View file @
d44e3af6
...
@@ -6,7 +6,7 @@ void rfbFillRect(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,Pixel col)
...
@@ -6,7 +6,7 @@ void rfbFillRect(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,Pixel col)
int
i
,
j
;
int
i
,
j
;
char
*
colour
=
(
char
*
)
&
col
;
char
*
colour
=
(
char
*
)
&
col
;
if
(
!
rfbEndianTest
)
if
(
!
rfbEndianTest
)
colour
+=
4
-
bpp
;
colour
+=
4
-
bpp
;
for
(
j
=
y1
;
j
<
y2
;
j
++
)
for
(
j
=
y1
;
j
<
y2
;
j
++
)
for
(
i
=
x1
;
i
<
x2
;
i
++
)
for
(
i
=
x1
;
i
<
x2
;
i
++
)
...
@@ -14,3 +14,48 @@ void rfbFillRect(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,Pixel col)
...
@@ -14,3 +14,48 @@ void rfbFillRect(rfbScreenInfoPtr s,int x1,int y1,int x2,int y2,Pixel col)
rfbMarkRectAsModified
(
s
,
x1
,
y1
,
x2
,
y2
);
rfbMarkRectAsModified
(
s
,
x1
,
y1
,
x2
,
y2
);
}
}
#define SETPIXEL(x,y) \
memcpy(s->frameBuffer+(y)*rowstride+(x)*bpp,colour,bpp)
void
rfbDrawPixel
(
rfbScreenInfoPtr
s
,
int
x
,
int
y
,
Pixel
col
)
{
int
rowstride
=
s
->
paddedWidthInBytes
,
bpp
=
s
->
bitsPerPixel
>>
3
;
char
*
colour
=
(
char
*
)
&
col
;
if
(
!
rfbEndianTest
)
colour
+=
4
-
bpp
;
SETPIXEL
(
x
,
y
);
rfbMarkRectAsModified
(
s
,
x
,
y
,
x
+
1
,
y
+
1
);
}
void
rfbDrawLine
(
rfbScreenInfoPtr
s
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
Pixel
col
)
{
int
rowstride
=
s
->
paddedWidthInBytes
,
bpp
=
s
->
bitsPerPixel
>>
3
;
int
i
;
char
*
colour
=
(
char
*
)
&
col
;
if
(
!
rfbEndianTest
)
colour
+=
4
-
bpp
;
#define SWAPPOINTS { i=x1; x1=x2; x2=i; i=y1; y1=y2; y2=i; }
if
(
abs
(
x1
-
x2
)
<
abs
(
y1
-
y2
))
{
if
(
y1
>
y2
)
SWAPPOINTS
for
(
i
=
y1
;
i
<=
y2
;
i
++
)
SETPIXEL
(
x1
+
(
i
-
y1
)
*
(
x2
-
x1
)
/
(
y2
-
y1
),
i
);
/* TODO: Maybe make this more intelligently? */
if
(
x2
<
x1
)
{
i
=
x1
;
x1
=
x2
;
x2
=
i
;
}
rfbMarkRectAsModified
(
s
,
x1
,
y1
,
x2
+
1
,
y2
+
1
);
}
else
{
if
(
x1
>
x2
)
SWAPPOINTS
else
if
(
x1
==
x2
)
{
rfbDrawPixel
(
s
,
x1
,
y1
,
col
);
return
;
}
for
(
i
=
x1
;
i
<=
x2
;
i
++
)
SETPIXEL
(
i
,
y1
+
(
i
-
x1
)
*
(
y2
-
y1
)
/
(
x2
-
x1
));
if
(
y2
<
y1
)
{
i
=
y1
;
y1
=
y2
;
y2
=
i
;
}
rfbMarkRectAsModified
(
s
,
x1
,
y1
,
x2
+
1
,
y2
+
1
);
}
}
main.c
View file @
d44e3af6
...
@@ -346,6 +346,9 @@ processArguments(rfbScreenInfoPtr rfbScreen,int argc, char *argv[])
...
@@ -346,6 +346,9 @@ processArguments(rfbScreenInfoPtr rfbScreen,int argc, char *argv[])
}
else
if
(
strcmp
(
argv
[
i
],
"-rfbauth"
)
==
0
)
{
/* -rfbauth passwd-file */
}
else
if
(
strcmp
(
argv
[
i
],
"-rfbauth"
)
==
0
)
{
/* -rfbauth passwd-file */
if
(
i
+
1
>=
argc
)
usage
();
if
(
i
+
1
>=
argc
)
usage
();
rfbScreen
->
rfbAuthPasswdData
=
argv
[
++
i
];
rfbScreen
->
rfbAuthPasswdData
=
argv
[
++
i
];
}
else
if
(
strcmp
(
argv
[
i
],
"-deferupdate"
)
==
0
)
{
/* -desktop desktop-name */
if
(
i
+
1
>=
argc
)
usage
();
rfbScreen
->
rfbDeferUpdateTime
=
atoi
(
argv
[
++
i
]);
}
else
if
(
strcmp
(
argv
[
i
],
"-desktop"
)
==
0
)
{
/* -desktop desktop-name */
}
else
if
(
strcmp
(
argv
[
i
],
"-desktop"
)
==
0
)
{
/* -desktop desktop-name */
if
(
i
+
1
>=
argc
)
usage
();
if
(
i
+
1
>=
argc
)
usage
();
rfbScreen
->
desktopName
=
argv
[
++
i
];
rfbScreen
->
desktopName
=
argv
[
++
i
];
...
...
rfb.h
View file @
d44e3af6
...
@@ -702,7 +702,10 @@ void rfbFreeFont(rfbFontDataPtr font);
...
@@ -702,7 +702,10 @@ void rfbFreeFont(rfbFontDataPtr font);
/* draw.c */
/* draw.c */
/* You have to call rfbUndrawCursor before using these functions */
void
rfbFillRect
(
rfbScreenInfoPtr
s
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
Pixel
col
);
void
rfbFillRect
(
rfbScreenInfoPtr
s
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
Pixel
col
);
void
rfbDrawPixel
(
rfbScreenInfoPtr
s
,
int
x
,
int
y
,
Pixel
col
);
void
rfbDrawLine
(
rfbScreenInfoPtr
s
,
int
x1
,
int
y1
,
int
x2
,
int
y2
,
Pixel
col
);
/* selbox.c */
/* selbox.c */
...
...
vncev.c
0 → 100644
View file @
d44e3af6
/* This program is a simple server to show events coming from the client */
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include "rfb.h"
#include "default8x16.h"
char
f
[
640
*
480
];
char
*
keys
[
0x400
];
int
hex2number
(
unsigned
char
c
)
{
if
(
c
>
'f'
)
return
(
-
1
);
else
if
(
c
>
'F'
)
return
(
10
+
c
-
'a'
);
else
if
(
c
>
'9'
)
return
(
10
+
c
-
'A'
);
else
return
(
c
-
'0'
);
}
void
read_keys
()
{
int
i
,
j
,
k
;
char
buffer
[
1024
];
FILE
*
keysyms
=
fopen
(
"keysym.h"
,
"r"
);
memset
(
keys
,
0
,
0x400
*
sizeof
(
char
*
));
if
(
!
keysyms
)
return
;
while
(
!
feof
(
keysyms
))
{
fgets
(
buffer
,
1024
,
keysyms
);
if
(
!
strncmp
(
buffer
,
"#define XK_"
,
strlen
(
"#define XK_"
)))
{
for
(
i
=
strlen
(
"#define XK_"
);
buffer
[
i
]
&&
buffer
[
i
]
!=
' '
&&
buffer
[
i
]
!=
'\t'
;
i
++
);
if
(
buffer
[
i
]
==
0
)
/* don't support wrapped lines */
continue
;
buffer
[
i
]
=
0
;
for
(
i
++
;
buffer
[
i
]
&&
buffer
[
i
]
!=
'0'
;
i
++
);
if
(
buffer
[
i
]
==
0
||
buffer
[
i
+
1
]
!=
'x'
)
continue
;
for
(
j
=
0
,
i
+=
2
;(
k
=
hex2number
(
buffer
[
i
]))
>=
0
;
i
++
)
j
=
j
*
16
+
k
;
if
(
keys
[
j
&
0x3ff
])
{
char
*
x
=
malloc
(
1
+
strlen
(
keys
[
j
&
0x3ff
])
+
1
+
strlen
(
buffer
+
strlen
(
"#define "
)));
strcpy
(
x
,
keys
[
j
&
0x3ff
]);
strcat
(
x
,
","
);
strcat
(
x
,
buffer
+
strlen
(
"#define "
));
free
(
keys
[
j
&
0x3ff
]);
keys
[
j
&
0x3ff
]
=
x
;
}
else
keys
[
j
&
0x3ff
]
=
strdup
(
buffer
+
strlen
(
"#define "
));
}
}
fclose
(
keysyms
);
}
int
lineHeight
=
16
,
lineY
=
480
-
16
;
void
output
(
rfbScreenInfoPtr
s
,
char
*
line
)
{
rfbDoCopyRect
(
s
,
0
,
0
,
640
,
480
-
lineHeight
,
0
,
-
lineHeight
);
rfbDrawString
(
s
,
&
default8x16Font
,
10
,
lineY
,
line
,
0x01
);
fprintf
(
stderr
,
"%s
\n
"
,
line
);
}
void
dokey
(
Bool
down
,
KeySym
k
,
rfbClientPtr
cl
)
{
char
buffer
[
1024
];
sprintf
(
buffer
,
"%s: %s (0x%x)"
,
down
?
"down"
:
"up"
,
keys
[
k
&
0x3ff
]
?
keys
[
k
&
0x3ff
]
:
""
,
k
);
output
(
cl
->
screen
,
buffer
);
}
void
doptr
(
int
buttonMask
,
int
x
,
int
y
,
rfbClientPtr
cl
)
{
char
buffer
[
1024
];
if
(
buttonMask
)
{
sprintf
(
buffer
,
"Ptr: mouse button mask 0x%x at %d,%d"
,
buttonMask
,
x
,
y
);
output
(
cl
->
screen
,
buffer
);
}
}
void
newclient
(
rfbClientPtr
cl
)
{
char
buffer
[
1024
];
struct
sockaddr_in
addr
;
int
len
=
sizeof
(
addr
),
ip
;
getpeername
(
cl
->
sock
,
&
addr
,
&
len
);
ip
=
ntohl
(
addr
.
sin_addr
.
s_addr
);
sprintf
(
buffer
,
"Client connected from ip %d.%d.%d.%d"
,
(
ip
>>
24
)
&
0xff
,(
ip
>>
16
)
&
0xff
,(
ip
>>
8
)
&
0xff
,
ip
&
0xff
);
output
(
cl
->
screen
,
buffer
);
}
int
main
(
int
argc
,
char
**
argv
)
{
rfbScreenInfoPtr
s
=
rfbGetScreen
(
argc
,
argv
,
640
,
480
,
8
,
1
,
1
);
s
->
colourMap
.
is16
=
FALSE
;
s
->
colourMap
.
count
=
2
;
s
->
colourMap
.
data
.
bytes
=
"
\xd0\xd0\xd0\x30\x01\xe0
"
;
s
->
rfbServerFormat
.
trueColour
=
FALSE
;
s
->
frameBuffer
=
f
;
s
->
kbdAddEvent
=
dokey
;
s
->
ptrAddEvent
=
doptr
;
s
->
newClientHook
=
newclient
;
memset
(
f
,
0
,
640
*
480
);
read_keys
();
rfbInitServer
(
s
);
while
(
1
)
{
rfbProcessEvents
(
s
,
999999
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment