if (client->viewOnly) {
if (client && client->viewOnly) {
void keyboard(rfbBool down, rfbKeySym keysym, rfbClientPtr client) {	KeyCode k;	int isbutton = 0;	if (debug_keyboard) {		char *str;		X_LOCK;		str = XKeysymToString(keysym);		rfbLog("keyboard(%s, 0x%x \"%s\")\n", down ? "down":"up",		    (int) keysym, str ? str : "null");		X_UNLOCK;	}	if (view_only) {		return;	}	if (client->viewOnly) {		return;	}	last_keyboard_client = client;	last_event = last_input = time(0);	got_user_input++;	got_keyboard_input++;		if (keyremaps) {		keyremap_t *remap = keyremaps;		while (remap != NULL) {			if (remap->before == keysym) {				keysym = remap->after;				isbutton = remap->isbutton;				if (debug_keyboard) {					X_LOCK;					rfbLog("keyboard(): remapping keysym: "					    "0x%x \"%s\" -> 0x%x \"%s\"\n",					    (int) remap->before,					    XKeysymToString(remap->before),					    (int) remap->after,					    remap->isbutton ? "button" :					    XKeysymToString(remap->after));					X_UNLOCK;				}				break;			}			remap = remap->next;		}	}	if (isbutton) {		int button = (int) keysym;		if (! down) {			return;	/* nothing to send */		}		if (debug_keyboard) {			rfbLog("keyboard(): remapping keystroke to button %d"			    " click\n", button);		}		if (button < 1 || button > num_buttons) {			rfbLog("keyboard(): ignoring mouse button out of "			    "bounds: %d\n", button);			return;		}		X_LOCK;		XTestFakeButtonEvent_wr(dpy, button, True, CurrentTime);		XTestFakeButtonEvent_wr(dpy, button, False, CurrentTime);		XFlush(dpy);		X_UNLOCK;		return;	}	if (use_modifier_tweak) {		modifier_tweak_keyboard(down, keysym, client);		X_LOCK;		XFlush(dpy);		X_UNLOCK;		return;	}	X_LOCK;	k = XKeysymToKeycode(dpy, (KeySym) keysym);	if (k == NoSymbol && add_keysyms && ! IsModifierKey(keysym)) {		int new_kc = add_keysym(keysym);		if (new_kc) {			k = new_kc;		}	}	if (debug_keyboard) {		char *str = XKeysymToString(keysym);		rfbLog("keyboard(): KeySym 0x%x \"%s\" -> KeyCode 0x%x%s\n",		    (int) keysym, str ? str : "null", (int) k,		    k ? "" : " *ignored*");	}	if ( k != NoSymbol ) {		XTestFakeKeyEvent_wr(dpy, k, (Bool) down, CurrentTime);		XFlush(dpy);	}	X_UNLOCK;}