-
-
Notifications
You must be signed in to change notification settings - Fork 620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove _member_access from geometry #1910
Conversation
✅ Deploy Preview for conkyweb canceled.
|
df61cec
to
90b0923
Compare
0e14543
to
9bb3061
Compare
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wfree-nonheap-object" | ||
// *_allocated takes care of avoiding freeing unallocated objects | ||
if (name_allocated) delete[] error_name; | ||
if (code_allocated) delete[] code_description; | ||
#pragma GCC diagnostic pop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This produces a (new) warning in GCC 14.1.1
add_compile_options( | ||
$<$<COMPILE_LANG_AND_ID:CXX,Clang>:-stdlib=libc++> | ||
$<$<COMPILE_LANG_AND_ID:CXX,Clang>:-Wno-unknown-warning-option> | ||
$<$<COMPILE_LANG_AND_ID:CXX,GCC>:-Wno-unknown-warning>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to add these to avoid warning about new warnings with older compiler versions.
@@ -226,7 +226,7 @@ char *find_and_replace_templates(const char *inbuf) { | |||
outlen += len; | |||
*o = '\0'; | |||
outbuf = static_cast<char *>(realloc(outbuf, outlen * sizeof(char))); | |||
strncat(outbuf, tmpl_out, len); | |||
strcat(outbuf, tmpl_out); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was also a warning because the new compiler can tell that len
is derived from strlen(tmpl_out)
which is then the same as using strcat
directly.
int display_width = workarea[2] - workarea[0]; | ||
int display_height = workarea[3] - workarea[1]; | ||
int display_width = workarea.width(); | ||
int display_height = workarea.height(); | ||
|
||
switch (horizontal_alignment(align)) { | ||
case axis_align::START: | ||
sizes[*x11_strut::LEFT] = std::clamp( | ||
window.geometry.x + window.geometry.width, 0, *workarea.width); | ||
window.geometry.x() + window.geometry.end_x(), 0, display_width); | ||
sizes[*x11_strut::LEFT_START_Y] = | ||
std::clamp(*window.geometry.y, 0, *workarea.height); | ||
std::clamp(window.geometry.y(), 0, display_height); | ||
sizes[*x11_strut::LEFT_END_Y] = std::clamp( | ||
window.geometry.y + window.geometry.height, 0, *workarea.height); | ||
window.geometry.y() + window.geometry.height(), 0, display_height); | ||
break; | ||
case axis_align::END: | ||
sizes[*x11_strut::RIGHT] = | ||
std::clamp(workarea.width - window.geometry.x, 0, *workarea.width); | ||
std::clamp(display_width - window.geometry.x(), 0, display_width); | ||
sizes[*x11_strut::RIGHT_START_Y] = | ||
std::clamp(*window.geometry.y, 0, *workarea.height); | ||
std::clamp(window.geometry.y(), 0, display_height); | ||
sizes[*x11_strut::RIGHT_END_Y] = std::clamp( | ||
window.geometry.y + window.geometry.height, 0, *workarea.height); | ||
window.geometry.y() + window.geometry.height(), 0, display_height); | ||
break; | ||
case axis_align::MIDDLE: | ||
switch (vertical_alignment(align)) { | ||
case axis_align::START: | ||
sizes[*x11_strut::TOP] = | ||
std::clamp(window.geometry.y + window.geometry.height, 0, | ||
*workarea.height); | ||
std::clamp(window.geometry.y() + window.geometry.height(), 0, | ||
display_height); | ||
sizes[*x11_strut::TOP_START_X] = | ||
std::clamp(*window.geometry.x, 0, *workarea.width); | ||
sizes[*x11_strut::TOP_END_X] = std::clamp( | ||
window.geometry.x + window.geometry.width, 0, *workarea.width); | ||
std::clamp(window.geometry.x(), 0, display_width); | ||
sizes[*x11_strut::TOP_END_X] = | ||
std::clamp(window.geometry.x() + window.geometry.width(), 0, | ||
display_width); | ||
break; | ||
case axis_align::END: | ||
sizes[*x11_strut::BOTTOM] = std::clamp( | ||
workarea.height - window.geometry.y, 0, *workarea.height); | ||
display_height - window.geometry.y(), 0, display_height); | ||
sizes[*x11_strut::BOTTOM_START_X] = | ||
std::clamp(*window.geometry.x, 0, *workarea.width); | ||
sizes[*x11_strut::BOTTOM_END_X] = std::clamp( | ||
window.geometry.x + window.geometry.width, 0, *workarea.width); | ||
std::clamp(window.geometry.x(), 0, display_width); | ||
sizes[*x11_strut::BOTTOM_END_X] = | ||
std::clamp(window.geometry.x() + window.geometry.width(), 0, | ||
display_width); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was buggy. I didn't use display_width
and display_height
at all, and instead workarea.width
which was in fact an absolute end x position and not width.
workarea[0] = ps->x_org; | ||
workarea[1] = ps->y_org; | ||
workarea[2] = workarea[0] + ps->width; | ||
workarea[3] = workarea[1] + ps->height; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As can be seen here.
It was difficult ensuring temporary `this` was correct when combined with composition. Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
Add some convenience setters. Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
This allows source pragmas for future warnings which are in a newer version of the compiler but not implemented in an older one. Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
strncat that concatenates to a buffer whose length was determined from source strlen can be replaced by strcat - if the buffer is invalid (unterminated), using strlen will result in same behavior. Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
Fixes incorrect member accessing left behind after #1910.
It was difficult/too costly ensuring temporary
this
was correct whenvec
s contained inrect
s were accessed directly.This PR also adds:
rect
for sized & absolute rectangles, and fixes another (unreported) bug with previous PR (Introduce geometry primitives #1862) where I used absolute end positions instead of width/height.Fixes #1908.