2011-08-16 07:37:43 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-08-16 07:37:43 +04:00
|
|
|
* RAIL Window List
|
|
|
|
*
|
|
|
|
* Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:09:01 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-11-22 04:22:41 +04:00
|
|
|
#include <winpr/crt.h>
|
|
|
|
|
2013-03-22 00:45:25 +04:00
|
|
|
#include <winpr/stream.h>
|
2011-08-16 07:37:43 +04:00
|
|
|
|
2011-09-02 21:29:17 +04:00
|
|
|
#include "librail.h"
|
|
|
|
|
2011-08-16 07:37:43 +04:00
|
|
|
#include <freerdp/rail/window_list.h>
|
|
|
|
|
2011-08-17 10:14:02 +04:00
|
|
|
void window_list_rewind(rdpWindowList* list)
|
|
|
|
{
|
|
|
|
list->iterator = list->head;
|
|
|
|
}
|
|
|
|
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL window_list_has_next(rdpWindowList* list)
|
2011-08-17 10:14:02 +04:00
|
|
|
{
|
|
|
|
if (list->iterator != NULL)
|
|
|
|
{
|
2014-03-05 16:55:22 +04:00
|
|
|
if (list->iterator->next != NULL)
|
2012-10-09 10:31:28 +04:00
|
|
|
return TRUE;
|
2011-08-17 10:14:02 +04:00
|
|
|
}
|
|
|
|
|
2012-10-09 10:31:28 +04:00
|
|
|
return FALSE;
|
2011-08-17 10:14:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
rdpWindow* window_list_get_next(rdpWindowList* list)
|
|
|
|
{
|
|
|
|
rdpWindow* next = NULL;
|
|
|
|
|
|
|
|
if (list->iterator != NULL)
|
|
|
|
{
|
|
|
|
next = list->iterator;
|
|
|
|
list->iterator = list->iterator->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return next;
|
|
|
|
}
|
|
|
|
|
2011-08-18 00:45:09 +04:00
|
|
|
rdpWindow* window_list_get_by_extra_id(rdpWindowList* list, void* extraId)
|
|
|
|
{
|
|
|
|
rdpWindow* window;
|
|
|
|
|
|
|
|
window = list->head;
|
|
|
|
|
|
|
|
if (window == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2011-08-18 07:46:08 +04:00
|
|
|
while (window != NULL)
|
2011-08-18 00:45:09 +04:00
|
|
|
{
|
|
|
|
if (window->extraId == extraId)
|
|
|
|
return window;
|
|
|
|
|
|
|
|
window = window->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-10-09 11:26:39 +04:00
|
|
|
rdpWindow* window_list_get_by_id(rdpWindowList* list, UINT32 windowId)
|
2011-08-16 07:37:43 +04:00
|
|
|
{
|
|
|
|
rdpWindow* window;
|
|
|
|
|
|
|
|
window = list->head;
|
|
|
|
|
|
|
|
if (window == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2011-08-18 06:31:27 +04:00
|
|
|
while (window != NULL)
|
2011-08-16 07:37:43 +04:00
|
|
|
{
|
|
|
|
if (window->windowId == windowId)
|
|
|
|
return window;
|
|
|
|
|
|
|
|
window = window->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void window_list_create(rdpWindowList* list, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* window_state)
|
|
|
|
{
|
|
|
|
rdpWindow* window;
|
|
|
|
|
2012-08-15 01:09:01 +04:00
|
|
|
/* See if the window already exists */
|
2012-08-04 02:35:17 +04:00
|
|
|
window = window_list_get_by_id(list, orderInfo->windowId);
|
|
|
|
|
2012-08-15 01:09:01 +04:00
|
|
|
/* If the window already exists, just update the existing window */
|
2012-08-04 02:35:17 +04:00
|
|
|
if (window != NULL)
|
|
|
|
{
|
|
|
|
window_list_update(list, orderInfo, window_state);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-22 04:22:41 +04:00
|
|
|
window = (rdpWindow*) malloc(sizeof(rdpWindow));
|
2011-08-17 10:14:02 +04:00
|
|
|
|
|
|
|
if (window == NULL)
|
|
|
|
return;
|
|
|
|
|
2012-11-22 04:22:41 +04:00
|
|
|
ZeroMemory(window, sizeof(rdpWindow));
|
|
|
|
|
2011-08-17 10:14:02 +04:00
|
|
|
window->windowId = orderInfo->windowId;
|
2011-08-16 07:37:43 +04:00
|
|
|
|
|
|
|
if (list->head == NULL)
|
|
|
|
{
|
|
|
|
list->head = list->tail = window;
|
|
|
|
window->prev = NULL;
|
|
|
|
window->next = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
window->prev = list->tail;
|
2011-08-17 22:51:17 +04:00
|
|
|
list->tail->next = window;
|
2011-08-16 07:37:43 +04:00
|
|
|
window->next = NULL;
|
|
|
|
list->tail = window;
|
|
|
|
}
|
|
|
|
|
|
|
|
window->windowId = orderInfo->windowId;
|
2011-08-16 08:22:00 +04:00
|
|
|
|
|
|
|
window_state_update(window, orderInfo, window_state);
|
2011-08-17 10:14:02 +04:00
|
|
|
|
|
|
|
rail_CreateWindow(list->rail, window);
|
2011-08-16 07:37:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void window_list_update(rdpWindowList* list, WINDOW_ORDER_INFO* orderInfo, WINDOW_STATE_ORDER* window_state)
|
|
|
|
{
|
|
|
|
rdpWindow* window;
|
|
|
|
|
|
|
|
window = window_list_get_by_id(list, orderInfo->windowId);
|
|
|
|
|
|
|
|
if (window == NULL)
|
|
|
|
return;
|
2011-08-16 08:22:00 +04:00
|
|
|
|
|
|
|
window_state_update(window, orderInfo, window_state);
|
2011-08-18 06:50:49 +04:00
|
|
|
|
|
|
|
rail_UpdateWindow(list->rail, window);
|
2011-08-16 07:37:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void window_list_delete(rdpWindowList* list, WINDOW_ORDER_INFO* orderInfo)
|
|
|
|
{
|
|
|
|
rdpWindow* prev;
|
|
|
|
rdpWindow* next;
|
|
|
|
rdpWindow* window;
|
|
|
|
|
|
|
|
window = window_list_get_by_id(list, orderInfo->windowId);
|
|
|
|
|
2011-08-16 08:22:00 +04:00
|
|
|
if (window == NULL)
|
|
|
|
return;
|
|
|
|
|
2011-08-16 07:37:43 +04:00
|
|
|
prev = window->prev;
|
|
|
|
next = window->next;
|
|
|
|
|
|
|
|
if (prev != NULL)
|
|
|
|
prev->next = next;
|
|
|
|
|
|
|
|
if (next != NULL)
|
|
|
|
next->prev = prev;
|
|
|
|
|
|
|
|
if (list->head == list->tail)
|
|
|
|
{
|
|
|
|
list->head = list->tail = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (list->head == window)
|
|
|
|
list->head = next;
|
|
|
|
|
|
|
|
if (list->tail == window)
|
|
|
|
list->tail = prev;
|
|
|
|
}
|
|
|
|
|
2011-08-17 10:14:02 +04:00
|
|
|
rail_DestroyWindow(list->rail, window);
|
2011-08-16 07:37:43 +04:00
|
|
|
}
|
|
|
|
|
2012-08-04 02:35:17 +04:00
|
|
|
void window_list_clear(rdpWindowList* list)
|
|
|
|
{
|
|
|
|
rdpWindow* current = list->head;
|
|
|
|
|
|
|
|
while (current != NULL)
|
|
|
|
{
|
|
|
|
list->head = current->next;
|
|
|
|
rail_DestroyWindow(list->rail, current);
|
|
|
|
current = list->head;
|
|
|
|
}
|
|
|
|
|
|
|
|
list->tail = NULL;
|
|
|
|
}
|
|
|
|
|
2011-08-17 10:14:02 +04:00
|
|
|
rdpWindowList* window_list_new(rdpRail* rail)
|
2011-08-16 07:37:43 +04:00
|
|
|
{
|
|
|
|
rdpWindowList* list;
|
|
|
|
|
2012-11-22 04:22:41 +04:00
|
|
|
list = (rdpWindowList*) malloc(sizeof(rdpWindowList));
|
2011-08-16 07:37:43 +04:00
|
|
|
|
|
|
|
if (list != NULL)
|
|
|
|
{
|
2012-11-22 04:22:41 +04:00
|
|
|
ZeroMemory(list, sizeof(rdpWindowList));
|
|
|
|
|
2011-08-16 07:37:43 +04:00
|
|
|
list->head = NULL;
|
|
|
|
list->tail = NULL;
|
2011-08-17 10:14:02 +04:00
|
|
|
list->rail = rail;
|
2011-08-16 07:37:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
void window_list_free(rdpWindowList* list)
|
|
|
|
{
|
|
|
|
if (list != NULL)
|
|
|
|
{
|
2012-10-09 07:21:26 +04:00
|
|
|
free(list);
|
2011-08-16 07:37:43 +04:00
|
|
|
}
|
|
|
|
}
|