mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-12-17 04:26:47 +08:00
[fix] clean display names by removing non-alphanumeric characters
This commit is contained in:
@@ -36,9 +36,21 @@ int ScreenCapturerX11::Init(const int fps, cb_desktop_data cb) {
|
|||||||
XRRCrtcInfo* crtc_info =
|
XRRCrtcInfo* crtc_info =
|
||||||
XRRGetCrtcInfo(display_, screen_res_, output_info->crtc);
|
XRRGetCrtcInfo(display_, screen_res_, output_info->crtc);
|
||||||
|
|
||||||
display_info_list_.push_back(
|
std::string name(output_info->name);
|
||||||
DisplayInfo((void*)display_, output_info->name, true, crtc_info->x,
|
|
||||||
crtc_info->y, crtc_info->width, crtc_info->height));
|
if (name.empty()) {
|
||||||
|
name = "Display" + std::to_string(i + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// clean display name, remove non-alphanumeric characters
|
||||||
|
name.erase(
|
||||||
|
std::remove_if(name.begin(), name.end(),
|
||||||
|
[](unsigned char c) { return !std::isalnum(c); }),
|
||||||
|
name.end());
|
||||||
|
|
||||||
|
display_info_list_.push_back(DisplayInfo(
|
||||||
|
(void*)display_, name, true, crtc_info->x, crtc_info->y,
|
||||||
|
crtc_info->x + crtc_info->width, crtc_info->y + crtc_info->height));
|
||||||
|
|
||||||
XRRFreeCrtcInfo(crtc_info);
|
XRRFreeCrtcInfo(crtc_info);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -226,13 +226,17 @@ int ScreenCapturerSckImpl::Init(const int fps, cb_desktop_data cb) {
|
|||||||
CGRect bounds = CGDisplayBounds(display_id);
|
CGRect bounds = CGDisplayBounds(display_id);
|
||||||
bool is_primary = CGDisplayIsMain(display_id);
|
bool is_primary = CGDisplayIsMain(display_id);
|
||||||
|
|
||||||
std::string name;
|
std::string name = GetDisplayName(display_id);
|
||||||
name = GetDisplayName(display_id);
|
|
||||||
|
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
name = "Display" + std::to_string(unnamed_count++);
|
name = "Display" + std::to_string(unnamed_count++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clean display name, remove non-alphanumeric characters
|
||||||
|
name.erase(
|
||||||
|
std::remove_if(name.begin(), name.end(), [](unsigned char c) { return !std::isalnum(c); }),
|
||||||
|
name.end());
|
||||||
|
|
||||||
DisplayInfo info((void *)(uintptr_t)display_id, name, is_primary,
|
DisplayInfo info((void *)(uintptr_t)display_id, name, is_primary,
|
||||||
static_cast<int>(bounds.origin.x), static_cast<int>(bounds.origin.y),
|
static_cast<int>(bounds.origin.x), static_cast<int>(bounds.origin.y),
|
||||||
static_cast<int>(bounds.origin.x + bounds.size.width),
|
static_cast<int>(bounds.origin.x + bounds.size.width),
|
||||||
|
|||||||
Reference in New Issue
Block a user