FreeRDP
Loading...
Searching...
No Matches
window_info_service.h File Reference
#include <freerdp/api.h>
#include <freerdp/wts_services.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  WINDOW_INFO_SOURCE
 what the client gives the service to answer from More...
 

Functions

WINPR_ATTR_NODISCARD FREERDP_API IWTSWindowInfoService * freerdp_client_window_info_service_new (const WINDOW_INFO_SOURCE *source)
 a new service (one reference for the caller) answering from source, which is copied
 
FREERDP_API void freerdp_client_window_info_service_changed (IWTSWindowInfoService *service, UINT64 remoteHwnd)
 a window changed (moved, resized, scaled, shown or hidden): the subscriber gets its new WTS_WINDOW_INFO (remoteHwnd: the remote window in a RemoteApp session, 0 for the desktop). Calls the subscriber on the calling thread.
 
FREERDP_API void freerdp_client_window_info_service_detach (IWTSWindowInfoService *service)
 stops using source: from now on the service answers E_UNEXPECTED. To call before what source uses goes, since channels and plugins may keep the service.
 

Detailed Description

FreeRDP: A Remote Desktop Protocol Implementation IWTSWindowInfoService for clients

Copyright 2026 David Fort conta.nosp@m.ct@h.nosp@m.arden.nosp@m.ing-.nosp@m.consu.nosp@m.ltin.nosp@m.g.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.

The IWTSWindowInfoService a client puts in rdpContext::windowInfoService, with Microsoft's behaviour (one subscriber, synchronous Subscribe/Unsubscribe, OnWindowChanged given a copy of the new WTS_WINDOW_INFO, GetProcessId the client's process). The client only tells where its windows are.

WINDOW_INFO_SOURCE source = { me, get_window_info, get_session_type }; context->windowInfoService = freerdp_client_window_info_service_new(&source); ... // each time a window moves, resizes or changes scale: freerdp_client_window_info_service_changed(context->windowInfoService, 0); ... // in ContextFree, before me goes: freerdp_client_window_info_service_detach(context->windowInfoService); WINPR_COM_RELEASE(context->windowInfoService); context->windowInfoService = nullptr;

Since
version 3.34.0

Definition in file window_info_service.h.

Function Documentation

◆ freerdp_client_window_info_service_changed()

FREERDP_API void freerdp_client_window_info_service_changed ( IWTSWindowInfoService *  service,
UINT64  remoteHwnd 
)

a window changed (moved, resized, scaled, shown or hidden): the subscriber gets its new WTS_WINDOW_INFO (remoteHwnd: the remote window in a RemoteApp session, 0 for the desktop). Calls the subscriber on the calling thread.

Since
version 3.34.0

Definition at line 178 of file window_info_service.c.

179{
180 CWindowInfoService* s = (CWindowInfoService*)service;
181 if (!s)
182 return;
183
184 WTS_WINDOW_INFO info = WINPR_C_ARRAY_INIT;
185 IWTSWindowChangedCallback* callback = nullptr;
186 EnterCriticalSection(&s->lock);
187 const WINDOW_INFO_SOURCE* src = source_locked(s);
188 if (src && s->subscriber && SUCCEEDED(src->GetWindowInfo(src->custom, remoteHwnd, &info)))
189 {
190 callback = s->subscriber;
191 WINPR_COM_ADDREF(callback);
192 }
193 LeaveCriticalSection(&s->lock);
194
195 if (!callback)
196 return;
197 /* outside the lock: the subscriber may call the service back */
198 const HRESULT hr = callback->lpVtbl->OnWindowChanged(callback, &info);
199 if (FAILED(hr))
200 WLog_DBG(TAG, "OnWindowChanged failed: 0x%08" PRIX32, (UINT32)hr);
201 WINPR_COM_RELEASE(callback);
202}
what the client gives the service to answer from
40 bytes on x64

◆ freerdp_client_window_info_service_detach()

FREERDP_API void freerdp_client_window_info_service_detach ( IWTSWindowInfoService *  service)

stops using source: from now on the service answers E_UNEXPECTED. To call before what source uses goes, since channels and plugins may keep the service.

Since
version 3.34.0

Definition at line 204 of file window_info_service.c.

205{
206 CWindowInfoService* s = (CWindowInfoService*)service;
207 if (!s)
208 return;
209 EnterCriticalSection(&s->lock);
210 s->detached = TRUE;
211 LeaveCriticalSection(&s->lock);
212}

◆ freerdp_client_window_info_service_new()

WINPR_ATTR_NODISCARD FREERDP_API IWTSWindowInfoService * freerdp_client_window_info_service_new ( const WINDOW_INFO_SOURCE *  source)

a new service (one reference for the caller) answering from source, which is copied

Since
version 3.34.0

Definition at line 158 of file window_info_service.c.

159{
160 WINPR_ASSERT(source);
161 WINPR_ASSERT(source->GetWindowInfo);
162 WINPR_ASSERT(source->GetSessionType);
163
164 CWindowInfoService* s = calloc(1, sizeof(*s));
165 if (!s)
166 return nullptr;
167 if (!InitializeCriticalSectionAndSpinCount(&s->lock, 4000))
168 {
169 free(s);
170 return nullptr;
171 }
172 winpr_com_base_init(&s->com, "CWindowInfoService", &CWindowInfoService_vtbl.iunknown,
173 CWindowInfoService_free);
174 s->source = *source;
175 return (IWTSWindowInfoService*)s;
176}
WINPR_API void winpr_com_base_init(wComBase *object, const char *className, const wIUnknownVtbl *vtbl, pfnwComBaseFree Free)
sets the vtable and the reference count to 1, the caller owns that first reference.
Definition com.c:30
UINT32(* GetSessionType)(void *custom)
a WTS_RDP_SESSION_TYPE. Called from any thread.
HRESULT(* GetWindowInfo)(void *custom, UINT64 remoteHwnd, WTS_WINDOW_INFO *info)
fills info as Microsoft's client does (see WTS_WINDOW_INFO): for a desktop session the window showing...

References WINDOW_INFO_SOURCE::GetSessionType, WINDOW_INFO_SOURCE::GetWindowInfo, and winpr_com_base_init().

Here is the call graph for this function: