79 |
static BOOL g_moving_wnd; |
static BOOL g_moving_wnd; |
80 |
static int g_move_x_offset = 0; |
static int g_move_x_offset = 0; |
81 |
static int g_move_y_offset = 0; |
static int g_move_y_offset = 0; |
82 |
|
static BOOL g_using_full_workarea = False; |
83 |
|
|
84 |
#ifdef WITH_RDPSND |
#ifdef WITH_RDPSND |
85 |
extern int g_dsp_fd; |
extern int g_dsp_fd; |
138 |
XDrawArc(g_display, g_backstore, g_gc, x, y, cx, cy, 0, 360*64); \ |
XDrawArc(g_display, g_backstore, g_gc, x, y, cx, cy, 0, 360*64); \ |
139 |
break; \ |
break; \ |
140 |
case 1: /* Filled */ \ |
case 1: /* Filled */ \ |
141 |
XFillArc(g_display, g_ownbackstore ? g_backstore : g_wnd, g_gc, x, y, \ |
XFillArc(g_display, g_wnd, g_gc, x, y, cx, cy, 0, 360*64); \ |
|
cx, cy, 0, 360*64); \ |
|
142 |
if (g_ownbackstore) \ |
if (g_ownbackstore) \ |
143 |
XCopyArea(g_display, g_backstore, g_wnd, g_gc, x, y, cx, cy, x, y); \ |
XFillArc(g_display, g_backstore, g_gc, x, y, cx, cy, 0, 360*64); \ |
144 |
break; \ |
break; \ |
145 |
} \ |
} \ |
146 |
} |
} |
1091 |
else if (g_width < 0) |
else if (g_width < 0) |
1092 |
{ |
{ |
1093 |
/* Percent of screen */ |
/* Percent of screen */ |
1094 |
|
if (-g_width >= 100) |
1095 |
|
g_using_full_workarea = True; |
1096 |
g_height = HeightOfScreen(g_screen) * (-g_width) / 100; |
g_height = HeightOfScreen(g_screen) * (-g_width) / 100; |
1097 |
g_width = WidthOfScreen(g_screen) * (-g_width) / 100; |
g_width = WidthOfScreen(g_screen) * (-g_width) / 100; |
1098 |
} |
} |
1100 |
{ |
{ |
1101 |
/* Fetch geometry from _NET_WORKAREA */ |
/* Fetch geometry from _NET_WORKAREA */ |
1102 |
uint32 x, y, cx, cy; |
uint32 x, y, cx, cy; |
1103 |
|
g_using_full_workarea = True; |
1104 |
|
|
1105 |
if (get_current_workarea(&x, &y, &cx, &cy) == 0) |
if (get_current_workarea(&x, &y, &cx, &cy) == 0) |
1106 |
{ |
{ |
1344 |
} |
} |
1345 |
} |
} |
1346 |
|
|
1347 |
|
static void |
1348 |
|
handle_button_event(XEvent xevent, BOOL down) |
1349 |
|
{ |
1350 |
|
uint16 button, flags = 0; |
1351 |
|
g_last_gesturetime = xevent.xbutton.time; |
1352 |
|
button = xkeymap_translate_button(xevent.xbutton.button); |
1353 |
|
if (button == 0) |
1354 |
|
return; |
1355 |
|
|
1356 |
|
if (down) |
1357 |
|
flags = MOUSE_FLAG_DOWN; |
1358 |
|
|
1359 |
|
/* Stop moving window when button is released, regardless of cursor position */ |
1360 |
|
if (g_moving_wnd && (xevent.type == ButtonRelease)) |
1361 |
|
g_moving_wnd = False; |
1362 |
|
|
1363 |
|
/* If win_button_size is nonzero, enable single app mode */ |
1364 |
|
if (xevent.xbutton.y < g_win_button_size) |
1365 |
|
{ |
1366 |
|
/* Check from right to left: */ |
1367 |
|
if (xevent.xbutton.x >= g_width - g_win_button_size) |
1368 |
|
{ |
1369 |
|
/* The close button, continue */ |
1370 |
|
; |
1371 |
|
} |
1372 |
|
else if (xevent.xbutton.x >= g_width - g_win_button_size * 2) |
1373 |
|
{ |
1374 |
|
/* The maximize/restore button. Do not send to |
1375 |
|
server. It might be a good idea to change the |
1376 |
|
cursor or give some other visible indication |
1377 |
|
that rdesktop inhibited this click */ |
1378 |
|
if (xevent.type == ButtonPress) |
1379 |
|
return; |
1380 |
|
} |
1381 |
|
else if (xevent.xbutton.x >= g_width - g_win_button_size * 3) |
1382 |
|
{ |
1383 |
|
/* The minimize button. Iconify window. */ |
1384 |
|
if (xevent.type == ButtonRelease) |
1385 |
|
{ |
1386 |
|
/* Release the mouse button outside the minimize button, to prevent the |
1387 |
|
actual minimazation to happen */ |
1388 |
|
rdp_send_input(time(NULL), RDP_INPUT_MOUSE, button, 1, 1); |
1389 |
|
XIconifyWindow(g_display, g_wnd, DefaultScreen(g_display)); |
1390 |
|
return; |
1391 |
|
} |
1392 |
|
} |
1393 |
|
else if (xevent.xbutton.x <= g_win_button_size) |
1394 |
|
{ |
1395 |
|
/* The system menu. Ignore. */ |
1396 |
|
if (xevent.type == ButtonPress) |
1397 |
|
return; |
1398 |
|
} |
1399 |
|
else |
1400 |
|
{ |
1401 |
|
/* The title bar. */ |
1402 |
|
if (xevent.type == ButtonPress) |
1403 |
|
{ |
1404 |
|
if (!g_fullscreen && g_hide_decorations && !g_using_full_workarea) |
1405 |
|
{ |
1406 |
|
g_moving_wnd = True; |
1407 |
|
g_move_x_offset = xevent.xbutton.x; |
1408 |
|
g_move_y_offset = xevent.xbutton.y; |
1409 |
|
} |
1410 |
|
return; |
1411 |
|
} |
1412 |
|
} |
1413 |
|
} |
1414 |
|
|
1415 |
|
rdp_send_input(time(NULL), RDP_INPUT_MOUSE, |
1416 |
|
flags | button, xevent.xbutton.x, xevent.xbutton.y); |
1417 |
|
} |
1418 |
|
|
1419 |
/* Process events in Xlib queue |
/* Process events in Xlib queue |
1420 |
Returns 0 after user quit, 1 otherwise */ |
Returns 0 after user quit, 1 otherwise */ |
1421 |
static int |
static int |
1423 |
{ |
{ |
1424 |
XEvent xevent; |
XEvent xevent; |
1425 |
KeySym keysym; |
KeySym keysym; |
|
uint16 button, flags; |
|
1426 |
uint32 ev_time; |
uint32 ev_time; |
1427 |
char str[256]; |
char str[256]; |
1428 |
Status status; |
Status status; |
1438 |
continue; |
continue; |
1439 |
} |
} |
1440 |
|
|
|
flags = 0; |
|
|
|
|
1441 |
switch (xevent.type) |
switch (xevent.type) |
1442 |
{ |
{ |
1443 |
case VisibilityNotify: |
case VisibilityNotify: |
1482 |
break; |
break; |
1483 |
|
|
1484 |
xkeymap_send_keys(keysym, xevent.xkey.keycode, xevent.xkey.state, |
xkeymap_send_keys(keysym, xevent.xkey.keycode, xevent.xkey.state, |
1485 |
ev_time, True); |
ev_time, True, 0); |
1486 |
break; |
break; |
1487 |
|
|
1488 |
case KeyRelease: |
case KeyRelease: |
1498 |
break; |
break; |
1499 |
|
|
1500 |
xkeymap_send_keys(keysym, xevent.xkey.keycode, xevent.xkey.state, |
xkeymap_send_keys(keysym, xevent.xkey.keycode, xevent.xkey.state, |
1501 |
ev_time, False); |
ev_time, False, 0); |
1502 |
break; |
break; |
1503 |
|
|
1504 |
case ButtonPress: |
case ButtonPress: |
1505 |
flags = MOUSE_FLAG_DOWN; |
handle_button_event(xevent, True); |
1506 |
/* fall through */ |
break; |
1507 |
|
|
1508 |
case ButtonRelease: |
case ButtonRelease: |
1509 |
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); |
|
1510 |
break; |
break; |
1511 |
|
|
1512 |
case MotionNotify: |
case MotionNotify: |