Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ivan-83/FreeRDP
Browse files Browse the repository at this point in the history
  • Loading branch information
rozhuk-im committed Mar 12, 2015
2 parents 7b3a552 + abb9843 commit 9e7e4ce
Show file tree
Hide file tree
Showing 54 changed files with 1,378 additions and 768 deletions.
7 changes: 6 additions & 1 deletion channels/audin/client/winmm/audin_winmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,13 @@ static BOOL audin_winmm_format_supported(IAudinDevice* device, audinFormat* form
{
if (winmm->cFormats >= winmm->ppwfx_size)
{
PWAVEFORMATEX *tmp_ppwfx;
tmp_ppwfx = realloc(winmm->ppwfx, sizeof(PWAVEFORMATEX) * winmm->ppwfx_size * 2);
if (!tmp_ppwfx)
return 0;

winmm->ppwfx_size *= 2;
winmm->ppwfx = realloc(winmm->ppwfx, sizeof(PWAVEFORMATEX) * winmm->ppwfx_size);
winmm->ppwfx = tmp_ppwfx;
}
winmm->ppwfx[winmm->cFormats++] = pwfx;

Expand Down
23 changes: 19 additions & 4 deletions channels/rail/client/rail_orders.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,33 @@

static BOOL rail_read_unicode_string(wStream* s, RAIL_UNICODE_STRING* unicode_string)
{
UINT16 new_length;

if (Stream_GetRemainingLength(s) < 2)
return FALSE;

Stream_Read_UINT16(s, unicode_string->length); /* cbString (2 bytes) */
Stream_Read_UINT16(s, new_length); /* cbString (2 bytes) */

if (Stream_GetRemainingLength(s) < unicode_string->length)
if (Stream_GetRemainingLength(s) < new_length)
return FALSE;

if (!unicode_string->string)
unicode_string->string = (BYTE*) malloc(unicode_string->length);
{
unicode_string->string = (BYTE*) malloc(new_length);
if (!unicode_string->string)
return FALSE;
unicode_string->length = new_length;
}
else
unicode_string->string = (BYTE*) realloc(unicode_string->string, unicode_string->length);
{
BYTE *new_str;

new_str = (BYTE*) realloc(unicode_string->string, new_length);
if (!new_str)
return FALSE;
unicode_string->string = new_str;
unicode_string->length = new_length;
}

Stream_Read(s, unicode_string->string, unicode_string->length);

Expand Down
8 changes: 7 additions & 1 deletion channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,14 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE *data, UI
/* Ensure enough space for decoding */
if (mdecoder->decoded_size_max - mdecoder->decoded_size < MAX_AUDIO_FRAME_SIZE)
{
BYTE *tmp_data;

tmp_data = realloc(mdecoder->decoded_data, mdecoder->decoded_size_max * 2 + 16);
if (!tmp_data)
return FALSE;
mdecoder->decoded_size_max = mdecoder->decoded_size_max * 2 + 16;
mdecoder->decoded_data = realloc(mdecoder->decoded_data, mdecoder->decoded_size_max);
mdecoder->decoded_data = tmp_data;

dst = (BYTE *)(((uintptr_t)mdecoder->decoded_data + 15) & ~ 0x0F);
if (dst - mdecoder->decoded_data != dst_offset)
{
Expand Down
10 changes: 7 additions & 3 deletions channels/tsmf/client/tsmf_media.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ void tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation,
UINT32 index;
UINT32 count;
TSMF_STREAM* stream;
void *tmp_rects;

/* The server may send messages with invalid width / height.
* Ignore those messages. */
Expand All @@ -835,11 +836,14 @@ void tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation,
presentation->y = y;
presentation->width = width;
presentation->height = height;

tmp_rects = realloc(presentation->rects, sizeof(RDP_RECT) * num_rects);
if (!tmp_rects)
return;
presentation->nr_rects = num_rects;
presentation->rects = realloc(presentation->rects, sizeof(RDP_RECT) * num_rects);
presentation->rects = tmp_rects;

if (presentation->rects)
CopyMemory(presentation->rects, rects, sizeof(RDP_RECT) * num_rects);
CopyMemory(presentation->rects, rects, sizeof(RDP_RECT) * num_rects);

ArrayList_Lock(presentation->stream_list);
count = ArrayList_Count(presentation->stream_list);
Expand Down
13 changes: 10 additions & 3 deletions client/Android/FreeRDPCore/jni/android_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,16 @@ void android_push_event(freerdp * inst, ANDROID_EVENT* event)
androidContext* aCtx = (androidContext*)inst->context;
if (aCtx->event_queue->count >= aCtx->event_queue->size)
{
aCtx->event_queue->size = aCtx->event_queue->size * 2;
aCtx->event_queue->events = realloc((void*) aCtx->event_queue->events,
sizeof(ANDROID_EVENT*) * aCtx->event_queue->size);
int new_size;
int new_events;

new_size = aCtx->event_queue->size * 2;
new_events = realloc((void*) aCtx->event_queue->events,
sizeof(ANDROID_EVENT*) * new_size);
if (!new_events)
return;
aCtx->event_queue->events = new_events;
aCtx->event_queue->size = new_size;
}

aCtx->event_queue->events[(aCtx->event_queue->count)++] = event;
Expand Down
40 changes: 28 additions & 12 deletions client/Windows/wf_cliprdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -906,9 +906,15 @@ static void map_ensure_capacity(wfClipboard* clipboard)
{
if (clipboard->map_size >= clipboard->map_capacity)
{
clipboard->map_capacity *= 2;
clipboard->format_mappings = (formatMapping*) realloc(clipboard->format_mappings,
sizeof(formatMapping) * clipboard->map_capacity);
int new_size;
formatMapping *new_map;

new_map = (formatMapping*) realloc(clipboard->format_mappings,
sizeof(formatMapping) * new_size);
if (!new_map)
return;
clipboard->format_mappings = new_map;
clipboard->map_capacity = new_size;
}
}

Expand Down Expand Up @@ -1348,9 +1354,24 @@ static void wf_cliprdr_array_ensure_capacity(wfClipboard* clipboard)
{
if (clipboard->nFiles == clipboard->file_array_size)
{
clipboard->file_array_size *= 2;
clipboard->fileDescriptor = (FILEDESCRIPTORW**) realloc(clipboard->fileDescriptor, clipboard->file_array_size * sizeof(FILEDESCRIPTORW*));
clipboard->file_names = (WCHAR**) realloc(clipboard->file_names, clipboard->file_array_size * sizeof(WCHAR*));
int new_size;
FILEDESCRIPTORW **new_fd;
WCHAR **new_name;

new_size = clipboard->file_array_size * 2;

new_fd = (FILEDESCRIPTORW**) realloc(clipboard->fileDescriptor, new_size * sizeof(FILEDESCRIPTORW*));
if (new_fd)
clipboard->fileDescriptor = new_fd;

new_name = (WCHAR**) realloc(clipboard->file_names, new_size * sizeof(WCHAR*));
if (new_name)
clipboard->file_names = new_name;

if (!new_fd || !new_name)
return;

clipboard->file_array_size *= new_size;
}
}

Expand Down Expand Up @@ -1678,12 +1699,7 @@ static int wf_cliprdr_server_format_data_request(CliprdrClientContext* context,
clipboard->file_names[clipboard->nFiles] = (LPWSTR) malloc(cchWideChar * 2);
MultiByteToWideChar(CP_ACP, MB_COMPOSITE, p, len, clipboard->file_names[clipboard->nFiles], cchWideChar);

if (clipboard->nFiles == clipboard->file_array_size)
{
clipboard->file_array_size *= 2;
clipboard->fileDescriptor = (FILEDESCRIPTORW**) realloc(clipboard->fileDescriptor, clipboard->file_array_size * sizeof(FILEDESCRIPTORW*));
clipboard->file_names = (WCHAR**) realloc(clipboard->file_names, clipboard->file_array_size * sizeof(WCHAR*));
}
map_ensure_capacity(clipboard);
}
}

Expand Down
19 changes: 10 additions & 9 deletions client/X11/xf_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ BOOL xf_create_window(xfContext* xfc)
xfc->attribs.background_pixel = BlackPixelOfScreen(xfc->screen);
xfc->attribs.border_pixel = WhitePixelOfScreen(xfc->screen);
xfc->attribs.backing_store = xfc->primary ? NotUseful : Always;
xfc->attribs.override_redirect = xfc->grab_keyboard ? xfc->fullscreen : False;
xfc->attribs.override_redirect = False;
xfc->attribs.colormap = xfc->colormap;
xfc->attribs.bit_gravity = NorthWestGravity;
xfc->attribs.win_gravity = NorthWestGravity;
Expand Down Expand Up @@ -571,14 +571,18 @@ BOOL xf_create_window(xfContext* xfc)
}
#endif

xfc->window = xf_CreateDesktopWindow(xfc, windowTitle, width, height, xfc->decorations);
xfc->window = xf_CreateDesktopWindow(xfc, windowTitle, width, height);

free(windowTitle);

if (xfc->fullscreen)
xf_SetWindowFullscreen(xfc, xfc->window, xfc->fullscreen);

xfc->unobscured = (xevent.xvisibility.state == VisibilityUnobscured);

/* Disallow resize now that any initial fullscreen window operation is complete */
xf_SetWindowSizeHints(xfc, xfc->window, FALSE, xfc->width, xfc->height);

XSetWMProtocols(xfc->display, xfc->window->handle, &(xfc->WM_DELETE_WINDOW), 1);
xfc->drawable = xfc->window->handle;
}
Expand Down Expand Up @@ -686,16 +690,12 @@ void xf_toggle_fullscreen(xfContext* xfc)
rdpContext* context = (rdpContext*) xfc;
rdpSettings* settings = context->settings;

xf_lock_x11(xfc, TRUE);

xf_window_free(xfc);

xfc->fullscreen = (xfc->fullscreen) ? FALSE : TRUE;
xfc->decorations = (xfc->fullscreen) ? FALSE : settings->Decorations;

xf_create_window(xfc);

xf_unlock_x11(xfc, TRUE);
xf_SetWindowSizeHints(xfc, xfc->window, TRUE, xfc->width, xfc->height);
xf_SetWindowFullscreen(xfc, xfc->window, xfc->fullscreen);
xf_SetWindowSizeHints(xfc, xfc->window, FALSE, xfc->width, xfc->height);

EventArgsInit(&e, "xfreerdp");
e.state = xfc->fullscreen ? FREERDP_WINDOW_STATE_FULLSCREEN : 0;
Expand Down Expand Up @@ -1697,6 +1697,7 @@ static int xfreerdp_client_new(freerdp* instance, rdpContext* context)
xfc->_NET_WORKAREA = XInternAtom(xfc->display, "_NET_WORKAREA", False);
xfc->_NET_WM_STATE = XInternAtom(xfc->display, "_NET_WM_STATE", False);
xfc->_NET_WM_STATE_FULLSCREEN = XInternAtom(xfc->display, "_NET_WM_STATE_FULLSCREEN", False);
xfc->_NET_WM_FULLSCREEN_MONITORS = XInternAtom(xfc->display, "_NET_WM_FULLSCREEN_MONITORS", False);
xfc->_NET_WM_WINDOW_TYPE = XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE", False);
xfc->_NET_WM_WINDOW_TYPE_NORMAL = XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_NORMAL", False);
xfc->_NET_WM_WINDOW_TYPE_DIALOG = XInternAtom(xfc->display, "_NET_WM_WINDOW_TYPE_DIALOG", False);
Expand Down
7 changes: 6 additions & 1 deletion client/X11/xf_cliprdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,13 @@ static BOOL xf_cliprdr_get_requested_data(xfClipboard* clipboard, Atom target)
{
if (clipboard->incr_starts)
{
BYTE *new_data;

bytes_left = length * format_property / 8;
clipboard->incr_data = (BYTE*) realloc(clipboard->incr_data, clipboard->incr_data_length + bytes_left);
new_data = (BYTE*) realloc(clipboard->incr_data, clipboard->incr_data_length + bytes_left);
if (!new_data)
return FALSE;
clipboard->incr_data = new_data;
CopyMemory(clipboard->incr_data + clipboard->incr_data_length, data, bytes_left);
clipboard->incr_data_length += bytes_left;
XFree(data);
Expand Down
1 change: 1 addition & 0 deletions client/X11/xf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ static BOOL xf_event_FocusOut(xfContext* xfc, XEvent* event, BOOL app)
if (event->xfocus.mode == NotifyWhileGrabbed)
XUngrabKeyboard(xfc->display, CurrentTime);

xf_keyboard_release_all_keypress(xfc);
xf_keyboard_clear(xfc);

if (app)
Expand Down
6 changes: 6 additions & 0 deletions client/X11/xf_keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ void xf_keyboard_release_all_keypress(xfContext* xfc)
if (xfc->KeyboardState[keycode] != NoSymbol)
{
rdp_scancode = freerdp_keyboard_get_rdp_scancode_from_x11_keycode(keycode);

// release tab before releasing the windows key.
// this stops the start menu from opening on unfocus event.
if (rdp_scancode == RDP_SCANCODE_LWIN)
freerdp_input_send_keyboard_event_ex(xfc->instance->input, FALSE, RDP_SCANCODE_TAB);

freerdp_input_send_keyboard_event_ex(xfc->instance->input, FALSE, rdp_scancode);
xfc->KeyboardState[keycode] = NoSymbol;
}
Expand Down
Loading

0 comments on commit 9e7e4ce

Please sign in to comment.