xfreerdp: fix RAIL window resizing

This commit is contained in:
Marc-André Moreau 2011-08-19 11:12:30 -04:00
parent 19217d51ba
commit af71a70233
8 changed files with 109 additions and 26 deletions

View File

@ -22,6 +22,45 @@
#include "xf_event.h"
uint8 X11_EVENT_STRINGS[][20] =
{
"", "",
"KeyPress",
"KeyRelease",
"ButtonPress",
"ButtonRelease",
"MotionNotify",
"EnterNotify",
"LeaveNotify",
"FocusIn",
"FocusOut",
"KeymapNotify",
"Expose",
"GraphicsExpose",
"NoExpose",
"VisibilityNotify",
"CreateNotify",
"DestroyNotify",
"UnmapNotify",
"MapNotify",
"MapRequest",
"ReparentNotify",
"ConfigureNotify",
"ConfigureRequest",
"GravityNotify",
"ResizeRequest",
"CirculateNotify",
"CirculateRequest",
"PropertyNotify",
"SelectionClear",
"SelectionRequest",
"SelectionNotify",
"ColormapNotify",
"ClientMessage",
"MappingNotify",
"GenericEvent",
};
void xf_send_mouse_motion_event(rdpInput* input, boolean down, uint32 button, uint16 x, uint16 y)
{
input->MouseEvent(input, PTR_FLAGS_MOVE, x, y);
@ -59,6 +98,8 @@ boolean xf_event_Expose(xfInfo* xfi, XEvent* event, boolean app)
XCopyArea(xfi->display, xfi->primary, xfw->handle, xfw->gc,
window->windowOffsetX, window->windowOffsetY,
window->windowWidth, window->windowHeight, 0, 0);
XFlush(xfi->display);
}
}
@ -67,9 +108,7 @@ boolean xf_event_Expose(xfInfo* xfi, XEvent* event, boolean app)
boolean xf_event_VisibilityNotify(xfInfo* xfi, XEvent* event, boolean app)
{
if (app != True)
xfi->unobscured = event->xvisibility.state == VisibilityUnobscured;
xfi->unobscured = event->xvisibility.state == VisibilityUnobscured;
return True;
}
@ -344,14 +383,38 @@ boolean xf_event_EnterNotify(xfInfo* xfi, XEvent* event, boolean app)
boolean xf_event_LeaveNotify(xfInfo* xfi, XEvent* event, boolean app)
{
xfi->mouse_active = False;
XUngrabKeyboard(xfi->display, CurrentTime);
if (app != True)
{
xfi->mouse_active = False;
XUngrabKeyboard(xfi->display, CurrentTime);
}
return True;
}
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);
if (window != NULL)
{
xfw = (xfWindow*) window->extra;
XPutImage(xfi->display, xfi->primary, xfw->gc, xfi->image,
window->windowOffsetX, window->windowOffsetY,
window->windowOffsetX, window->windowOffsetY,
window->windowWidth, window->windowHeight);
XCopyArea(xfi->display, xfi->primary, xfw->handle, xfw->gc,
window->windowOffsetX, window->windowOffsetY,
window->windowWidth, window->windowHeight, 0, 0);
XFlush(xfi->display);
}
return True;
}
@ -371,6 +434,11 @@ boolean xf_event_process(freerdp* instance, XEvent* event)
app = True;
}
#if 0
if (event->type != MotionNotify)
printf("X11 %s Event\n", X11_EVENT_STRINGS[event->type]);
#endif
switch (event->type)
{
case Expose:

View File

@ -75,8 +75,6 @@ void xf_rail_MoveWindow(rdpRail* rail, rdpWindow* window)
window->windowOffsetX + xfi->workArea.x,
window->windowOffsetY + xfi->workArea.y,
window->windowWidth, window->windowHeight);
XFlush(xfi->display);
}
void xf_rail_DestroyWindow(rdpRail* rail, rdpWindow* window)

View File

@ -36,7 +36,7 @@ struct _PropMotifWmHints
};
typedef struct _PropMotifWmHints PropMotifWmHints;
void window_fullscreen(xfInfo* xfi, xfWindow* window, boolean fullscreen)
void desktop_fullscreen(xfInfo* xfi, xfWindow* window, boolean fullscreen)
{
if (fullscreen)
{
@ -159,7 +159,7 @@ xfWindow* desktop_create(xfInfo* xfi, char* name)
XClassHint* class_hints;
window->decorations = True;
window->fullscreen = False;
window->fullscreen = True;
window->handle = XCreateWindow(xfi->display, RootWindowOfScreen(xfi->screen),
xfi->workArea.x, xfi->workArea.y, xfi->width, xfi->height, 0, xfi->depth, InputOutput, xfi->visual,
@ -270,31 +270,36 @@ xfWindow* xf_CreateWindow(xfInfo* xfi, int x, int y, int width, int height, char
void xf_MoveWindow(xfInfo* xfi, xfWindow* window, int x, int y, int width, int height)
{
Pixmap surface;
XSizeHints* size_hints;
XWindowChanges changes;
changes.x = x;
changes.y = y;
changes.width = width;
changes.height = height;
XConfigureWindow(xfi->display, window->handle, CWX | CWY | CWWidth | CWHeight, &changes);
window->width = width;
window->height = height;
XFreePixmap(xfi->display, window->surface);
window->surface = XCreatePixmap(xfi->display, window->handle, window->width, window->height, xfi->depth);
size_hints = XAllocSizeHints();
if (size_hints)
{
size_hints->flags = PMinSize | PMaxSize;
size_hints->min_width = size_hints->max_width = window->width;
size_hints->min_height = size_hints->max_height = window->height;
size_hints->min_width = size_hints->max_width = width;
size_hints->min_height = size_hints->max_height = height;
XSetWMNormalHints(xfi->display, window->handle, size_hints);
XFree(size_hints);
}
if (window->width == width && window->height == height)
XMoveWindow(xfi->display, window->handle, x, y);
else if (window->x == x && window->y == y)
XResizeWindow(xfi->display, window->handle, width, height);
else
XMoveResizeWindow(xfi->display, window->handle, x, y, width, height);
surface = XCreatePixmap(xfi->display, window->handle, width, height, xfi->depth);
XCopyArea(xfi->display, surface, window->surface, window->gc, 0, 0, window->width, window->height, 0, 0);
XFreePixmap(xfi->display, window->surface);
window->surface = surface;
window->x = x;
window->y = y;
window->width = width;
window->height = height;
}
void xf_DestroyWindow(xfInfo* xfi, xfWindow* window)

View File

@ -31,6 +31,8 @@ typedef struct xf_window xfWindow;
struct xf_window
{
GC gc;
int x;
int y;
int width;
int height;
Window handle;
@ -42,7 +44,7 @@ struct xf_window
boolean window_GetCurrentDesktop(xfInfo* xfi);
boolean window_GetWorkArea(xfInfo* xfi);
void window_fullscreen(xfInfo* xfi, xfWindow* window, boolean fullscreen);
void desktop_fullscreen(xfInfo* xfi, xfWindow* window, boolean fullscreen);
void window_show_decorations(xfInfo* xfi, xfWindow* window, boolean show);
xfWindow* desktop_create(xfInfo* xfi, char* name);

View File

@ -166,6 +166,7 @@ boolean xf_pre_connect(freerdp* instance)
xfi->mouse_motion = True;
xfi->decoration = settings->decorations;
xfi->remote_app = settings->remote_app;
xfi->fullscreen = settings->fullscreen;
window_GetWorkArea(xfi);
@ -292,7 +293,9 @@ boolean xf_post_connect(freerdp* instance)
xfi->window = desktop_create(xfi, "xfreerdp");
window_show_decorations(xfi, xfi->window, xfi->decoration);
window_fullscreen(xfi, xfi->window, xfi->fullscreen);
if (xfi->fullscreen)
desktop_fullscreen(xfi, xfi->window, xfi->fullscreen);
/* wait for VisibilityNotify */
do

View File

@ -162,6 +162,7 @@ struct rdp_settings
uint16 width;
uint16 height;
boolean workarea;
boolean fullscreen;
boolean decorations;
uint32 rdp_version;
uint16 color_depth;

View File

@ -40,6 +40,7 @@ rdpSettings* settings_new()
settings->width = 1024;
settings->height = 768;
settings->workarea = False;
settings->fullscreen = False;
settings->decorations = True;
settings->rdp_version = 7;
settings->color_depth = 16;

View File

@ -147,6 +147,10 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
}
}
}
else if (strcmp("-f", argv[index]) == 0)
{
settings->fullscreen = True;
}
else if (strcmp("-D", argv[index]) == 0)
{
settings->decorations = False;
@ -214,6 +218,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
{
settings->remote_app = True;
settings->rail_langbar_supported = True;
settings->workarea = True;
}
else if (strcmp("-x", argv[index]) == 0)
{