From f9baaf1ee49e7889808b1f058a5f348a9cd5f027 Mon Sep 17 00:00:00 2001 From: runge Date: Thu, 28 Dec 2006 17:57:10 +0000 Subject: [PATCH] more compiler warnings cleanup. --- x11vnc/8to24.c | 3 +++ x11vnc/README | 2 +- x11vnc/cleanup.c | 2 ++ x11vnc/connections.c | 1 + x11vnc/cursor.c | 5 +++-- x11vnc/macosx.c | 13 +++++-------- x11vnc/macosx.h | 2 ++ x11vnc/macosxCG.c | 31 ++++++++++++++++++++++--------- x11vnc/macosxCG.h | 6 ++++++ x11vnc/macosxCGP.c | 9 +++++---- x11vnc/macosxCGS.c | 18 +++++++++++------- x11vnc/macosxCGS.h | 1 + x11vnc/scan.c | 5 ++--- x11vnc/screen.c | 1 + x11vnc/sslhelper.c | 2 +- x11vnc/uinput.c | 11 +++++++++-- x11vnc/userinput.c | 9 ++++----- x11vnc/v4l.c | 34 ++++++++++++++++++++++++++++++++-- x11vnc/win_utils.c | 1 + x11vnc/xevents.c | 3 ++- x11vnc/xwrappers.c | 1 + 21 files changed, 115 insertions(+), 45 deletions(-) diff --git a/x11vnc/8to24.c b/x11vnc/8to24.c index b07e468..1d071a8 100644 --- a/x11vnc/8to24.c +++ b/x11vnc/8to24.c @@ -1475,6 +1475,9 @@ if (db24 > 1) fprintf(stderr, "transform %4d %4d %4d %4d cm: %d\n", rect.x1, rec return; #else + attr.width = 0; + attr.height = 0; + /* now transform the pixels in this rectangle: */ n_off = main_bytes_per_line * rect.y1 + pixelsize * rect.x1; diff --git a/x11vnc/README b/x11vnc/README index d1e44a6..a9864f3 100644 --- a/x11vnc/README +++ b/x11vnc/README @@ -1,5 +1,5 @@ -x11vnc README file Date: Thu Dec 28 10:42:34 EST 2006 +x11vnc README file Date: Thu Dec 28 12:53:07 EST 2006 The following information is taken from these URLs: diff --git a/x11vnc/cleanup.c b/x11vnc/cleanup.c index 1134a0f..74f0ea6 100644 --- a/x11vnc/cleanup.c +++ b/x11vnc/cleanup.c @@ -12,6 +12,8 @@ #include "sslcmds.h" #include "sslhelper.h" #include "connections.h" +#include "macosx.h" +#include "macosxCG.h" /* * Exiting and error handling routines diff --git a/x11vnc/connections.c b/x11vnc/connections.c index 50cf6cf..343f11f 100644 --- a/x11vnc/connections.c +++ b/x11vnc/connections.c @@ -16,6 +16,7 @@ #include "sslhelper.h" #include "xwrappers.h" #include "xevents.h" +#include "macosx.h" #include "macosxCG.h" #include "userinput.h" diff --git a/x11vnc/cursor.c b/x11vnc/cursor.c index ab9218c..54ac152 100644 --- a/x11vnc/cursor.c +++ b/x11vnc/cursor.c @@ -6,6 +6,7 @@ #include "screen.h" #include "scan.h" #include "unixpw.h" +#include "macosx.h" int xfixes_present = 0; int use_xfixes = 1; @@ -1460,10 +1461,10 @@ int get_which_cursor(void) { int db = 0; if (show_multiple_cursors) { - int depth; + int depth = 0; static win_str_info_t winfo; static int first = 1, depth_cutoff = -1; - Window win; + Window win = None; XErrorHandler old_handler; int mode = 0; diff --git a/x11vnc/macosx.c b/x11vnc/macosx.c index ccea8df..59aa92e 100644 --- a/x11vnc/macosx.c +++ b/x11vnc/macosx.c @@ -19,6 +19,7 @@ #include "allowed_input_t.h" #include "keyboard.h" #include "cursor.h" +#include "connections.h" #include "macosxCG.h" #include "macosxCGP.h" #include "macosxCGS.h" @@ -35,6 +36,8 @@ int macosx_valid_window(Window, XWindowAttributes*); Status macosx_xquerytree(Window w, Window *root_return, Window *parent_return, Window **children_return, unsigned int *nchildren_return); +int macosx_get_wm_frame_pos(int *px, int *py, int *x, int *y, int *w, int *h, + Window *frame, Window *win); void macosx_add_mapnotify(Window win, int level, int map); void macosx_add_create(Window win, int level); @@ -287,7 +290,6 @@ void init_key_table(void) { } void macosx_key_command(rfbBool down, rfbKeySym keysym, rfbClientPtr client) { - static int control = 0, alt = 0; allowed_input_t input; if (debug_keyboard) fprintf(stderr, "macosx_key_command: %d %s\n", (int) keysym, down ? "down" : "up"); @@ -301,7 +303,6 @@ void macosx_key_command(rfbBool down, rfbKeySym keysym, rfbClientPtr client) { init_key_table(); macosxCG_key_inject((int) down, (unsigned int) keysym); - } extern void macosxGCS_poll_pb(void); @@ -600,11 +601,11 @@ extern int CGS_levels[]; Status macosx_xquerytree(Window w, Window *root_return, Window *parent_return, Window **children_return, unsigned int *nchildren_return) { - int i, n, k, swap; - int win1, win2; + int i, n, k; *root_return = (Window) 0; *parent_return = (Window) 0; + if (!w) {} macosxCGS_get_all_windows(); @@ -685,17 +686,13 @@ int macosx_check_clipped(int win, int *list, int n) { if (sraRgnAnd(r2, r1)) { ret = 1; sraRgnDestroy(r2); -//fprintf(stderr, "macosx_check_clipped: %4d %4d -- CLIP\n", win, list[k]); break; } -//fprintf(stderr, "macosx_check_clipped: %4d %4d -- -no-\n", win, list[k]); sraRgnDestroy(r2); } sraRgnDestroy(r0); sraRgnDestroy(r1); -//fprintf(stderr, "macosx_check_clipped: %4d -- CLIP: %s\n", win, ret ? "yes" : "no"); - return ret; } diff --git a/x11vnc/macosx.h b/x11vnc/macosx.h index 1ff0b69..907c723 100644 --- a/x11vnc/macosx.h +++ b/x11vnc/macosx.h @@ -13,6 +13,8 @@ extern int macosx_get_cursor_pos(int *, int *); extern int macosx_valid_window(Window, XWindowAttributes*); extern Status macosx_xquerytree(Window w, Window *root_return, Window *parent_return, Window **children_return, unsigned int *nchildren_return); +extern int macosx_get_wm_frame_pos(int *px, int *py, int *x, int *y, int *w, int *h, + Window *frame, Window *win); extern void macosx_send_sel(char *, int); extern void macosx_set_sel(char *, int); diff --git a/x11vnc/macosxCG.c b/x11vnc/macosxCG.c index 81175a4..086451a 100644 --- a/x11vnc/macosxCG.c +++ b/x11vnc/macosxCG.c @@ -15,6 +15,7 @@ void macosxCG_dummy(void) {} #include void macosxCG_init(void); +void macosxCG_fini(void); void macosxCG_event_loop(void); char *macosxCG_get_fb_addr(void); @@ -38,7 +39,8 @@ extern int collect_macosx_damage(int x_in, int y_in, int w_in, int h_in, int cal static void macosxCG_callback(CGRectCount n, const CGRect *rects, void *dum) { int i, db = 0; if (db) fprintf(stderr, "macosx_callback: n=%d\n", (int) n); - for (i=0; i < n; i++) { + if (!dum) {} + for (i=0; i < (int) n; i++) { if (db > 1) fprintf(stderr, " : %g %g - %g %g\n", rects[i].origin.x, rects[i].origin.y, rects[i].size.width, rects[i].size.height); collect_macosx_damage( (int) rects[i].origin.x, (int) rects[i].origin.y, (int) rects[i].size.width, (int) rects[i].size.height, 1); @@ -90,6 +92,11 @@ void macosxCG_refresh_callback_off(void) { extern int macosx_noscreensaver; extern void macosxGCS_initpb(void); +extern int macosxCGP_init_dimming(void); +extern int macosxCGP_undim(void); +extern int macosxCGP_dim_shutdown(void); +extern void macosxCGP_screensaver_timer_off(void); +extern void macosxCGP_screensaver_timer_on(void); void macosxCG_init(void) { if (displayID == NULL) { @@ -130,6 +137,10 @@ extern int client_count, nofb; extern void do_new_fb(int); extern int macosx_wait_for_switch, macosx_resize; +extern void macosxGCS_poll_pb(void); +extern void usleep(unsigned long usec); +extern unsigned int sleep(unsigned int seconds); + void macosxCG_event_loop(void) { OSStatus rc; int nbpp; @@ -278,11 +289,11 @@ int macosxCG_get_cursor(void) { int last_idx = (int) get_cursor_serial(1); int which = 1; CGError err; - int datasize, masksize, row_bytes, cdepth, comps, bpcomp; + int datasize, row_bytes, cdepth, comps, bpcomp; CGRect rect; CGPoint hot; unsigned char *data; - int res, cursor_seed; + int cursor_seed; static int last_cursor_seed = -1; static time_t last_fetch = 0; time_t now = time(NULL); @@ -337,7 +348,7 @@ extern int macosx_swap23; extern int off_x, coff_x, off_y, coff_y; void macosxCG_pointer_inject(int mask, int x, int y) { - int swap23 = macosx_swap23, rc; + int swap23 = macosx_swap23; int s1 = 0, s2 = 1, s3 = 2, s4 = 3, s5 = 4; CGPoint loc; int wheel_distance = macosx_mouse_wheel_speed; @@ -561,23 +572,25 @@ void macosxCG_init_key_table(void) { keyTable[i] = 0xFFFF; keyTableMods[i] = 0; } - for (i=0; i< (sizeof(USKeyCodes) / sizeof(int)); i += 2) { + for (i=0; i< (int) (sizeof(USKeyCodes) / sizeof(int)); i += 2) { int j = USKeyCodes[i]; keyTable[(unsigned short) j] = (CGKeyCode) USKeyCodes[i+1]; } - for (i=0; i< (sizeof(SpecialKeyCodes) / sizeof(int)); i += 2) { + for (i=0; i< (int) (sizeof(SpecialKeyCodes) / sizeof(int)); i += 2) { int j = SpecialKeyCodes[i]; keyTable[(unsigned short) j] = (CGKeyCode) SpecialKeyCodes[i+1]; } } -void macosxCG_key_inject(int down, unsigned int keysym) { - static int control = 0, alt = 0; - int pressModsForKeys = FALSE; +extern void init_key_table(void); +void macosxCG_key_inject(int down, unsigned int keysym) { CGKeyCode keyCode = keyTable[(unsigned short)keysym]; CGCharCode keyChar = 0; +#if 0 + int pressModsForKeys = FALSE; UInt32 modsForKey = keyTableMods[keysym] << 8; +#endif init_key_table(); diff --git a/x11vnc/macosxCG.h b/x11vnc/macosxCG.h index 4fe9c2a..2569496 100644 --- a/x11vnc/macosxCG.h +++ b/x11vnc/macosxCG.h @@ -4,6 +4,7 @@ /* -- macosxCG.h -- */ extern void macosxCG_init(void); +extern void macosxCG_fini(void); extern void macosxCG_event_loop(void); extern char *macosxCG_get_fb_addr(void); @@ -12,6 +13,7 @@ extern int macosxCG_CGDisplayPixelsHigh(void); extern int macosxCG_CGDisplayBitsPerPixel(void); extern int macosxCG_CGDisplayBitsPerSample(void); extern int macosxCG_CGDisplaySamplesPerPixel(void); +extern int macosxCG_CGDisplayBytesPerRow(void); extern void macosxCG_pointer_inject(int mask, int x, int y); extern int macosxCG_get_cursor_pos(int *x, int *y); @@ -19,5 +21,9 @@ extern int macosxCG_get_cursor(void); extern void macosxCG_init_key_table(void); extern void macosxCG_key_inject(int down, unsigned int keysym); +extern void macosxCG_refresh_callback_off(void); +extern void macosxCG_refresh_callback_on(void); + + #endif /* _X11VNC_MACOSXCG_H */ diff --git a/x11vnc/macosxCGP.c b/x11vnc/macosxCGP.c index 0366f81..9049ebb 100644 --- a/x11vnc/macosxCGP.c +++ b/x11vnc/macosxCGP.c @@ -38,21 +38,22 @@ static EventLoopTimerUPP sstimerUPP; static EventLoopTimerRef sstimer; void macosxCG_screensaver_timer(EventLoopTimerRef timer, void *data) { - if (0) fprintf(stderr, "macosxCG_screensaver_timer: %d\n", time(0)); + if (0) fprintf(stderr, "macosxCG_screensaver_timer: %d\n", (int) time(0)); + if (!timer || !data) {} if (macosx_nosleep && client_count) { - if (0) fprintf(stderr, "UpdateSystemActivity: %d\n", time(0)); + if (0) fprintf(stderr, "UpdateSystemActivity: %d\n", (int) time(0)); UpdateSystemActivity(IdleActivity); } } void macosxCGP_screensaver_timer_off(void) { - if (0) fprintf(stderr, "macosxCGP_screensaver_timer_off: %d\n", time(0)); + if (0) fprintf(stderr, "macosxCGP_screensaver_timer_off: %d\n", (int) time(0)); RemoveEventLoopTimer(sstimer); DisposeEventLoopTimerUPP(sstimerUPP); } void macosxCGP_screensaver_timer_on(void) { - if (0) fprintf(stderr, "macosxCGP_screensaver_timer_on: %d\n", time(0)); + if (0) fprintf(stderr, "macosxCGP_screensaver_timer_on: %d\n", (int) time(0)); sstimerUPP = NewEventLoopTimerUPP(macosxCG_screensaver_timer); InstallEventLoopTimer(GetMainEventLoop(), kEventDurationSecond * 30, kEventDurationSecond * 30, sstimerUPP, NULL, &sstimer); diff --git a/x11vnc/macosxCGS.c b/x11vnc/macosxCGS.c index a723242..b492ef6 100644 --- a/x11vnc/macosxCGS.c +++ b/x11vnc/macosxCGS.c @@ -132,11 +132,13 @@ int macosxCGS_find_index(int w) { return -1; } +extern void usleep(unsigned long usec); + int macosxCGS_follow_animation_win(int win, int idx, int grow) { double t = dnow(); int diffs = 0; int x, y, w, h; - int xp, yp, wp, hp; + int xp = -1, yp = -1, wp = -1, hp = -1; CGSRect rect; CGSError err; @@ -217,13 +219,13 @@ static int check_offscreen(int win) { extern int macosx_ncache_macmenu; + void macosxCGS_get_all_windows(void) { static double last = 0.0; static int totcnt = 0; double dt = 0.0, now = dnow(); - int i, db = 0, whist_prv, maxwin = 0, whist_skip = 0; + int i, db = 0, whist_prv = 0, maxwin = 0, whist_skip = 0; CGSWindowCount cap = (CGSWindowCount) MAXWINDAT; - CGSWindowCount cnt = 0; CGSError err; CGS_levelmax = 0; @@ -267,7 +269,7 @@ void macosxCGS_get_all_windows(void) { err = CGSGetWindowList(cid, NULL, cap, _wins_all, &_wins_all_cnt); -if (db) fprintf(stderr, "cnt: %d err: %d\n", _wins_all_cnt, err); +if (db) fprintf(stderr, "cnt: %d err: %d\n", (int) _wins_all_cnt, err); if (err != 0) { return; @@ -330,7 +332,7 @@ if (0 || db) fprintf(stderr, "i=%03d ID: %06d x: %03d y: %03d w: %03d h: %03d err = CGSGetOnScreenWindowList(cid, NULL, cap, _wins_mapped, &_wins_mapped_cnt); -if (db) fprintf(stderr, "cnt: %d err: %d\n", _wins_mapped_cnt, err); +if (db) fprintf(stderr, "cnt: %d err: %d\n", (int) _wins_mapped_cnt, err); if (err != 0) { return; @@ -394,9 +396,9 @@ if (db) fprintf(stderr, "cnt: %d err: %d\n", _wins_mapped_cnt, err); ; } else if ( !(prev & is_mapped) && (curr & is_mapped)) { /* MapNotify */ - fprintf(stderr, "MapNotify: %d/%d %d %.4f %d tot=%d\n", prev, curr, win, dnowx(), totcnt); + fprintf(stderr, "MapNotify: %d/%d %d %.4f tot=%d\n", prev, curr, win, dnowx(), totcnt); macosx_add_mapnotify(win, macwins[i].level, 1); - //macosxCGS_follow_animation_win(win, i, 1); + if (0) macosxCGS_follow_animation_win(win, i, 1); } else if ( !(curr & is_mapped) && (prev & is_mapped)) { /* UnmapNotify */ @@ -532,6 +534,7 @@ void macosxGCS_poll_pb(void) { } dlast = now; + { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [pblock lock]; if (pbcnt != [[NSPasteboard generalPasteboard] changeCount]) { @@ -550,6 +553,7 @@ void macosxGCS_poll_pb(void) { } [pblock unlock]; [pool release]; + } } #endif diff --git a/x11vnc/macosxCGS.h b/x11vnc/macosxCGS.h index b6b7bb2..42bc16d 100644 --- a/x11vnc/macosxCGS.h +++ b/x11vnc/macosxCGS.h @@ -7,6 +7,7 @@ extern void macosxCGS_get_all_windows(void); extern int macosxCGS_get_qlook(int); extern void macosxGCS_set_pasteboard(char *str, int len); extern int macosxCGS_follow_animation_win(int win, int idx, int grow); +extern int macosxCGS_find_index(int w); #endif /* _X11VNC_MACOSXCGS_H */ diff --git a/x11vnc/scan.c b/x11vnc/scan.c index 633917f..61706d7 100644 --- a/x11vnc/scan.c +++ b/x11vnc/scan.c @@ -547,6 +547,8 @@ static void hint_updates(void) { int x, y, i, n, ty, th, tx, tw; int hint_count = 0, in_run = 0; + hint.x = hint.y = hint.w = hint.h = 0; + for (y=0; y < ntiles_y; y++) { for (x=0; x < ntiles_x; x++) { n = x + y * ntiles_x; @@ -3069,7 +3071,6 @@ int scan_for_updates(int count_only) { /* scan with the initial y to the jitter value from scanlines: */ scan_in_progress = 1; tile_count = scan_display(scanlines[scan_count], 0); -//if (tile_count) fprintf(stderr, "XX tile_countA: %d\n", tile_count); SCAN_FATAL(tile_count); /* @@ -3132,14 +3133,12 @@ int scan_for_updates(int count_only) { cp = (NSCAN - scan_count) % NSCAN; tile_count = scan_display(scanlines[cp], 1); -//fprintf(stderr, "XX tile_countB: %d\n", tile_count); SCAN_FATAL(tile_count); if (tile_count >= (1 + frac2) * tile_count_old) { /* on a roll... do a 3rd scan */ cp = (NSCAN - scan_count + 7) % NSCAN; tile_count = scan_display(scanlines[cp], 1); -//fprintf(stderr, "XX tile_countC: %d\n", tile_count); SCAN_FATAL(tile_count); } } diff --git a/x11vnc/screen.c b/x11vnc/screen.c index f61a866..e627026 100644 --- a/x11vnc/screen.c +++ b/x11vnc/screen.c @@ -22,6 +22,7 @@ #include "v4l.h" #include "linuxfb.h" #include "macosx.h" +#include "macosxCG.h" void set_greyscale_colormap(void); void set_hi240_colormap(void); diff --git a/x11vnc/sslhelper.c b/x11vnc/sslhelper.c index 89770af..9ccc4a9 100644 --- a/x11vnc/sslhelper.c +++ b/x11vnc/sslhelper.c @@ -1510,7 +1510,7 @@ void accept_openssl(int mode) { } if (have_httpd) { - int n, is_http; + int n = 0, is_http; int hport = screen->httpPort; char *iface = NULL; char *buf, *tbuf; diff --git a/x11vnc/uinput.c b/x11vnc/uinput.c index c25f212..680c09d 100644 --- a/x11vnc/uinput.c +++ b/x11vnc/uinput.c @@ -82,10 +82,10 @@ static char *devs[] = { */ int check_uinput(void) { - int i; #ifndef UINPUT_OK return 0; #else + int i; if (UT.release) { int maj, min; /* guard against linux 2.4 */ @@ -455,6 +455,8 @@ static void ptr_move(int dx, int dy) { ev.code = SYN_REPORT; ev.value = 0; write(fd, &ev, sizeof(ev)); +#else + if (!dx || !dy) {} #endif } @@ -485,6 +487,8 @@ static void ptr_abs(int x, int y) { ev.code = SYN_REPORT; ev.value = 0; write(fd, &ev, sizeof(ev)); +#else + if (!x || !y) {} #endif } @@ -668,7 +672,8 @@ static void button_click(int down, int btn) { write(fd, &ev, sizeof(ev)); last_button_click = dnow(); - +#else + if (!down || !btn) {} #endif } @@ -910,6 +915,8 @@ void uinput_key_command(int down, int keysym, rfbClientPtr client) { if (0 <= scancode && scancode < 256) { key_pressed[scancode] = down ? 1 : 0; } +#else + if (!down || !keysym || !client) {} #endif } diff --git a/x11vnc/userinput.c b/x11vnc/userinput.c index 14605b3..e19ab8d 100644 --- a/x11vnc/userinput.c +++ b/x11vnc/userinput.c @@ -1696,7 +1696,6 @@ if (db) fprintf(stderr, " DFC(%d,%d-%d,%d)", tx1, ty1, tx2, ty2); if (fast_push) { fb_push(); } -//fb_push(); do_fb_push++; PUSH_TEST(0); } @@ -4079,9 +4078,9 @@ fprintf(stderr, "FAW orig_frame unmapped.\n"); if (unmapped) { ; } else if (orig_frame && macosxCGS_follow_animation_win(orig_frame, -1, 0)) { - fprintf(stderr, "FAW orig_frame %d\n", orig_frame); + fprintf(stderr, "FAW orig_frame %d\n", (int) orig_frame); } else if (0 && frame && macosxCGS_follow_animation_win(frame, -1, 0)) { - fprintf(stderr, "FAW frame %d\n", frame); + fprintf(stderr, "FAW frame %d\n", (int) frame); } for (j=0; j