check IsClipboardFormatAvailable(CF_HDROP) on clipboard update

Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
dignow 2023-07-30 16:42:39 +08:00
parent 69f1969e60
commit ac743ca2fe
2 changed files with 46 additions and 30 deletions

View File

@ -181,32 +181,37 @@ pub fn server_clip_file(
ClipboardFile::MonitorReady => {
log::debug!("server_monitor_ready called");
ret = server_monitor_ready(context, conn_id);
log::debug!("server_monitor_ready called, return {}", ret);
log::debug!("server_monitor_ready called, conn_id {}, return {}", conn_id, ret);
}
ClipboardFile::FormatList { format_list } => {
log::debug!("server_format_list called");
log::debug!("server_format_list called, conn_id {}, format_list: {:?}", conn_id, &format_list);
ret = server_format_list(context, conn_id, format_list);
log::debug!("server_format_list called, return {}", ret);
log::debug!("server_format_list called, conn_id {}, return {}", conn_id, ret);
}
ClipboardFile::FormatListResponse { msg_flags } => {
log::debug!("format_list_response called");
log::debug!("server_format_list_response called");
ret = server_format_list_response(context, conn_id, msg_flags);
log::debug!("server_format_list_response called, return {}", ret);
log::debug!("server_format_list_response called, conn_id {}, msg_flags {}, return {}", conn_id, msg_flags, ret);
}
ClipboardFile::FormatDataRequest {
requested_format_id,
} => {
log::debug!("format_data_request called");
log::debug!("server_format_data_request called");
ret = server_format_data_request(context, conn_id, requested_format_id);
log::debug!("server_format_data_request called, return {}", ret);
log::debug!("server_format_data_request called, conn_id {}, requested_format_id {}, return {}", conn_id, requested_format_id, ret);
}
ClipboardFile::FormatDataResponse {
msg_flags,
format_data,
} => {
log::debug!("format_data_response called");
log::debug!("server_format_data_response called");
ret = server_format_data_response(context, conn_id, msg_flags, format_data);
log::debug!("server_format_data_response called, return {}", ret);
log::debug!(
"server_format_data_response called, conn_id {}, msg_flags: {}, return {}",
conn_id,
msg_flags,
ret
);
}
ClipboardFile::FileContentsRequest {
stream_id,
@ -218,7 +223,7 @@ pub fn server_clip_file(
have_clip_data_id,
clip_data_id,
} => {
log::debug!("file_contents_request called");
log::debug!("server_file_contents_request called");
ret = server_file_contents_request(
context,
conn_id,
@ -231,14 +236,24 @@ pub fn server_clip_file(
have_clip_data_id,
clip_data_id,
);
log::debug!("server_file_contents_request called, return {}", ret);
log::debug!("server_file_contents_request called, conn_id {}, stream_id: {}, list_index {}, dw_flags {}, n_position_low {}, n_position_high {}, cb_requested {}, have_clip_data_id {}, clip_data_id {}, return {}", conn_id,
stream_id,
list_index,
dw_flags,
n_position_low,
n_position_high,
cb_requested,
have_clip_data_id,
clip_data_id,
ret
);
}
ClipboardFile::FileContentsResponse {
msg_flags,
stream_id,
requested_data,
} => {
log::debug!("file_contents_response called");
log::debug!("server_file_contents_response called");
ret = server_file_contents_response(
context,
conn_id,
@ -246,7 +261,12 @@ pub fn server_clip_file(
stream_id,
requested_data,
);
log::debug!("server_file_contents_response called, return {}", ret);
log::debug!("server_file_contents_response called, conn_id {}, msg_flags {}, stream_id {}, return {}",
conn_id,
msg_flags,
stream_id,
ret
);
}
}
ret
@ -578,8 +598,6 @@ extern "C" fn client_format_data_request(
_context: *mut CliprdrClientContext,
format_data_request: *const CLIPRDR_FORMAT_DATA_REQUEST,
) -> UINT {
log::debug!("client_format_data_request called");
let conn_id;
let requested_format_id;
unsafe {
@ -589,6 +607,7 @@ extern "C" fn client_format_data_request(
let data = ClipboardFile::FormatDataRequest {
requested_format_id,
};
log::debug!("client_format_data_request called, conn_id: {}, requested_format_id: {}", conn_id, requested_format_id);
// no need to handle result here
send_data(conn_id, data);

View File

@ -1367,6 +1367,11 @@ static UINT cliprdr_send_format_list(wfClipboard *clipboard, UINT32 connID)
if (!clipboard)
return ERROR_INTERNAL_ERROR;
if (!IsClipboardFormatAvailable(CF_HDROP))
{
return ERROR_SUCCESS;
}
ZeroMemory(&formatList, sizeof(CLIPRDR_FORMAT_LIST));
/* Ignore if other app is holding clipboard */
@ -1392,21 +1397,11 @@ static UINT cliprdr_send_format_list(wfClipboard *clipboard, UINT32 connID)
}
index = 0;
if (IsClipboardFormatAvailable(CF_HDROP))
{
UINT fsid = RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW);
UINT fcid = RegisterClipboardFormat(CFSTR_FILECONTENTS);
formats[index++].formatId = fsid;
formats[index++].formatId = fcid;
}
else
{
while (formatId = EnumClipboardFormats(formatId) && index < numFormats)
formats[index++].formatId = formatId;
}
// IsClipboardFormatAvailable(CF_HDROP) is checked above
UINT fsid = RegisterClipboardFormat(CFSTR_FILEDESCRIPTORW);
UINT fcid = RegisterClipboardFormat(CFSTR_FILECONTENTS);
formats[index++].formatId = fsid;
formats[index++].formatId = fcid;
numFormats = index;
if (!CloseClipboard())
@ -2215,6 +2210,7 @@ static UINT wf_cliprdr_server_format_list(CliprdrClientContext *context,
for (i = 0; i < formatList->numFormats; i++)
{
printf("REMOVE ME ========================== idx: %d, format id: %d\n", i, formatList->formats[i].formatId);
format = &(formatList->formats[i]);
mapping = &(clipboard->format_mappings[i]);
mapping->remote_format_id = format->formatId;
@ -2594,6 +2590,7 @@ wf_cliprdr_server_format_data_response(CliprdrClientContext *context,
{
// BOOL emptyRes = wf_do_empty_cliprdr((wfClipboard *)context->custom);
// (void)emptyRes;
printf("REMOVE ME ================================= msg flags: %d\n", formatDataResponse->msgFlags);
rc = E_FAIL;
break;
}