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
5c438e3f
Commit
5c438e3f
authored
Sep 24, 2001
by
dscho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bugfix: cursor (works now without xcursor encoding)
parent
fa85c12a
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
126 additions
and
181 deletions
+126
-181
Makefile
Makefile
+2
-1
TODO
TODO
+4
-2
cursor.c
cursor.c
+1
-145
example.c
example.c
+7
-5
os.h
include/Xserver/os.h
+2
-2
main.c
main.c
+3
-0
miregion.c
miregion.c
+11
-4
pnmshow.c
pnmshow.c
+12
-5
rfb.h
rfb.h
+71
-7
rfbserver.c
rfbserver.c
+6
-5
sockets.c
sockets.c
+2
-0
xalloc.c
xalloc.c
+5
-5
No files found.
Makefile
View file @
5c438e3f
...
...
@@ -3,7 +3,8 @@ CFLAGS=-g -Wall
#CFLAGS=-O2 -Wall
RANLIB
=
ranlib
INCLUDES
=
-I
.
-Ilibvncauth
-Iinclude
-Iinclude
/X11
-Iinclude
/Xserver
INCLUDES
=
-I
.
-Ilibvncauth
-Iinclude
# -Iinclude/X11 -Iinclude/Xserver
VNCAUTHLIB
=
-Llibvncauth
-lvncauth
VNCSERVERLIB
=
-L
.
-lvncserver
-lz
-ljpeg
...
...
TODO
View file @
5c438e3f
dont draw rich cursors as xcursors
test drawing of cursors when not using xcursor or rich cursor encoding
fix bug with odd width
adapt rdp2vnc (rdesktop)
dont draw rich cursors as xcursors
udp
rfbCloseClient, rfbConnect, ConnectToTcpAddr
CORBA
translate.c: warning about non 8-bit colourmaps
set colourmap
done:
...
...
@@ -12,4 +13,5 @@ done:
.cutpaste
.httpd
.other encodings
.test drawing of cursors when not using xcursor or rich cursor encoding
cursor.c
View file @
5c438e3f
...
...
@@ -69,14 +69,6 @@ static unsigned char _reverse_byte[0x100] = {
};
static
int
EncodeRichCursorData8
(
rfbClientPtr
cl
,
char
*
buf
,
rfbPixelFormat
*
fmt
,
rfbCursorPtr
pCursor
);
static
int
EncodeRichCursorData16
(
rfbClientPtr
cl
,
char
*
buf
,
rfbPixelFormat
*
fmt
,
rfbCursorPtr
pCursor
);
static
int
EncodeRichCursorData32
(
rfbClientPtr
cl
,
char
*
buf
,
rfbPixelFormat
*
fmt
,
rfbCursorPtr
pCursor
);
/*
* Send cursor shape either in X-style format or in client pixel format.
*/
...
...
@@ -209,24 +201,6 @@ rfbSendCursorShape(cl)
pCursor
->
width
*
bpp1
,
pCursor
->
width
,
pCursor
->
height
);
cl
->
ublen
+=
pCursor
->
width
*
bpp2
*
pCursor
->
height
;
/*
switch (cl->format.bitsPerPixel) {
case 8:
cl->ublen += EncodeRichCursorData8(cl, &cl->updateBuf[cl->ublen],
&cl->format, pCursor);
break;
case 16:
cl->ublen += EncodeRichCursorData16(cl, &cl->updateBuf[cl->ublen],
&cl->format, pCursor);
break;
case 32:
cl->ublen += EncodeRichCursorData32(cl, &cl->updateBuf[cl->ublen],
&cl->format, pCursor);
break;
default:
return FALSE;
}
*/
}
/* Prepare transparency mask. */
...
...
@@ -254,123 +228,7 @@ rfbSendCursorShape(cl)
return
TRUE
;
}
/*
* Code to convert cursor source bitmap to the desired pixel format.
*/
#define RGB48_TO_PIXEL(fmt,r,g,b) \
(((CARD32)(r) * ((fmt)->redMax + 1) >> 16) << (fmt)->redShift | \
((CARD32)(g) * ((fmt)->greenMax + 1) >> 16) << (fmt)->greenShift | \
((CARD32)(b) * ((fmt)->blueMax + 1) >> 16) << (fmt)->blueShift)
static
int
EncodeRichCursorData8
(
cl
,
buf
,
fmt
,
pCursor
)
rfbClientPtr
cl
;
char
*
buf
;
rfbPixelFormat
*
fmt
;
rfbCursorPtr
pCursor
;
{
int
widthPixels
,
widthBytes
;
int
x
,
y
,
b
;
CARD8
*
src
;
char
pix
[
2
];
CARD8
bitmapByte
;
pix
[
0
]
=
(
char
)
RGB48_TO_PIXEL
(
fmt
,
pCursor
->
backRed
,
pCursor
->
backGreen
,
pCursor
->
backBlue
);
pix
[
1
]
=
(
char
)
RGB48_TO_PIXEL
(
fmt
,
pCursor
->
foreRed
,
pCursor
->
foreGreen
,
pCursor
->
foreBlue
);
src
=
(
CARD8
*
)
pCursor
->
richSource
;
widthPixels
=
pCursor
->
width
;
widthBytes
=
widthPixels
;
for
(
y
=
0
;
y
<
pCursor
->
height
;
y
++
)
{
for
(
x
=
0
;
x
<
widthPixels
/
8
;
x
++
)
{
bitmapByte
=
src
[
y
*
widthBytes
+
x
];
/*if (screenInfo.bitmapBitOrder == LSBFirst) {
bitmapByte = _reverse_byte[bitmapByte];
}*/
for
(
b
=
7
;
b
>=
0
;
b
--
)
{
*
buf
++
=
pix
[
bitmapByte
>>
b
&
1
];
}
}
if
(
widthPixels
%
8
)
{
bitmapByte
=
src
[
y
*
widthBytes
+
x
];
/*if (screenInfo.bitmapBitOrder == LSBFirst) {
bitmapByte = _reverse_byte[bitmapByte];
}*/
for
(
b
=
7
;
b
>
7
-
widthPixels
%
8
;
b
--
)
{
*
buf
++
=
pix
[
bitmapByte
>>
b
&
1
];
}
}
}
return
(
widthPixels
*
pCursor
->
height
);
}
#define DEFINE_RICH_ENCODE(bpp) \
\
static int \
EncodeRichCursorData##bpp(cl, buf, fmt, pCursor) \
rfbClientPtr cl; \
char *buf; \
rfbPixelFormat *fmt; \
rfbCursorPtr pCursor; \
{ \
int widthPixels, widthBytes; \
int x, y, b; \
CARD8 *src; \
CARD##bpp pix[2]; \
CARD8 bitmapByte; \
\
pix[0] = (CARD##bpp)RGB48_TO_PIXEL(fmt, pCursor->backRed, \
pCursor->backGreen, \
pCursor->backBlue); \
pix[1] = (CARD##bpp)RGB48_TO_PIXEL(fmt, pCursor->foreRed, \
pCursor->foreGreen, \
pCursor->foreBlue); \
if (!cl->screen->rfbServerFormat.bigEndian != !fmt->bigEndian) { \
pix[0] = Swap##bpp(pix[0]); \
pix[1] = Swap##bpp(pix[1]); \
} \
\
src = (CARD8 *)pCursor->richSource; \
widthPixels = pCursor->width; \
widthBytes = (pCursor->width*bpp)/8; \
\
for (y = 0; y < pCursor->height; y++) { \
for (x = 0; x < widthPixels / 8; x++) { \
bitmapByte = src[y * widthBytes + x]; \
/*if (screenInfo.bitmapBitOrder == LSBFirst) { \
bitmapByte = _reverse_byte[bitmapByte]; \
}*/
\
for (b = 7; b >= 0; b--) { \
memcpy (buf, (char *)&pix[bitmapByte >> b & 1], \
sizeof(CARD##bpp)); \
buf += sizeof(CARD##bpp); \
} \
} \
if (widthPixels % 8) { \
bitmapByte = src[y * widthBytes + x]; \
/*if (cl->screen.bitmapBitOrder == LSBFirst) { \
bitmapByte = _reverse_byte[bitmapByte]; \
}*/
\
for (b = 7; b > 7 - widthPixels % 8; b--) { \
memcpy (buf, (char *)&pix[bitmapByte >> b & 1], \
sizeof(CARD##bpp)); \
buf += sizeof(CARD##bpp); \
} \
} \
} \
\
return (widthPixels * pCursor->height * (bpp / 8)); \
}
DEFINE_RICH_ENCODE
(
16
)
DEFINE_RICH_ENCODE
(
32
)
/* if you have a cursor in LSB order you have to convert it */
void
rfbConvertLSBCursorBitmapOrMask
(
int
width
,
int
height
,
unsigned
char
*
bitmap
)
{
int
i
,
t
=
(
width
+
7
)
/
8
*
height
;
...
...
@@ -495,7 +353,6 @@ void rfbUndrawCursor(rfbClientPtr cl)
rfbCursorPtr
c
=
s
->
cursor
;
int
j
,
x1
,
x2
,
y1
,
y2
,
bpp
=
s
->
rfbServerFormat
.
bitsPerPixel
/
8
,
rowstride
=
s
->
paddedWidthInBytes
;
return
;
if
(
!
s
->
cursorIsDrawn
)
return
;
/* restore what is under the cursor */
...
...
@@ -525,7 +382,6 @@ void rfbDrawCursor(rfbClientPtr cl)
int
i
,
j
,
x1
,
x2
,
y1
,
y2
,
i1
,
j1
,
bpp
=
s
->
rfbServerFormat
.
bitsPerPixel
/
8
,
rowstride
=
s
->
paddedWidthInBytes
,
bufSize
=
c
->
width
*
c
->
height
*
bpp
,
w
=
(
c
->
width
+
7
)
/
8
;
return
;
if
(
s
->
cursorIsDrawn
)
rfbUndrawCursor
(
cl
);
if
(
s
->
underCursorBufferLen
<
bufSize
)
{
...
...
example.c
View file @
5c438e3f
...
...
@@ -28,9 +28,10 @@
#endif
#define XK_MISCELLANY
#include "rfb.h"
#include "keysym
def
.h"
#include "keysym.h"
const
int
maxx
=
640
,
maxy
=
480
,
bpp
=
4
;
/* TODO: odd maxx doesn't work */
/* This initializes a nice (?) background */
...
...
@@ -94,10 +95,10 @@ void drawline(unsigned char* buffer,int rowstride,int bpp,int x1,int y1,int x2,i
void
doptr
(
int
buttonMask
,
int
x
,
int
y
,
rfbClientPtr
cl
)
{
ClientData
*
cd
=
cl
->
clientData
;
//
if(cl->screen->cursorIsDrawn)
//
rfbUndrawCursor(cl);
//
cl->screen->cursorX=x;
//
cl->screen->cursorY=y;
if
(
cl
->
screen
->
cursorIsDrawn
)
rfbUndrawCursor
(
cl
);
cl
->
screen
->
cursorX
=
x
;
cl
->
screen
->
cursorY
=
y
;
if
(
x
>=
0
&&
y
>=
0
&&
x
<
maxx
&&
y
<
maxy
)
{
if
(
buttonMask
)
{
int
i
,
j
,
x1
,
x2
,
y1
,
y2
;
...
...
@@ -252,6 +253,7 @@ int main(int argc,char** argv)
rfbCursorPtr
c
=
rfbScreen
->
cursor
;
char
x
[
32
*
32
],
mask
[
32
*
32
/
8
];
c
=
rfbScreen
->
cursor
=
rfbMakeXCursor
(
w
,
h
,
x
,
mask
);
c
->
xhot
=
2
;
c
->
yhot
=
10
;
c
->
mask
[
0
]
=
0xff
;
c
->
mask
[
1
]
=
0x0
;
memset
(
c
->
mask
,
255
,
h
*
w
/
8
);
c
->
richSource
=
malloc
(
w
*
h
*
bpp
);
...
...
include/Xserver/os.h
View file @
5c438e3f
...
...
@@ -51,10 +51,10 @@ SOFTWARE.
#ifndef OS_H
#define OS_H
#include "misc.h"
#include "
Xserver/
misc.h"
#define ALLOCATE_LOCAL_FALLBACK(_size) Xalloc((unsigned long)(_size))
#define DEALLOCATE_LOCAL_FALLBACK(_ptr) Xfree((pointer)(_ptr))
#include "Xalloca.h"
#include "X
11/X
alloca.h"
#define NullFID ((FID) 0)
...
...
main.c
View file @
5c438e3f
...
...
@@ -40,6 +40,7 @@
#include <time.h>
#include "rfb.h"
#include "region.h"
#ifdef HAVE_PTHREADS
pthread_mutex_t
logMutex
;
...
...
@@ -408,6 +409,7 @@ rfbScreenInfoPtr rfbDefaultScreenInit(int argc,char** argv,int width,int height,
X11 ScreenPtr, so we do this. Pretty ugly, but at least it lets us
avoid hacking up regionstr.h, or changing every call to REGION_*
(which actually I should probably do eventually). */
/*
rfbScreen->screen.RegionCreate = miRegionCreate;
rfbScreen->screen.RegionInit = miRegionInit;
rfbScreen->screen.RegionCopy = miRegionCopy;
...
...
@@ -426,6 +428,7 @@ rfbScreenInfoPtr rfbDefaultScreenInit(int argc,char** argv,int width,int height,
rfbScreen->screen.RegionExtents = miRegionExtents;
rfbScreen->screen.RegionAppend = miRegionAppend;
rfbScreen->screen.RegionValidate = miRegionValidate;
*/
rfbScreen
->
kbdAddEvent
=
defaultKbdAddEvent
;
rfbScreen
->
kbdReleaseAllKeys
=
doNothingWithClient
;
...
...
miregion.c
View file @
5c438e3f
...
...
@@ -50,10 +50,10 @@ SOFTWARE.
#include <stdio.h>
#include <stdlib.h>
#include "miscstruct.h"
#include "regionstr.h"
#include "Xprotostr.h"
#include "gc.h"
#include "
Xserver/
miscstruct.h"
#include "
Xserver/
regionstr.h"
#include "X
11/X
protostr.h"
#include "
Xserver/
gc.h"
#if defined (__GNUC__) && !defined (NO_INLINES)
#define INLINE __inline
...
...
@@ -61,6 +61,13 @@ SOFTWARE.
#define INLINE
#endif
#undef xalloc
#undef xrealloc
#undef xfree
#define xalloc malloc
#define xrealloc realloc
#define xfree free
/*
* hack until callers of these functions can deal with out-of-memory
*/
...
...
pnmshow.c
View file @
5c438e3f
#include <stdio.h>
#include "rfb.h"
#define XK_MISCELLANY
#include "keysymdef.h"
#include "keysym.h"
void
HandleKey
(
Bool
down
,
KeySym
key
,
rfbClientPtr
cl
)
{
...
...
@@ -52,12 +51,20 @@ int main(int argc,char** argv)
/* allocate picture and read it */
rfbScreen
->
frameBuffer
=
(
char
*
)
malloc
(
width
*
height
*
4
);
fread
(
rfbScreen
->
frameBuffer
,
width
*
3
,
height
,
in
);
fclose
(
in
);
/* correct the format to 4 bytes instead of 3 */
for
(
i
=
width
*
height
-
1
;
i
>=
0
;
i
--
)
{
rfbScreen
->
frameBuffer
[
i
*
4
+
3
]
=
rfbScreen
->
frameBuffer
[
i
*
3
+
2
];
rfbScreen
->
frameBuffer
[
i
*
4
+
2
]
=
rfbScreen
->
frameBuffer
[
i
*
3
+
1
];
rfbScreen
->
frameBuffer
[
i
*
4
+
1
]
=
rfbScreen
->
frameBuffer
[
i
*
3
+
0
];
rfbScreen
->
frameBuffer
[
i
*
4
+
2
]
=
rfbScreen
->
frameBuffer
[
i
*
3
+
0
];
rfbScreen
->
frameBuffer
[
i
*
4
+
1
]
=
rfbScreen
->
frameBuffer
[
i
*
3
+
1
];
rfbScreen
->
frameBuffer
[
i
*
4
+
0
]
=
rfbScreen
->
frameBuffer
[
i
*
3
+
2
];
}
for
(
i
=
0
;
i
<
200
;
i
++
)
{
rfbScreen
->
frameBuffer
[
i
*
4
+
i
*
width
*
4
]
=
0
;
rfbScreen
->
frameBuffer
[
i
*
4
+
i
*
width
*
4
+
1
]
=
0
;
rfbScreen
->
frameBuffer
[
i
*
4
+
i
*
width
*
4
+
2
]
=
0
;
rfbScreen
->
frameBuffer
[
i
*
4
+
i
*
width
*
4
+
3
]
=
0
;
}
/* run event loop */
...
...
rfb.h
View file @
5c438e3f
...
...
@@ -25,12 +25,69 @@
#include <stdlib.h>
#include <string.h>
#include "scrnintstr.h"
//
#include "scrnintstr.h"
/* trying to replace the above with some more minimal set of includes */
#include "misc.h"
#include "Xmd.h"
#include "regionstr.h"
//#include "misc.h"
//#include "Xmd.h"
/* TODO: this stuff has to go into autoconf */
typedef
unsigned
char
CARD8
;
typedef
unsigned
short
CARD16
;
typedef
unsigned
int
CARD32
;
typedef
CARD32
Pixel
;
typedef
CARD32
KeySym
;
typedef
signed
char
Bool
;
#define FALSE 0
#define TRUE -1
#include "keysym.h"
/* region stuff */
#define NullRegion ((RegionPtr)0)
#define NullBox ((BoxPtr)0)
typedef
struct
_Box
{
short
x1
,
y1
,
x2
,
y2
;
}
BoxRec
,
*
BoxPtr
;
typedef
struct
_RegData
{
long
size
;
long
numRects
;
/* BoxRec rects[size]; in memory but not explicitly declared */
}
RegDataRec
,
*
RegDataPtr
;
typedef
struct
_Region
{
BoxRec
extents
;
RegDataPtr
data
;
}
RegionRec
,
*
RegionPtr
;
#define REGION_NIL(reg) ((reg)->data && !(reg)->data->numRects)
#define REGION_NUM_RECTS(reg) ((reg)->data ? (reg)->data->numRects : 1)
#define REGION_SIZE(reg) ((reg)->data ? (reg)->data->size : 0)
#define REGION_RECTS(reg) ((reg)->data ? (BoxPtr)((reg)->data + 1) \
: &(reg)->extents)
#define REGION_BOXPTR(reg) ((BoxPtr)((reg)->data + 1))
#define REGION_BOX(reg,i) (®ION_BOXPTR(reg)[i])
#define REGION_TOP(reg) REGION_BOX(reg, (reg)->data->numRects)
#define REGION_END(reg) REGION_BOX(reg, (reg)->data->numRects - 1)
#define REGION_SZOF(n) (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)))
#define REGION_INIT(s,pReg,rect,size) miRegionInit(pReg,rect,size)
#define REGION_EMPTY(s,pReg) miRegionEmpty(pReg)
#define REGION_UNINIT(s,pReg) miRegionUninit(pReg)
#define REGION_NOTEMPTY(s,pReg) miRegionNotEmpty(pReg)
#define REGION_INTERSECT(s,newReg,reg1,reg2) miIntersect(newReg,reg1,reg2)
#define REGION_SUBTRACT(s,newReg,reg1,reg2) miSubtract(newReg,reg1,reg2)
#define REGION_UNION(s,newReg,reg1,reg2) miUnion(newReg,reg1,reg2)
#define REGION_TRANSLATE(s,pReg,x,y) miTranslateRegion(pReg,x,y)
//#include "regionstr.h"
#define xalloc malloc
#define xrealloc realloc
#define xfree free
int
max
(
int
,
int
);
#include <zlib.h>
#include <rfbproto.h>
...
...
@@ -61,6 +118,7 @@
#define IF_PTHREADS(x)
#endif
struct
rfbClientRec
;
struct
rfbScreenInfo
;
struct
rfbCursor
;
...
...
@@ -136,6 +194,7 @@ typedef struct
/* wrapped screen functions */
/*
CloseScreenProcPtr CloseScreen;
CreateGCProcPtr CreateGC;
PaintWindowBackgroundProcPtr PaintWindowBackground;
...
...
@@ -143,10 +202,13 @@ typedef struct
CopyWindowProcPtr CopyWindow;
ClearToBackgroundProcPtr ClearToBackground;
RestoreAreasProcPtr RestoreAreas;
*/
/* additions by libvncserver */
/*
ScreenRec screen;
*/
rfbPixelFormat
rfbServerFormat
;
char
*
desktopName
;
char
rfbThisHost
[
255
];
...
...
@@ -287,8 +349,10 @@ typedef struct rfbClientRec {
milliseconds so that several changes to the framebuffer can be combined
into a single update. */
Bool
deferredUpdateScheduled
;
OsTimerPtr
deferredUpdateTimer
;
/* no deferred timer here; server has to do it alone */
/* Bool deferredUpdateScheduled;
OsTimerPtr deferredUpdateTimer; */
/* translateFn points to the translation function which is used to copy
and translate a rectangle from the framebuffer to an output buffer. */
...
...
rfbserver.c
View file @
5c438e3f
...
...
@@ -35,6 +35,7 @@
#include <pthread.h>
#endif
#include "rfb.h"
#include "region.h"
rfbClientPtr
pointerClient
=
NULL
;
/* Mutex for pointer events */
...
...
@@ -845,8 +846,8 @@ rfbSendFramebufferUpdate(cl, updateRegion)
sendCursorShape
=
TRUE
;
}
else
{
if
(
!
cl
->
screen
->
cursorIsDrawn
)
//
rfbDrawCursor(cl);
fprintf
(
stderr
,
"rfbSpriteRestoreCursor(pScreen); not yet!
\n
"
);
rfbDrawCursor
(
cl
);
//
fprintf(stderr,"rfbSpriteRestoreCursor(pScreen); not yet!\n");
}
/*
...
...
@@ -865,9 +866,9 @@ rfbSendFramebufferUpdate(cl, updateRegion)
* no update is needed.
*/
//
REGION_INIT(pScreen,&updateRegion,NullBox,0);
//
REGION_UNION(pScreen, &updateRegion, &cl->copyRegion,
//
&cl->modifiedRegion);
REGION_INIT
(
pScreen
,
&
updateRegion
,
NullBox
,
0
);
REGION_UNION
(
pScreen
,
&
updateRegion
,
&
cl
->
copyRegion
,
&
cl
->
modifiedRegion
);
REGION_INTERSECT
(
pScreen
,
&
updateRegion
,
&
cl
->
requestedRegion
,
&
updateRegion
);
...
...
sockets.c
View file @
5c438e3f
...
...
@@ -61,6 +61,8 @@ struct timeval
#include "rfb.h"
int
max
(
int
i
,
int
j
)
{
return
(
i
<
j
?
j
:
i
);
}
int
rfbMaxClientWait
=
20000
;
/* time (ms) after which we decide client has
gone away - needed to stop us hanging */
...
...
xalloc.c
View file @
5c438e3f
...
...
@@ -13,12 +13,12 @@
#ifdef WIN32
#include <X11/Xwinsock.h>
#endif
#include "Xos.h"
#include "X
11/X
os.h"
#include <stdio.h>
#include "misc.h"
#include "X.h"
#include "input.h"
#include "opaque.h"
#include "
Xserver/
misc.h"
#include "X
11/X
.h"
#include "
Xserver/
input.h"
#include "
Xserver/
opaque.h"
#ifdef X_POSIX_C_SOURCE
#define _POSIX_C_SOURCE X_POSIX_C_SOURCE
#include <signal.h>
...
...
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