refactor: XWindowsClipboard, user std::format_to_n in place of snprintf

This commit is contained in:
sithlord48 2025-07-31 21:49:30 -04:00 committed by Chris Rizzitello
parent fe19f4de66
commit 023037f7ee

View file

@ -22,6 +22,7 @@
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <format>
#include <vector>
//
@ -643,7 +644,7 @@ void XWindowsClipboard::motifFillCache()
// get the Motif item property from the root window
static const int buffer_size = 18 + 20;
char name[buffer_size];
snprintf(name, buffer_size, "_MOTIF_CLIP_ITEM_%d", header.m_item);
std::format_to_n(name, buffer_size, "_MOTIF_CLIP_ITEM_{}", header.m_item);
Atom atomItem = XInternAtom(m_display, name, False);
data = "";
if (!XWindowsUtil::getWindowProperty(m_display, root, atomItem, &data, &target, &format, False)) {
@ -668,7 +669,7 @@ void XWindowsClipboard::motifFillCache()
MotifFormatMap motifFormats;
for (int32_t i = 0; i < numFormats; ++i) {
// get Motif format property from the root window
snprintf(name, buffer_size, "_MOTIF_CLIP_ITEM_%d", formats[i]);
std::format_to_n(name, buffer_size, "_MOTIF_CLIP_ITEM_{}", formats[i]);
Atom atomFormat = XInternAtom(m_display, name, False);
std::string data;
if (!XWindowsUtil::getWindowProperty(m_display, root, atomFormat, &data, &target, &format, False)) {
@ -743,7 +744,7 @@ bool XWindowsClipboard::motifGetSelection(const MotifClipFormat *format, Atom *a
// part that i don't know.
static const int buffer_size = 18 + 20;
char name[buffer_size];
snprintf(name, buffer_size, "_MOTIF_CLIP_ITEM_%d", format->m_data);
std::format_to_n(name, buffer_size, "_MOTIF_CLIP_ITEM_{}", format->m_data);
Atom target = XInternAtom(m_display, name, False);
Window root = RootWindow(m_display, DefaultScreen(m_display));
return XWindowsUtil::getWindowProperty(m_display, root, target, data, actualTarget, nullptr, False);