Skip to content

Commit 2118440

Browse files
authored
windows: refactor class member vars (hyprwm#10168)
1 parent c505eb5 commit 2118440

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2130
-2140
lines changed

src/Compositor.cpp

Lines changed: 189 additions & 190 deletions
Large diffs are not rendered by default.

src/config/ConfigManager.cpp

Lines changed: 85 additions & 85 deletions
Large diffs are not rendered by default.

src/config/ConfigManager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ struct SFloatCache {
142142
size_t hash;
143143

144144
SFloatCache(PHLWINDOW window) {
145-
hash = std::hash<std::string>{}(window->m_szClass) ^ (std::hash<std::string>{}(window->m_szTitle) << 1);
145+
hash = std::hash<std::string>{}(window->m_class) ^ (std::hash<std::string>{}(window->m_title) << 1);
146146
}
147147

148148
bool operator==(const SFloatCache& other) const {

src/debug/HyprCtl.cpp

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static std::string getTagsData(PHLWINDOW w, eHyprCtlOutputFormat format) {
199199

200200
static std::string getGroupedData(PHLWINDOW w, eHyprCtlOutputFormat format) {
201201
const bool isJson = format == eHyprCtlOutputFormat::FORMAT_JSON;
202-
if (w->m_sGroupData.pNextWindow.expired())
202+
if (w->m_groupData.pNextWindow.expired())
203203
return isJson ? "" : "0";
204204

205205
std::ostringstream result;
@@ -211,7 +211,7 @@ static std::string getGroupedData(PHLWINDOW w, eHyprCtlOutputFormat format) {
211211
result << std::format("\"0x{:x}\"", (uintptr_t)curr.get());
212212
else
213213
result << std::format("{:x}", (uintptr_t)curr.get());
214-
curr = curr->m_sGroupData.pNextWindow.lock();
214+
curr = curr->m_groupData.pNextWindow.lock();
215215
// We've wrapped around to the start, break out without trailing comma
216216
if (curr == head)
217217
break;
@@ -262,26 +262,25 @@ std::string CHyprCtl::getWindowData(PHLWINDOW w, eHyprCtlOutputFormat format) {
262262
"xdgTag": "{}",
263263
"xdgDescription": "{}"
264264
}},)#",
265-
(uintptr_t)w.get(), (w->m_bIsMapped ? "true" : "false"), (w->isHidden() ? "true" : "false"), (int)w->m_vRealPosition->goal().x, (int)w->m_vRealPosition->goal().y,
266-
(int)w->m_vRealSize->goal().x, (int)w->m_vRealSize->goal().y, w->m_pWorkspace ? w->workspaceID() : WORKSPACE_INVALID,
267-
escapeJSONStrings(!w->m_pWorkspace ? "" : w->m_pWorkspace->m_name), ((int)w->m_bIsFloating == 1 ? "true" : "false"), (w->m_bIsPseudotiled ? "true" : "false"),
268-
(int64_t)w->monitorID(), escapeJSONStrings(w->m_szClass), escapeJSONStrings(w->m_szTitle), escapeJSONStrings(w->m_szInitialClass),
269-
escapeJSONStrings(w->m_szInitialTitle), w->getPID(), ((int)w->m_bIsX11 == 1 ? "true" : "false"), (w->m_bPinned ? "true" : "false"),
270-
(uint8_t)w->m_sFullscreenState.internal, (uint8_t)w->m_sFullscreenState.client, getGroupedData(w, format), getTagsData(w, format), (uintptr_t)w->m_pSwallowed.get(),
271-
getFocusHistoryID(w), (g_pInputManager->isWindowInhibiting(w, false) ? "true" : "false"), escapeJSONStrings(w->xdgTag().value_or("")),
272-
escapeJSONStrings(w->xdgDescription().value_or("")));
265+
(uintptr_t)w.get(), (w->m_isMapped ? "true" : "false"), (w->isHidden() ? "true" : "false"), (int)w->m_realPosition->goal().x, (int)w->m_realPosition->goal().y,
266+
(int)w->m_realSize->goal().x, (int)w->m_realSize->goal().y, w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID,
267+
escapeJSONStrings(!w->m_workspace ? "" : w->m_workspace->m_name), ((int)w->m_isFloating == 1 ? "true" : "false"), (w->m_isPseudotiled ? "true" : "false"),
268+
(int64_t)w->monitorID(), escapeJSONStrings(w->m_class), escapeJSONStrings(w->m_title), escapeJSONStrings(w->m_initialClass), escapeJSONStrings(w->m_initialTitle),
269+
w->getPID(), ((int)w->m_isX11 == 1 ? "true" : "false"), (w->m_pinned ? "true" : "false"), (uint8_t)w->m_fullscreenState.internal, (uint8_t)w->m_fullscreenState.client,
270+
getGroupedData(w, format), getTagsData(w, format), (uintptr_t)w->m_swallowed.get(), getFocusHistoryID(w),
271+
(g_pInputManager->isWindowInhibiting(w, false) ? "true" : "false"), escapeJSONStrings(w->xdgTag().value_or("")), escapeJSONStrings(w->xdgDescription().value_or("")));
273272
} else {
274273
return std::format(
275274
"Window {:x} -> {}:\n\tmapped: {}\n\thidden: {}\n\tat: {},{}\n\tsize: {},{}\n\tworkspace: {} ({})\n\tfloating: {}\n\tpseudo: {}\n\tmonitor: {}\n\tclass: {}\n\ttitle: "
276275
"{}\n\tinitialClass: {}\n\tinitialTitle: {}\n\tpid: "
277276
"{}\n\txwayland: {}\n\tpinned: "
278277
"{}\n\tfullscreen: {}\n\tfullscreenClient: {}\n\tgrouped: {}\n\ttags: {}\n\tswallowing: {:x}\n\tfocusHistoryID: {}\n\tinhibitingIdle: {}\n\txdgTag: "
279278
"{}\n\txdgDescription: {}\n\n",
280-
(uintptr_t)w.get(), w->m_szTitle, (int)w->m_bIsMapped, (int)w->isHidden(), (int)w->m_vRealPosition->goal().x, (int)w->m_vRealPosition->goal().y,
281-
(int)w->m_vRealSize->goal().x, (int)w->m_vRealSize->goal().y, w->m_pWorkspace ? w->workspaceID() : WORKSPACE_INVALID, (!w->m_pWorkspace ? "" : w->m_pWorkspace->m_name),
282-
(int)w->m_bIsFloating, (int)w->m_bIsPseudotiled, (int64_t)w->monitorID(), w->m_szClass, w->m_szTitle, w->m_szInitialClass, w->m_szInitialTitle, w->getPID(),
283-
(int)w->m_bIsX11, (int)w->m_bPinned, (uint8_t)w->m_sFullscreenState.internal, (uint8_t)w->m_sFullscreenState.client, getGroupedData(w, format), getTagsData(w, format),
284-
(uintptr_t)w->m_pSwallowed.get(), getFocusHistoryID(w), (int)g_pInputManager->isWindowInhibiting(w, false), w->xdgTag().value_or(""), w->xdgDescription().value_or(""));
279+
(uintptr_t)w.get(), w->m_title, (int)w->m_isMapped, (int)w->isHidden(), (int)w->m_realPosition->goal().x, (int)w->m_realPosition->goal().y,
280+
(int)w->m_realSize->goal().x, (int)w->m_realSize->goal().y, w->m_workspace ? w->workspaceID() : WORKSPACE_INVALID, (!w->m_workspace ? "" : w->m_workspace->m_name),
281+
(int)w->m_isFloating, (int)w->m_isPseudotiled, (int64_t)w->monitorID(), w->m_class, w->m_title, w->m_initialClass, w->m_initialTitle, w->getPID(), (int)w->m_isX11,
282+
(int)w->m_pinned, (uint8_t)w->m_fullscreenState.internal, (uint8_t)w->m_fullscreenState.client, getGroupedData(w, format), getTagsData(w, format),
283+
(uintptr_t)w->m_swallowed.get(), getFocusHistoryID(w), (int)g_pInputManager->isWindowInhibiting(w, false), w->xdgTag().value_or(""), w->xdgDescription().value_or(""));
285284
}
286285
}
287286

@@ -291,7 +290,7 @@ static std::string clientsRequest(eHyprCtlOutputFormat format, std::string reque
291290
result += "[";
292291

293292
for (auto const& w : g_pCompositor->m_windows) {
294-
if (!w->m_bIsMapped && !g_pHyprCtl->m_currentRequestParams.all)
293+
if (!w->m_isMapped && !g_pHyprCtl->m_currentRequestParams.all)
295294
continue;
296295

297296
result += CHyprCtl::getWindowData(w, format);
@@ -302,7 +301,7 @@ static std::string clientsRequest(eHyprCtlOutputFormat format, std::string reque
302301
result += "]";
303302
} else {
304303
for (auto const& w : g_pCompositor->m_windows) {
305-
if (!w->m_bIsMapped && !g_pHyprCtl->m_currentRequestParams.all)
304+
if (!w->m_isMapped && !g_pHyprCtl->m_currentRequestParams.all)
306305
continue;
307306

308307
result += CHyprCtl::getWindowData(w, format);
@@ -328,12 +327,12 @@ std::string CHyprCtl::getWorkspaceData(PHLWORKSPACE w, eHyprCtlOutputFormat form
328327
}})#",
329328
w->m_id, escapeJSONStrings(w->m_name), escapeJSONStrings(PMONITOR ? PMONITOR->szName : "?"),
330329
escapeJSONStrings(PMONITOR ? std::to_string(PMONITOR->ID) : "null"), w->getWindows(), w->m_hasFullscreenWindow ? "true" : "false",
331-
(uintptr_t)PLASTW.get(), PLASTW ? escapeJSONStrings(PLASTW->m_szTitle) : "", w->m_persistent ? "true" : "false");
330+
(uintptr_t)PLASTW.get(), PLASTW ? escapeJSONStrings(PLASTW->m_title) : "", w->m_persistent ? "true" : "false");
332331
} else {
333332
return std::format(
334333
"workspace ID {} ({}) on monitor {}:\n\tmonitorID: {}\n\twindows: {}\n\thasfullscreen: {}\n\tlastwindow: 0x{:x}\n\tlastwindowtitle: {}\n\tispersistent: {}\n\n",
335334
w->m_id, w->m_name, PMONITOR ? PMONITOR->szName : "?", PMONITOR ? std::to_string(PMONITOR->ID) : "null", w->getWindows(), (int)w->m_hasFullscreenWindow,
336-
(uintptr_t)PLASTW.get(), PLASTW ? PLASTW->m_szTitle : "", (int)w->m_persistent);
335+
(uintptr_t)PLASTW.get(), PLASTW ? PLASTW->m_title : "", (int)w->m_persistent);
337336
}
338337
}
339338

@@ -1397,15 +1396,15 @@ static std::string decorationRequest(eHyprCtlOutputFormat format, std::string re
13971396
std::string result = "";
13981397
if (format == eHyprCtlOutputFormat::FORMAT_JSON) {
13991398
result += "[";
1400-
for (auto const& wd : PWINDOW->m_dWindowDecorations) {
1399+
for (auto const& wd : PWINDOW->m_windowDecorations) {
14011400
result += "{\n\"decorationName\": \"" + wd->getDisplayName() + "\",\n\"priority\": " + std::to_string(wd->getPositioningInfo().priority) + "\n},";
14021401
}
14031402

14041403
trimTrailingComma(result);
14051404
result += "]";
14061405
} else {
14071406
result = +"Decoration\tPriority\n";
1408-
for (auto const& wd : PWINDOW->m_dWindowDecorations) {
1407+
for (auto const& wd : PWINDOW->m_windowDecorations) {
14091408
result += wd->getDisplayName() + "\t" + std::to_string(wd->getPositioningInfo().priority) + "\n";
14101409
}
14111410
}
@@ -1794,7 +1793,7 @@ std::string CHyprCtl::getReply(std::string request) {
17941793
}
17951794

17961795
for (auto const& w : g_pCompositor->m_windows) {
1797-
if (!w->m_bIsMapped || !w->m_pWorkspace || !w->m_pWorkspace->isVisible())
1796+
if (!w->m_isMapped || !w->m_workspace || !w->m_workspace->isVisible())
17981797
continue;
17991798

18001799
w->updateDynamicRules();

src/desktop/Popup.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ void CPopup::initAllSignals() {
5454

5555
if (!m_resource) {
5656
if (!m_windowOwner.expired())
57-
m_listeners.newPopup =
58-
m_windowOwner->m_pXDGSurface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); });
57+
m_listeners.newPopup = m_windowOwner->m_xdgSurface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); });
5958
else if (!m_layerOwner.expired())
6059
m_listeners.newPopup =
6160
m_layerOwner->m_layerSurface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); });
@@ -172,7 +171,7 @@ void CPopup::onCommit(bool ignoreSiblings) {
172171
return;
173172
}
174173

175-
if (!m_windowOwner.expired() && (!m_windowOwner->m_bIsMapped || !m_windowOwner->m_pWorkspace->m_visible)) {
174+
if (!m_windowOwner.expired() && (!m_windowOwner->m_isMapped || !m_windowOwner->m_workspace->m_visible)) {
176175
m_lastSize = m_resource->surface->surface->current.size;
177176

178177
static auto PLOGDAMAGE = CConfigValue<Hyprlang::INT>("debug:log_damage");
@@ -231,7 +230,7 @@ void CPopup::reposition() {
231230

232231
SP<CWLSurface> CPopup::getT1Owner() {
233232
if (m_windowOwner)
234-
return m_windowOwner->m_pWLSurface;
233+
return m_windowOwner->m_wlSurface;
235234
else
236235
return m_layerOwner->m_surface;
237236
}
@@ -266,7 +265,7 @@ Vector2D CPopup::localToGlobal(const Vector2D& rel) {
266265

267266
Vector2D CPopup::t1ParentCoords() {
268267
if (!m_windowOwner.expired())
269-
return m_windowOwner->m_vRealPosition->value();
268+
return m_windowOwner->m_realPosition->value();
270269
if (!m_layerOwner.expired())
271270
return m_layerOwner->m_realPosition->value();
272271

@@ -301,7 +300,7 @@ Vector2D CPopup::size() {
301300

302301
void CPopup::sendScale() {
303302
if (!m_windowOwner.expired())
304-
g_pCompositor->setPreferredScaleForSurface(m_wlSurface->resource(), m_windowOwner->m_pWLSurface->m_lastScaleFloat);
303+
g_pCompositor->setPreferredScaleForSurface(m_wlSurface->resource(), m_windowOwner->m_wlSurface->m_lastScaleFloat);
305304
else if (!m_layerOwner.expired())
306305
g_pCompositor->setPreferredScaleForSurface(m_wlSurface->resource(), m_layerOwner->m_surface->m_lastScaleFloat);
307306
else

src/desktop/Subsurface.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ UP<CSubsurface> CSubsurface::create(PHLWINDOW pOwner) {
1313
subsurface->m_self = subsurface;
1414

1515
subsurface->initSignals();
16-
subsurface->initExistingSubsurfaces(pOwner->m_pWLSurface->resource());
16+
subsurface->initExistingSubsurfaces(pOwner->m_wlSurface->resource());
1717
return subsurface;
1818
}
1919

@@ -60,7 +60,7 @@ void CSubsurface::initSignals() {
6060
m_subsurface->surface->events.newSubsurface.registerListener([this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
6161
} else {
6262
if (m_windowParent)
63-
m_listeners.newSubsurface = m_windowParent->m_pWLSurface->resource()->events.newSubsurface.registerListener(
63+
m_listeners.newSubsurface = m_windowParent->m_wlSurface->resource()->events.newSubsurface.registerListener(
6464
[this](std::any d) { onNewSubsurface(std::any_cast<SP<CWLSubsurfaceResource>>(d)); });
6565
else if (m_popupParent)
6666
m_listeners.newSubsurface =
@@ -74,7 +74,7 @@ void CSubsurface::checkSiblingDamage() {
7474
if (!m_parent)
7575
return; // ??????????
7676

77-
const double SCALE = m_windowParent.lock() && m_windowParent->m_bIsX11 ? 1.0 / m_windowParent->m_fX11SurfaceScaledBy : 1.0;
77+
const double SCALE = m_windowParent.lock() && m_windowParent->m_isX11 ? 1.0 / m_windowParent->m_X11SurfaceScaledBy : 1.0;
7878

7979
for (auto const& n : m_parent->m_children) {
8080
if (n.get() == this)
@@ -94,7 +94,7 @@ void CSubsurface::recheckDamageForSubsurfaces() {
9494

9595
void CSubsurface::onCommit() {
9696
// no damaging if it's not visible
97-
if (!m_windowParent.expired() && (!m_windowParent->m_bIsMapped || !m_windowParent->m_pWorkspace->m_visible)) {
97+
if (!m_windowParent.expired() && (!m_windowParent->m_isMapped || !m_windowParent->m_workspace->m_visible)) {
9898
m_lastSize = m_wlSurface->resource()->current.size;
9999

100100
static auto PLOGDAMAGE = CConfigValue<Hyprlang::INT>("debug:log_damage");
@@ -110,7 +110,7 @@ void CSubsurface::onCommit() {
110110
if (m_popupParent && !m_popupParent->inert() && m_popupParent->m_wlSurface)
111111
m_popupParent->recheckTree();
112112
if (!m_windowParent.expired()) // I hate you firefox why are you doing this
113-
m_windowParent->m_pPopupHead->recheckTree();
113+
m_windowParent->m_popupHead->recheckTree();
114114

115115
// I do not think this is correct, but it solves a lot of issues with some apps (e.g. firefox)
116116
checkSiblingDamage();
@@ -191,7 +191,7 @@ Vector2D CSubsurface::coordsGlobal() {
191191
Vector2D coords = coordsRelativeToParent();
192192

193193
if (!m_windowParent.expired())
194-
coords += m_windowParent->m_vRealPosition->value();
194+
coords += m_windowParent->m_realPosition->value();
195195
else if (m_popupParent)
196196
coords += m_popupParent->coordsGlobal();
197197

src/desktop/WLSurface.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ bool CWLSurface::small() const {
6464

6565
const auto O = m_windowOwner.lock();
6666

67-
return O->m_vReportedSize.x > m_resource->current.size.x + 1 || O->m_vReportedSize.y > m_resource->current.size.y + 1;
67+
return O->m_reportedSize.x > m_resource->current.size.x + 1 || O->m_reportedSize.y > m_resource->current.size.y + 1;
6868
}
6969

7070
Vector2D CWLSurface::correctSmallVec() const {
@@ -74,7 +74,7 @@ Vector2D CWLSurface::correctSmallVec() const {
7474
const auto SIZE = getViewporterCorrectedSize();
7575
const auto O = m_windowOwner.lock();
7676

77-
return Vector2D{(O->m_vReportedSize.x - SIZE.x) / 2, (O->m_vReportedSize.y - SIZE.y) / 2}.clamp({}, {INFINITY, INFINITY}) * (O->m_vRealSize->value() / O->m_vReportedSize);
77+
return Vector2D{(O->m_reportedSize.x - SIZE.x) / 2, (O->m_reportedSize.y - SIZE.y) / 2}.clamp({}, {INFINITY, INFINITY}) * (O->m_realSize->value() / O->m_reportedSize);
7878
}
7979

8080
Vector2D CWLSurface::correctSmallVecBuf() const {
@@ -121,7 +121,7 @@ CRegion CWLSurface::computeDamage() const {
121121
damage.scale(SCALE);
122122

123123
if (m_windowOwner)
124-
damage.scale(m_windowOwner->m_fX11SurfaceScaledBy); // fix xwayland:force_zero_scaling stuff that will be fucked by the above a bit
124+
damage.scale(m_windowOwner->m_X11SurfaceScaledBy); // fix xwayland:force_zero_scaling stuff that will be fucked by the above a bit
125125

126126
return damage;
127127
}

0 commit comments

Comments
 (0)