[client,x11] refactor headers

* Use a forward definition in xf_types.h for xfContext
* Resolve circular dependencies on xfreerdp.h
This commit is contained in:
Armin Novak
2026-02-09 19:01:48 +01:00
parent d3e8b3b936
commit 2679cf6bf8
11 changed files with 168 additions and 127 deletions

View File

@@ -40,6 +40,7 @@ include_directories(SYSTEM ${X11_INCLUDE_DIRS})
include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR})
set(SRCS
xf_types.h
xf_utils.h
xf_utils.c
xf_x11_utils.c

View File

@@ -20,11 +20,15 @@
#ifndef FREERDP_CLIENT_X11_CLIPRDR_H
#define FREERDP_CLIENT_X11_CLIPRDR_H
#include "xf_client.h"
#include "xfreerdp.h"
#include <freerdp/types.h>
#include <freerdp/client/cliprdr.h>
#include <X11/Xlib.h>
#include "xf_types.h"
typedef struct xf_clipboard xfClipboard;
void xf_clipboard_free(xfClipboard* clipboard);
WINPR_ATTR_MALLOC(xf_clipboard_free, 1)

View File

@@ -35,6 +35,7 @@
#endif
#include "xfreerdp.h"
#include "xf_disp.h"
#include "xf_monitor.h"

View File

@@ -22,8 +22,11 @@
#include <freerdp/types.h>
#include <freerdp/client/disp.h>
#include "xf_client.h"
#include "xfreerdp.h"
#include <X11/Xlib.h>
#include "xf_types.h"
typedef struct s_xfDispContext xfDispContext;
FREERDP_API BOOL xf_disp_init(xfDispContext* xfDisp, DispClientContext* disp);
FREERDP_API BOOL xf_disp_uninit(xfDispContext* xfDisp, DispClientContext* disp);

View File

@@ -18,9 +18,13 @@
#ifndef FREERDP_CLIENT_X11_FLOATBAR_H
#define FREERDP_CLIENT_X11_FLOATBAR_H
typedef struct xf_floatbar xfFloatbar;
#include <winpr/wtypes.h>
#include "xfreerdp.h"
#include <X11/Xlib.h>
#include "xf_types.h"
typedef struct xf_floatbar xfFloatbar;
void xf_floatbar_free(xfFloatbar* floatbar);

View File

@@ -22,24 +22,9 @@
#include <freerdp/api.h>
#include <freerdp/freerdp.h>
#include <freerdp/types.h>
typedef struct
{
RECTANGLE_16 area;
RECTANGLE_16 workarea;
BOOL primary;
} MONITOR_INFO;
typedef struct
{
UINT32 nmonitors;
RECTANGLE_16 area;
RECTANGLE_16 workarea;
MONITOR_INFO* monitors;
} VIRTUAL_SCREEN;
#include "xf_client.h"
#include "xfreerdp.h"
#include "xf_types.h"
FREERDP_API int xf_list_monitors(xfContext* xfc);
FREERDP_API BOOL xf_detect_monitors(xfContext* xfc, UINT32* pWidth, UINT32* pHeight);

View File

@@ -20,11 +20,98 @@
#ifndef FREERDP_CLIENT_X11_RAIL_H
#define FREERDP_CLIENT_X11_RAIL_H
#include "xf_client.h"
#include "xfreerdp.h"
#include <freerdp/client/rail.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include "xf_types.h"
enum xf_localmove_state
{
LMS_NOT_ACTIVE,
LMS_STARTING,
LMS_ACTIVE,
LMS_TERMINATING
};
struct xf_localmove
{
int root_x;
int root_y;
int window_x;
int window_y;
enum xf_localmove_state state;
int direction;
};
typedef struct xf_localmove xfLocalMove;
struct xf_app_window
{
xfContext* xfc;
int x;
int y;
int width;
int height;
char* title;
UINT32 surfaceId;
UINT64 windowId;
UINT32 ownerWindowId;
UINT32 dwStyle;
UINT32 dwExStyle;
UINT32 showState;
INT32 clientOffsetX;
INT32 clientOffsetY;
UINT32 clientAreaWidth;
UINT32 clientAreaHeight;
INT32 windowOffsetX;
INT32 windowOffsetY;
INT32 windowClientDeltaX;
INT32 windowClientDeltaY;
UINT32 windowWidth;
UINT32 windowHeight;
UINT32 numWindowRects;
RECTANGLE_16* windowRects;
INT32 visibleOffsetX;
INT32 visibleOffsetY;
UINT32 numVisibilityRects;
RECTANGLE_16* visibilityRects;
UINT32 localWindowOffsetCorrX;
UINT32 localWindowOffsetCorrY;
UINT32 resizeMarginLeft;
UINT32 resizeMarginTop;
UINT32 resizeMarginRight;
UINT32 resizeMarginBottom;
GC gc;
int shmid;
Window handle;
Window* xfwin;
BOOL fullscreen;
BOOL decorations;
BOOL is_mapped;
BOOL is_transient;
xfLocalMove local_move;
BYTE rail_state;
BOOL maxVert;
BOOL maxHorz;
BOOL minimized;
BOOL rail_ignore_configure;
Pixmap pixmap;
XImage* image;
};
typedef struct xf_app_window xfAppWindow;
typedef struct xf_rail_icon_cache xfRailIconCache;
BOOL xf_rail_paint(xfContext* xfc, const RECTANGLE_16* rect);
BOOL xf_rail_paint_surface(xfContext* xfc, UINT64 windowId, const RECTANGLE_16* rect);

42
client/X11/xf_types.h Normal file
View File

@@ -0,0 +1,42 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* X11 Client
*
* Copyright 2026 Thincast Technologies GmbH
* Copyright 2026 Armin Novak <armin.novak@thincast.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.
*/
#pragma once
#include <winpr/wtypes.h>
#include <freerdp/types.h>
/* Forward declarations */
typedef struct xf_context xfContext;
typedef struct
{
RECTANGLE_16 area;
RECTANGLE_16 workarea;
BOOL primary;
} MONITOR_INFO;
typedef struct
{
UINT32 nmonitors;
RECTANGLE_16 area;
RECTANGLE_16 workarea;
MONITOR_INFO* monitors;
} VIRTUAL_SCREEN;

View File

@@ -19,10 +19,11 @@
#ifndef CLIENT_X11_XF_VIDEO_H_
#define CLIENT_X11_XF_VIDEO_H_
#include "xfreerdp.h"
#include <freerdp/client/video.h>
#include <freerdp/channels/geometry.h>
#include <freerdp/channels/video.h>
#include "xf_types.h"
typedef struct s_xfVideoContext xfVideoContext;
void xf_video_control_init(xfContext* xfc, VideoClientContext* video);
void xf_video_control_uninit(xfContext* xfc, VideoClientContext* video);

View File

@@ -26,14 +26,11 @@
#include <freerdp/freerdp.h>
#include <freerdp/gdi/gfx.h>
typedef struct xf_app_window xfAppWindow;
typedef struct xf_localmove xfLocalMove;
typedef struct xf_window xfWindow;
#include "xf_client.h"
#include "xf_types.h"
#include "xf_rail.h"
#include "xf_floatbar.h"
#include "xfreerdp.h"
typedef struct xf_window xfWindow;
// Extended ICCM flags http://standards.freedesktop.org/wm-spec/wm-spec-latest.html
WINPR_PRAGMA_DIAG_PUSH
@@ -58,24 +55,6 @@ WINPR_PRAGMA_DIAG_IGNORED_RESERVED_ID_MACRO
WINPR_PRAGMA_DIAG_POP
enum xf_localmove_state
{
LMS_NOT_ACTIVE,
LMS_STARTING,
LMS_ACTIVE,
LMS_TERMINATING
};
struct xf_localmove
{
int root_x;
int root_y;
int window_x;
int window_y;
enum xf_localmove_state state;
int direction;
};
struct xf_window
{
GC gc;
@@ -94,70 +73,6 @@ struct xf_window
BOOL is_transient;
};
struct xf_app_window
{
xfContext* xfc;
int x;
int y;
int width;
int height;
char* title;
UINT32 surfaceId;
UINT64 windowId;
UINT32 ownerWindowId;
UINT32 dwStyle;
UINT32 dwExStyle;
UINT32 showState;
INT32 clientOffsetX;
INT32 clientOffsetY;
UINT32 clientAreaWidth;
UINT32 clientAreaHeight;
INT32 windowOffsetX;
INT32 windowOffsetY;
INT32 windowClientDeltaX;
INT32 windowClientDeltaY;
UINT32 windowWidth;
UINT32 windowHeight;
UINT32 numWindowRects;
RECTANGLE_16* windowRects;
INT32 visibleOffsetX;
INT32 visibleOffsetY;
UINT32 numVisibilityRects;
RECTANGLE_16* visibilityRects;
UINT32 localWindowOffsetCorrX;
UINT32 localWindowOffsetCorrY;
UINT32 resizeMarginLeft;
UINT32 resizeMarginTop;
UINT32 resizeMarginRight;
UINT32 resizeMarginBottom;
GC gc;
int shmid;
Window handle;
Window* xfwin;
BOOL fullscreen;
BOOL decorations;
BOOL is_mapped;
BOOL is_transient;
xfLocalMove local_move;
BYTE rail_state;
BOOL maxVert;
BOOL maxHorz;
BOOL minimized;
BOOL rail_ignore_configure;
Pixmap pixmap;
XImage* image;
};
void xf_ewmhints_init(xfContext* xfc);
BOOL xf_GetWorkArea(xfContext* xfc);
@@ -207,8 +122,6 @@ void xf_SetWindowMinMaxInfo(xfContext* xfc, xfAppWindow* appWindow, int maxWidth
void xf_StartLocalMoveSize(xfContext* xfc, xfAppWindow* appWindow, int direction, int x, int y);
void xf_EndLocalMoveSize(xfContext* xfc, xfAppWindow* appWindow);
void xf_rail_return_window(xfAppWindow* window);
WINPR_ATTR_MALLOC(xf_rail_return_window, 1)
xfAppWindow* xf_AppWindowFromX11Window(xfContext* xfc, Window wnd);

View File

@@ -24,7 +24,11 @@
#include <freerdp/config.h>
typedef struct xf_context xfContext;
#include "xf_types.h"
#include "xf_disp.h"
#include "xf_cliprdr.h"
#include "xf_video.h"
#include "xf_rail.h"
#ifdef WITH_XCURSOR
#include <X11/Xcursor/Xcursor.h>
@@ -54,6 +58,7 @@ typedef struct xf_context xfContext;
#include <freerdp/codec/progressive.h>
#include <freerdp/codec/region.h>
#include <freerdp/locale/keyboard.h>
#include <freerdp/client.h>
#if !defined(XcursorUInt)
typedef unsigned int XcursorUInt;
@@ -109,11 +114,6 @@ struct xf_glyph
};
typedef struct xf_glyph xfGlyph;
typedef struct xf_clipboard xfClipboard;
typedef struct s_xfDispContext xfDispContext;
typedef struct s_xfVideoContext xfVideoContext;
typedef struct xf_rail_icon_cache xfRailIconCache;
/* Number of buttons that are mapped from X11 to RDP button events. */
#define NUM_BUTTONS_MAPPED 11