xfreerdp-client: tweaks for other clients

This commit is contained in:
C-o-r-E
2013-05-07 21:42:49 -04:00
parent cca413a5b9
commit 6a3cbfd072
5 changed files with 58 additions and 17 deletions

View File

@@ -561,15 +561,8 @@ static BOOL xf_event_ConfigureNotify(xfInfo* xfi, XEvent* event, BOOL app)
if(xfi->width != event->xconfigure.width)
{
printf("resize detected: x: %dx%d xfi:%dx%d orig: %dx%d\n",
event->xconfigure.width, event->xconfigure.height,
xfi->width, xfi->height,
xfi->orig_width, xfi->orig_height);
scale = (double)event->xconfigure.width / (double) xfi->orig_width;
printf("\tscale:%.2f\n", scale);
xfi->cur_width = event->xconfigure.width;
xfi->cur_height = event->xconfigure.width;
xfi->scale = scale;

View File

@@ -44,6 +44,8 @@ double firstDist = -1.0;
int xinput_opcode; //TODO: use this instead of xfi
int scale_cnt;
BOOL xf_input_is_duplicate(XIDeviceEvent* event)
{
if( (lastEvent.time == event->time) &&
@@ -69,7 +71,7 @@ void xf_input_save_last_event(XIDeviceEvent* event)
return;
}
void xf_input_detect_pinch()
void xf_input_detect_pinch(xfInfo* xfi)
{
double dist;
double zoom;
@@ -89,19 +91,63 @@ void xf_input_detect_pinch()
if(firstDist <= 0)
{
firstDist = dist;
scale_cnt = 0;
}
else
{
//compare the current distance to the first one
zoom = (dist / firstDist) * 100.0;
printf("zoom %.2f%%\n", zoom);
zoom = (dist / firstDist);
printf("zoom: %.2f, cnt:%d\n", zoom, scale_cnt);
if(zoom < 0.75 && scale_cnt == 0)
{
//zoom out one level
xfi->scale -= 0.05;
scale_cnt++;
XResizeWindow(xfi->display, xfi->window->handle, xfi->orig_width * xfi->scale, xfi->orig_height * xfi->scale);
IFCALL(xfi->client->OnResizeWindow, xfi->instance, xfi->orig_width * xfi->scale, xfi->orig_height * xfi->scale);
printf("-5 ");
}
else if(zoom < 0.5 && scale_cnt == 1)
{
//zoom out an other level
xfi->scale -= 0.05;
scale_cnt++;
XResizeWindow(xfi->display, xfi->window->handle, xfi->orig_width * xfi->scale, xfi->orig_height * xfi->scale);
IFCALL(xfi->client->OnResizeWindow, xfi->instance, xfi->orig_width * xfi->scale, xfi->orig_height * xfi->scale);
printf("-5 ");
}
if(zoom > 1.25 && scale_cnt == 0)
{
//zoom out one level
xfi->scale += 0.05;
scale_cnt++;
XResizeWindow(xfi->display, xfi->window->handle, xfi->orig_width * xfi->scale, xfi->orig_height * xfi->scale);
IFCALL(xfi->client->OnResizeWindow, xfi->instance, xfi->orig_width * xfi->scale, xfi->orig_height * xfi->scale);
printf("+5 ");
}
else if(zoom < 1.5 && scale_cnt == 1)
{
//zoom out an other level
xfi->scale += 0.05;
scale_cnt++;
XResizeWindow(xfi->display, xfi->window->handle, xfi->orig_width * xfi->scale, xfi->orig_height * xfi->scale);
IFCALL(xfi->client->OnResizeWindow, xfi->instance, xfi->orig_width * xfi->scale, xfi->orig_height * xfi->scale);
printf("+5 ");
}
}
}
#endif
void xf_input_init(xfInfo* xfi)
void xf_input_init(xfInfo* xfi, Window win)
{
#ifdef WITH_XI
int opcode, event, error;
@@ -134,7 +180,8 @@ void xf_input_init(xfInfo* xfi)
XISetMask(mask, XI_TouchUpdate);
XISetMask(mask, XI_TouchEnd);
error = XISelectEvents(xfi->display, xfi->window->handle, &eventmask, 1);
error = XISelectEvents(xfi->display, win, &eventmask, 1);
switch (error)
{
@@ -265,7 +312,7 @@ void xf_input_touch_update(xfInfo* xfi, XIDeviceEvent* event)
contacts[i].pos_y = event->event_y;
//detect pinch-zoom
xf_input_detect_pinch();
xf_input_detect_pinch(xfi);
break;
}

View File

@@ -27,7 +27,7 @@
#include <X11/extensions/XInput2.h>
#endif
void xf_input_init(xfInfo* xfi);//rdpContext* context);
void xf_input_init(xfInfo* xfi, Window win);//rdpContext* context);
void xf_input_handle_event(xfInfo* xfi, XEvent* event);
#ifdef WITH_XI

View File

@@ -414,7 +414,7 @@ BOOL xf_process_x_events(freerdp* instance)
if (initialized_xi == 0)
{
initialized_xi++;
xf_input_init(xfi);
//xf_input_init(xfi);
}
status = TRUE;
@@ -1171,7 +1171,7 @@ void* xf_input_thread(void* arg)
xfi = ((xfContext*) instance->context)->xfi;
xf_input_init(xfi);
//xf_input_init(xfi);
event = CreateFileDescriptorEvent(NULL, FALSE, FALSE, xfi->xfds);

View File

@@ -44,6 +44,7 @@
#ifdef WITH_XI
#include <X11/extensions/XInput2.h>
#include "xf_input.h"
#endif
#ifdef WITH_DEBUG_X11
@@ -412,7 +413,7 @@ xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height,
XMapWindow(xfi->display, window->handle);
#ifdef WITH_XI
xf_input_init(xfi, window->handle);
xf_input_init(xfi, settings->ParentWindowId);//window->handle);
#endif
/*
* NOTE: This must be done here to handle reparenting the window,