[client] windows: implement native clipboard support

Add Win32 clipboard ownership, notifications, and data exchange for
text and image formats. Marshal clipboard access onto the window thread
and reject stale transfers when ownership changes.

Keep file clipboard offers unsupported while clearing stale content from
earlier remote offers.
This commit is contained in:
Geoffrey McRae
2026-10-03 11:53:10 +10:00
parent 7f63dc986e
commit 1a4b6049bd
4 changed files with 1255 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.10)
project(displayserver_Windows LANGUAGES C) project(displayserver_Windows LANGUAGES C)
add_library(displayserver_Windows STATIC add_library(displayserver_Windows STATIC
clipboard.c
input_event.c input_event.c
window_size.c window_size.c
windows.c windows.c

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,42 @@
/**
* Looking Glass
* Copyright © 2017-2026 The Looking Glass Authors
* https://looking-glass.io
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _H_WINDOWSDS_CLIPBOARD_
#define _H_WINDOWSDS_CLIPBOARD_
#include <stdbool.h>
#include <windows.h>
#include "interface/displayserver.h"
bool windowsCBHandleMessage(HWND window, UINT message,
WPARAM wParam, LPARAM lParam, LRESULT * result);
void windowsCBEventShutdown(void);
bool windowsCBInit(void);
void windowsCBNotice(LG_ClipboardData type);
void windowsCBRelease(void);
void windowsCBRequest(LG_ClipboardRequest request, LG_ClipboardData type);
void windowsCBRequestReady(LG_ClipboardRequest request);
void windowsCBRequestCancel(LG_ClipboardRequest request,
LG_ClipboardCancelReason reason);
#endif

View File

@@ -54,6 +54,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "clipboard.h"
#define LG_WINDOW_CLASS L"LookingGlassClientWindow" #define LG_WINDOW_CLASS L"LookingGlassClientWindow"
enum WindowsMessage enum WindowsMessage
@@ -849,6 +851,7 @@ static LRESULT handleCustomMessage(UINT message, WPARAM wParam,
switch (message) switch (message)
{ {
case WM_LG_SHUTDOWN: case WM_LG_SHUTDOWN:
windowsCBEventShutdown();
eventSourceFree(); eventSourceFree();
setKeyboardGrab(false); setKeyboardGrab(false);
setPointerGrab(false, false); setPointerGrab(false, false);
@@ -930,6 +933,11 @@ static LRESULT handleCustomMessage(UINT message, WPARAM wParam,
static LRESULT CALLBACK windowProc(HWND window, UINT message, static LRESULT CALLBACK windowProc(HWND window, UINT message,
WPARAM wParam, LPARAM lParam) WPARAM wParam, LPARAM lParam)
{ {
LRESULT clipboardResult;
if (windowsCBHandleMessage(
window, message, wParam, lParam, &clipboardResult))
return clipboardResult;
if (message >= WM_LG_SHUTDOWN && message <= WM_LG_EVENT_SOURCE) if (message >= WM_LG_SHUTDOWN && message <= WM_LG_EVENT_SOURCE)
return handleCustomMessage(message, wParam, lParam); return handleCustomMessage(message, wParam, lParam);
@@ -1887,4 +1895,10 @@ struct LG_DisplayServerOps LGDS_Windows =
.getFullscreen = windowsGetFullscreen, .getFullscreen = windowsGetFullscreen,
.setFullscreen = windowsSetFullscreen, .setFullscreen = windowsSetFullscreen,
.minimize = windowsMinimize, .minimize = windowsMinimize,
.cbInit = windowsCBInit,
.cbNotice = windowsCBNotice,
.cbRelease = windowsCBRelease,
.cbRequest = windowsCBRequest,
.cbRequestReady = windowsCBRequestReady,
.cbRequestCancel = windowsCBRequestCancel,
}; };