mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
win_fix_multi_tab: refactor clipboard on windows, monitor ready mid commit
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
@@ -20,6 +20,7 @@ pub mod cliprdr;
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(tag = "t", content = "c")]
|
||||
pub enum ClipbaordFile {
|
||||
MonitorReady,
|
||||
FormatList {
|
||||
format_list: Vec<(i32, String)>,
|
||||
},
|
||||
@@ -152,6 +153,12 @@ pub fn server_clip_file(
|
||||
msg: ClipbaordFile,
|
||||
) -> u32 {
|
||||
match msg {
|
||||
ClipbaordFile::MonitorReady => {
|
||||
log::debug!("server_monitor_ready called");
|
||||
let ret = server_monitor_ready(context, conn_id);
|
||||
log::debug!("server_monitor_ready called, return {}", ret);
|
||||
ret
|
||||
}
|
||||
ClipbaordFile::FormatList { format_list } => {
|
||||
log::debug!("server_format_list called");
|
||||
let ret = server_format_list(context, conn_id, format_list);
|
||||
@@ -226,6 +233,19 @@ pub fn server_clip_file(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn server_monitor_ready(context: &mut Box<CliprdrClientContext>, conn_id: i32) -> u32 {
|
||||
unsafe {
|
||||
let monitor_ready = CLIPRDR_MONITOR_READY {
|
||||
connID: conn_id as UINT32,
|
||||
msgType: 0 as UINT16,
|
||||
msgFlags: 0 as UINT16,
|
||||
dataLen: 0 as UINT32,
|
||||
};
|
||||
let ret = ((**context).MonitorReady.unwrap())(&mut (**context), &monitor_ready);
|
||||
ret as u32
|
||||
}
|
||||
}
|
||||
|
||||
pub fn server_format_list(
|
||||
context: &mut Box<CliprdrClientContext>,
|
||||
conn_id: i32,
|
||||
@@ -441,7 +461,7 @@ extern "C" fn client_format_list(
|
||||
) -> UINT {
|
||||
log::debug!("client_format_list called");
|
||||
|
||||
// let conn_id;
|
||||
let conn_id;
|
||||
let mut format_list: Vec<(i32, String)> = Vec::new();
|
||||
unsafe {
|
||||
let mut i = 0u32;
|
||||
@@ -463,15 +483,19 @@ extern "C" fn client_format_list(
|
||||
// log::debug!("format list item {}: format id: {}, format name: {}", i, format_data.formatId, &format_name);
|
||||
i += 1;
|
||||
}
|
||||
// conn_id = (*clip_format_list).connID as i32;
|
||||
conn_id = (*clip_format_list).connID as i32;
|
||||
}
|
||||
let data = ClipbaordFile::FormatList { format_list };
|
||||
// no need to handle result here
|
||||
VEC_MSG_CHANNEL
|
||||
.read()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.for_each(|msg_channel| allow_err!(msg_channel.sender.send(data.clone())));
|
||||
if conn_id == 0 {
|
||||
VEC_MSG_CHANNEL
|
||||
.read()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.for_each(|msg_channel| allow_err!(msg_channel.sender.send(data.clone())));
|
||||
} else {
|
||||
send_data(conn_id, data);
|
||||
}
|
||||
|
||||
0
|
||||
}
|
||||
|
||||
@@ -1348,7 +1348,7 @@ static BOOL cliprdr_GetUpdatedClipboardFormats(wfClipboard *clipboard, PUINT lpu
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static UINT cliprdr_send_format_list(wfClipboard *clipboard)
|
||||
static UINT cliprdr_send_format_list(wfClipboard *clipboard, UINT32 connID)
|
||||
{
|
||||
UINT rc;
|
||||
int count = 0;
|
||||
@@ -1423,7 +1423,7 @@ static UINT cliprdr_send_format_list(wfClipboard *clipboard)
|
||||
}
|
||||
}
|
||||
|
||||
formatList.connID = 0;
|
||||
formatList.connID = connID;
|
||||
formatList.numFormats = numFormats;
|
||||
formatList.formats = formats;
|
||||
formatList.msgType = CB_FORMAT_LIST;
|
||||
@@ -1653,7 +1653,7 @@ static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM
|
||||
clipboard->hmem = NULL;
|
||||
}
|
||||
|
||||
cliprdr_send_format_list(clipboard);
|
||||
cliprdr_send_format_list(clipboard, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1704,7 +1704,7 @@ static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM
|
||||
if ((GetClipboardOwner() != clipboard->hwnd) &&
|
||||
(S_FALSE == OleIsCurrentClipboard(clipboard->data_obj)))
|
||||
{
|
||||
cliprdr_send_format_list(clipboard);
|
||||
cliprdr_send_format_list(clipboard, 0);
|
||||
}
|
||||
|
||||
SendMessage(clipboard->hWndNextViewer, Msg, wParam, lParam);
|
||||
@@ -2137,9 +2137,14 @@ static UINT wf_cliprdr_send_client_capabilities(wfClipboard *clipboard)
|
||||
CLIPRDR_CAPABILITIES capabilities;
|
||||
CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet;
|
||||
|
||||
if (!clipboard || !clipboard->context || !clipboard->context->ClientCapabilities)
|
||||
if (!clipboard || !clipboard->context)
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
|
||||
// Ignore ClientCapabilities for now
|
||||
if (!clipboard->context->ClientCapabilities) {
|
||||
return CHANNEL_RC_OK;
|
||||
}
|
||||
|
||||
capabilities.connID = 0;
|
||||
capabilities.cCapabilitiesSets = 1;
|
||||
capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET *)&(generalCapabilitySet);
|
||||
@@ -2171,7 +2176,7 @@ static UINT wf_cliprdr_monitor_ready(CliprdrClientContext *context,
|
||||
if (rc != CHANNEL_RC_OK)
|
||||
return rc;
|
||||
|
||||
return cliprdr_send_format_list(clipboard);
|
||||
return cliprdr_send_format_list(clipboard, monitorReady->connID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user