1341 |
} |
} |
1342 |
} |
} |
1343 |
|
|
1344 |
|
static void |
1345 |
|
handle_button_event(XEvent xevent, BOOL down) |
1346 |
|
{ |
1347 |
|
uint16 button, flags = 0; |
1348 |
|
g_last_gesturetime = xevent.xbutton.time; |
1349 |
|
button = xkeymap_translate_button(xevent.xbutton.button); |
1350 |
|
if (button == 0) |
1351 |
|
return; |
1352 |
|
|
1353 |
|
if (down) |
1354 |
|
flags = MOUSE_FLAG_DOWN; |
1355 |
|
|
1356 |
|
/* Stop moving window when button is released, regardless of cursor position */ |
1357 |
|
if (g_moving_wnd && (xevent.type == ButtonRelease)) |
1358 |
|
g_moving_wnd = False; |
1359 |
|
|
1360 |
|
/* If win_button_size is nonzero, enable single app mode */ |
1361 |
|
if (xevent.xbutton.y < g_win_button_size) |
1362 |
|
{ |
1363 |
|
/* Check from right to left: */ |
1364 |
|
if (xevent.xbutton.x >= g_width - g_win_button_size) |
1365 |
|
{ |
1366 |
|
/* The close button, continue */ |
1367 |
|
; |
1368 |
|
} |
1369 |
|
else if (xevent.xbutton.x >= g_width - g_win_button_size * 2) |
1370 |
|
{ |
1371 |
|
/* The maximize/restore button. Do not send to |
1372 |
|
server. It might be a good idea to change the |
1373 |
|
cursor or give some other visible indication |
1374 |
|
that rdesktop inhibited this click */ |
1375 |
|
if (xevent.type == ButtonPress) |
1376 |
|
return; |
1377 |
|
} |
1378 |
|
else if (xevent.xbutton.x >= g_width - g_win_button_size * 3) |
1379 |
|
{ |
1380 |
|
/* The minimize button. Iconify window. */ |
1381 |
|
if (xevent.type == ButtonRelease) |
1382 |
|
{ |
1383 |
|
/* Release the mouse button outside the minimize button, to prevent the |
1384 |
|
actual minimazation to happen */ |
1385 |
|
rdp_send_input(time(NULL), RDP_INPUT_MOUSE, button, 1, 1); |
1386 |
|
XIconifyWindow(g_display, g_wnd, DefaultScreen(g_display)); |
1387 |
|
return; |
1388 |
|
} |
1389 |
|
} |
1390 |
|
else if (xevent.xbutton.x <= g_win_button_size) |
1391 |
|
{ |
1392 |
|
/* The system menu. Ignore. */ |
1393 |
|
if (xevent.type == ButtonPress) |
1394 |
|
return; |
1395 |
|
} |
1396 |
|
else |
1397 |
|
{ |
1398 |
|
/* The title bar. */ |
1399 |
|
if (xevent.type == ButtonPress) |
1400 |
|
{ |
1401 |
|
if (!g_fullscreen && g_hide_decorations) |
1402 |
|
{ |
1403 |
|
g_moving_wnd = True; |
1404 |
|
g_move_x_offset = xevent.xbutton.x; |
1405 |
|
g_move_y_offset = xevent.xbutton.y; |
1406 |
|
} |
1407 |
|
return; |
1408 |
|
} |
1409 |
|
} |
1410 |
|
} |
1411 |
|
|
1412 |
|
rdp_send_input(time(NULL), RDP_INPUT_MOUSE, |
1413 |
|
flags | button, xevent.xbutton.x, xevent.xbutton.y); |
1414 |
|
} |
1415 |
|
|
1416 |
/* Process events in Xlib queue |
/* Process events in Xlib queue |
1417 |
Returns 0 after user quit, 1 otherwise */ |
Returns 0 after user quit, 1 otherwise */ |
1418 |
static int |
static int |
1420 |
{ |
{ |
1421 |
XEvent xevent; |
XEvent xevent; |
1422 |
KeySym keysym; |
KeySym keysym; |
|
uint16 button, flags; |
|
1423 |
uint32 ev_time; |
uint32 ev_time; |
1424 |
char str[256]; |
char str[256]; |
1425 |
Status status; |
Status status; |
1435 |
continue; |
continue; |
1436 |
} |
} |
1437 |
|
|
|
flags = 0; |
|
|
|
|
1438 |
switch (xevent.type) |
switch (xevent.type) |
1439 |
{ |
{ |
1440 |
case VisibilityNotify: |
case VisibilityNotify: |
1479 |
break; |
break; |
1480 |
|
|
1481 |
xkeymap_send_keys(keysym, xevent.xkey.keycode, xevent.xkey.state, |
xkeymap_send_keys(keysym, xevent.xkey.keycode, xevent.xkey.state, |
1482 |
ev_time, True); |
ev_time, True, 0); |
1483 |
break; |
break; |
1484 |
|
|
1485 |
case KeyRelease: |
case KeyRelease: |
1495 |
break; |
break; |
1496 |
|
|
1497 |
xkeymap_send_keys(keysym, xevent.xkey.keycode, xevent.xkey.state, |
xkeymap_send_keys(keysym, xevent.xkey.keycode, xevent.xkey.state, |
1498 |
ev_time, False); |
ev_time, False, 0); |
1499 |
break; |
break; |
1500 |
|
|
1501 |
case ButtonPress: |
case ButtonPress: |
1502 |
flags = MOUSE_FLAG_DOWN; |
handle_button_event(xevent, True); |
1503 |
/* fall through */ |
break; |
1504 |
|
|
1505 |
case ButtonRelease: |
case ButtonRelease: |
1506 |
g_last_gesturetime = xevent.xbutton.time; |
handle_button_event(xevent, False); |
|
button = xkeymap_translate_button(xevent.xbutton.button); |
|
|
if (button == 0) |
|
|
break; |
|
|
|
|
|
/* If win_button_size is nonzero, enable single app mode */ |
|
|
if (xevent.xbutton.y < g_win_button_size) |
|
|
{ |
|
|
/* Stop moving window when button is released, regardless of cursor position */ |
|
|
if (g_moving_wnd && (xevent.type == ButtonRelease)) |
|
|
g_moving_wnd = False; |
|
|
|
|
|
/* Check from right to left: */ |
|
|
|
|
|
if (xevent.xbutton.x >= g_width - g_win_button_size) |
|
|
{ |
|
|
/* The close button, continue */ |
|
|
; |
|
|
} |
|
|
else if (xevent.xbutton.x >= |
|
|
g_width - g_win_button_size * 2) |
|
|
{ |
|
|
/* The maximize/restore button. Do not send to |
|
|
server. It might be a good idea to change the |
|
|
cursor or give some other visible indication |
|
|
that rdesktop inhibited this click */ |
|
|
break; |
|
|
} |
|
|
else if (xevent.xbutton.x >= |
|
|
g_width - g_win_button_size * 3) |
|
|
{ |
|
|
/* The minimize button. Iconify window. */ |
|
|
XIconifyWindow(g_display, g_wnd, |
|
|
DefaultScreen(g_display)); |
|
|
break; |
|
|
} |
|
|
else if (xevent.xbutton.x <= g_win_button_size) |
|
|
{ |
|
|
/* The system menu. Ignore. */ |
|
|
break; |
|
|
} |
|
|
else |
|
|
{ |
|
|
/* The title bar. */ |
|
|
if ((xevent.type == ButtonPress) && !g_fullscreen |
|
|
&& g_hide_decorations) |
|
|
{ |
|
|
g_moving_wnd = True; |
|
|
g_move_x_offset = xevent.xbutton.x; |
|
|
g_move_y_offset = xevent.xbutton.y; |
|
|
} |
|
|
break; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
rdp_send_input(time(NULL), RDP_INPUT_MOUSE, |
|
|
flags | button, xevent.xbutton.x, xevent.xbutton.y); |
|
1507 |
break; |
break; |
1508 |
|
|
1509 |
case MotionNotify: |
case MotionNotify: |