xfreerdp: added initial Local Move/Size (by using _NET_WM_MOVERESIZE).
This commit is contained in:
parent
3c78705515
commit
e244300347
@ -421,15 +421,36 @@ boolean xf_event_LeaveNotify(xfInfo* xfi, XEvent* event, boolean app)
|
||||
|
||||
boolean xf_event_ConfigureNotify(xfInfo* xfi, XEvent* event, boolean app)
|
||||
{
|
||||
xfWindow* xfw;
|
||||
rdpWindow* window;
|
||||
|
||||
window = window_list_get_by_extra_id(xfi->rail->list, (void*) event->xany.window);
|
||||
printf( "ConfigureNotify event: send_event=%d eventWindow=0x%X window=0x%X above=0x%X x=%d y=%d "
|
||||
"width=%d height=%d override_redirect=%d\n",
|
||||
event->xconfigure.send_event,
|
||||
(uint32)event->xconfigure.event,
|
||||
(uint32)event->xconfigure.window,
|
||||
(uint32)event->xconfigure.above,
|
||||
event->xconfigure.x,
|
||||
event->xconfigure.y,
|
||||
event->xconfigure.width,
|
||||
event->xconfigure.height,
|
||||
event->xconfigure.override_redirect);
|
||||
|
||||
window = window_list_get_by_extra_id(xfi->rail->list, (void*) event->xconfigure.window);
|
||||
|
||||
if (window != NULL)
|
||||
{
|
||||
xfWindow* xfw;
|
||||
xfw = (xfWindow*) window->extra;
|
||||
|
||||
if (xfw->isLocalMoveSizeModeEnabled)
|
||||
{
|
||||
uint32 left = event->xconfigure.x;
|
||||
uint32 top = event->xconfigure.y;
|
||||
uint32 right = event->xconfigure.y + event->xconfigure.width - 1;
|
||||
uint32 bottom = event->xconfigure.y + event->xconfigure.height - 1;
|
||||
|
||||
xf_rail_send_windowmove(xfi, window->windowId, left, top, right, bottom);
|
||||
}
|
||||
XPutImage(xfi->display, xfi->primary, xfw->gc, xfi->image,
|
||||
xfw->left, xfw->top, xfw->left, xfw->top, xfw->width, xfw->height);
|
||||
|
||||
@ -476,7 +497,7 @@ boolean xf_event_process(freerdp* instance, XEvent* event)
|
||||
app = True;
|
||||
}
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
if (event->type != MotionNotify)
|
||||
printf("X11 %s Event: wnd=0x%X\n", X11_EVENT_STRINGS[event->type], (uint32)event->xany.window);
|
||||
#endif
|
||||
|
@ -20,6 +20,10 @@
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
#include <freerdp/rail.h>
|
||||
#include <freerdp/utils/rail.h>
|
||||
|
||||
|
||||
#ifdef WITH_XEXT
|
||||
#include <X11/extensions/shape.h>
|
||||
#endif
|
||||
@ -292,7 +296,7 @@ xfWindow* xf_CreateWindow(xfInfo* xfi, xfWindow* parent, int x, int y, int width
|
||||
window->decorations = False;
|
||||
window->fullscreen = False;
|
||||
window->parent = parent;
|
||||
window->isLocalMoveSizeStarted = False;
|
||||
window->isLocalMoveSizeModeEnabled = False;
|
||||
|
||||
window->handle = XCreateWindow(xfi->display, RootWindowOfScreen(xfi->screen),
|
||||
x, y, window->width, window->height, 0, xfi->depth, InputOutput, xfi->visual,
|
||||
@ -339,6 +343,8 @@ void xf_SetWindowMinMaxInfo(xfInfo* xfi, xfWindow* window,
|
||||
int minTrackWidth, int minTrackHeight,
|
||||
int maxTrackWidth, int maxTrackHeight)
|
||||
{
|
||||
XSizeHints* size_hints;
|
||||
|
||||
printf("xf_SetWindowMinMaxInfo: windowHandle=0x%X "
|
||||
"maxWidth=%d maxHeight=%d maxPosX=%d maxPosY=%d "
|
||||
"minTrackWidth=%d minTrackHeight=%d maxTrackWidth=%d maxTrackHeight=%d\n",
|
||||
@ -347,6 +353,27 @@ void xf_SetWindowMinMaxInfo(xfInfo* xfi, xfWindow* window,
|
||||
minTrackWidth, minTrackHeight,
|
||||
maxTrackWidth, maxTrackHeight);
|
||||
|
||||
size_hints = XAllocSizeHints();
|
||||
|
||||
if (size_hints)
|
||||
{
|
||||
size_hints->flags = PMinSize | PMaxSize | PResizeInc;
|
||||
|
||||
size_hints->min_width = minTrackWidth;
|
||||
size_hints->min_height = minTrackHeight;
|
||||
|
||||
size_hints->max_width = maxTrackWidth;
|
||||
size_hints->max_height = maxTrackHeight;
|
||||
|
||||
// For speedup window drawing we need to select optimal value
|
||||
// for sizing step.
|
||||
size_hints->width_inc = size_hints->height_inc = 5;
|
||||
|
||||
XSetWMNormalHints(xfi->display, window->handle, size_hints);
|
||||
XFree(size_hints);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -376,19 +403,88 @@ void SentMoveResizeEvent(xfInfo* xfi, xfWindow* window, int direction, int x_roo
|
||||
XSendEvent(xfi->display, RootWindowOfScreen(xfi->screen), False, SubstructureNotifyMask, &event);
|
||||
}
|
||||
|
||||
#define XF_NET_WM_MOVERESIZE_SIZE_TOPLEFT 0
|
||||
#define XF_NET_WM_MOVERESIZE_SIZE_TOP 1
|
||||
#define XF_NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2
|
||||
#define XF_NET_WM_MOVERESIZE_SIZE_RIGHT 3
|
||||
#define XF_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4
|
||||
#define XF_NET_WM_MOVERESIZE_SIZE_BOTTOM 5
|
||||
#define XF_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6
|
||||
#define XF_NET_WM_MOVERESIZE_SIZE_LEFT 7
|
||||
#define XF_NET_WM_MOVERESIZE_MOVE 8 /* movement only */
|
||||
#define XF_NET_WM_MOVERESIZE_SIZE_KEYBOARD 9 /* size via keyboard */
|
||||
#define XF_NET_WM_MOVERESIZE_MOVE_KEYBOARD 10 /* move via keyboard */
|
||||
#define XF_NET_WM_MOVERESIZE_CANCEL 11 /* cancel operation */
|
||||
|
||||
void xf_StartLocalMoveSize(xfInfo* xfi, xfWindow* window, uint16 moveSizeType, int posX, int posY)
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint16 moveSizeType;
|
||||
int direction;
|
||||
} type2dir_table[] =
|
||||
{
|
||||
{ RAIL_WMSZ_LEFT, XF_NET_WM_MOVERESIZE_SIZE_LEFT },
|
||||
{ RAIL_WMSZ_RIGHT, XF_NET_WM_MOVERESIZE_SIZE_RIGHT },
|
||||
{ RAIL_WMSZ_TOP, XF_NET_WM_MOVERESIZE_SIZE_TOP },
|
||||
{ RAIL_WMSZ_TOPLEFT, XF_NET_WM_MOVERESIZE_SIZE_TOPLEFT },
|
||||
{ RAIL_WMSZ_TOPRIGHT, XF_NET_WM_MOVERESIZE_SIZE_TOPRIGHT },
|
||||
{ RAIL_WMSZ_BOTTOM, XF_NET_WM_MOVERESIZE_SIZE_BOTTOM },
|
||||
{ RAIL_WMSZ_BOTTOMLEFT, XF_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT },
|
||||
{ RAIL_WMSZ_BOTTOMRIGHT, XF_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT },
|
||||
{ RAIL_WMSZ_MOVE, XF_NET_WM_MOVERESIZE_MOVE },
|
||||
{ RAIL_WMSZ_KEYMOVE, XF_NET_WM_MOVERESIZE_MOVE_KEYBOARD },
|
||||
{ RAIL_WMSZ_KEYSIZE, XF_NET_WM_MOVERESIZE_SIZE_KEYBOARD },
|
||||
};
|
||||
|
||||
int x_root = 0;
|
||||
int y_root = 0;
|
||||
int direction = -1;
|
||||
int i = 0;
|
||||
|
||||
|
||||
printf("xf_StartLocalMoveSize: window=0x%X moveSizeType=0x%X PosX=%d PosY=%d\n",
|
||||
(uint32)window->handle, moveSizeType, posX, posY);
|
||||
|
||||
window->isLocalMoveSizeStarted = True;
|
||||
window->isLocalMoveSizeModeEnabled = True;
|
||||
x_root = posX;
|
||||
y_root = posY;
|
||||
|
||||
if (moveSizeType == RAIL_WMSZ_MOVE)
|
||||
{
|
||||
x_root += window->left;
|
||||
y_root += window->top;
|
||||
}
|
||||
|
||||
for (i = 0; i < RAIL_ARRAY_SIZE(type2dir_table); i++)
|
||||
{
|
||||
if (type2dir_table[i].moveSizeType == moveSizeType)
|
||||
{
|
||||
direction = type2dir_table[i].direction;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (direction == -1)
|
||||
{
|
||||
printf("xf_StartLocalMoveSize: unknown moveSizeType. (window=0x%X moveSizeType=0x%X)\n",
|
||||
(uint32)window->handle, moveSizeType);
|
||||
return;
|
||||
}
|
||||
|
||||
SentMoveResizeEvent(xfi, window, direction, x_root, y_root);
|
||||
}
|
||||
|
||||
void xf_StopLocalMoveSize(xfInfo* xfi, xfWindow* window, uint16 moveSizeType, int topLeftX, int topLeftY)
|
||||
{
|
||||
window->isLocalMoveSizeStarted = False;
|
||||
window->isLocalMoveSizeModeEnabled = False;
|
||||
printf("xf_StopLocalMoveSize: window=0x%X moveSizeType=0x%X PosX=%d PosY=%d\n",
|
||||
(uint32)window->handle, moveSizeType, topLeftX, topLeftY);
|
||||
|
||||
if (moveSizeType == RAIL_WMSZ_MOVE)
|
||||
{
|
||||
xf_MoveWindow(xfi, window, topLeftX, topLeftY, window->width, window->height);
|
||||
}
|
||||
}
|
||||
|
||||
void xf_MoveWindow(xfInfo* xfi, xfWindow* window, int x, int y, int width, int height)
|
||||
@ -398,6 +494,9 @@ void xf_MoveWindow(xfInfo* xfi, xfWindow* window, int x, int y, int width, int h
|
||||
if ((width * height) < 1)
|
||||
return;
|
||||
|
||||
if (window->isLocalMoveSizeModeEnabled)
|
||||
return;
|
||||
|
||||
xf_FixWindowCoordinates(&x, &y, &width, &height);
|
||||
|
||||
XMoveResizeWindow(xfi->display, window->handle, x, y, width, height);
|
||||
|
@ -44,7 +44,7 @@ struct xf_window
|
||||
xfWindow* parent;
|
||||
size_t ref_count;
|
||||
|
||||
boolean isLocalMoveSizeStarted;
|
||||
boolean isLocalMoveSizeModeEnabled;
|
||||
};
|
||||
|
||||
void xf_ewmhints_init(xfInfo* xfi);
|
||||
@ -67,6 +67,10 @@ void xf_SetWindowVisibilityRects(xfInfo* xfi, xfWindow* window, RECTANGLE_16* re
|
||||
void xf_SetWindowStyle(xfInfo* xfi, xfWindow* window, uint32 style, uint32 ex_style);
|
||||
void xf_DestroyWindow(xfInfo* xfi, xfWindow* window);
|
||||
|
||||
void xf_SetWindowMinMaxInfo(xfInfo* xfi, xfWindow* window, int maxWidth, int maxHeight,
|
||||
int maxPosX, int maxPosY, int minTrackWidth, int minTrackHeight, int maxTrackWidth, int maxTrackHeight);
|
||||
|
||||
|
||||
void xf_StartLocalMoveSize(xfInfo* xfi, xfWindow* window, uint16 moveSizeType, int posX, int posY);
|
||||
void xf_StopLocalMoveSize(xfInfo* xfi, xfWindow* window, uint16 moveSizeType, int topLeftX, int topLeftY);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user