Compare commits

...

6 Commits

Author SHA1 Message Date
Brenden Matthews 0821c25533 This span doesn't need to exist 2024-04-24 17:01:38 -04:00
Brenden Matthews 3d62277edd Fix type def, handle error case 2024-04-24 17:01:38 -04:00
Brenden Matthews 4c2969778b Link to latest commit in web footer 2024-04-24 17:01:38 -04:00
Brenden Matthews 224c5ebd72 Explicitly note updated time is UTC 2024-04-24 15:17:29 -04:00
Brenden Matthews c0f06aa0a0 Bump version 2024-04-24 15:17:13 -04:00
Tin Švagelj c5ee70177c
set_struts improvements (#1849)
Simplify and speed up strut code

Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
2024-04-24 13:56:28 +00:00
7 changed files with 93 additions and 88 deletions

View File

@ -133,7 +133,7 @@ endif(OS_HAIKU)
# Do version stuff
set(VERSION_MAJOR "1")
set(VERSION_MINOR "20")
set(VERSION_PATCH "2")
set(VERSION_PATCH "3")
find_program(APP_AWK awk)

View File

@ -313,37 +313,8 @@ bool display_output_x11::main_loop_wait(double t) {
/* update struts */
if ((changed != 0) && own_window_type.get(*state) == window_type::PANEL) {
int sidenum = -1;
NORM_ERR("defining struts");
alignment align = text_alignment.get(*state);
switch (align) {
case alignment::TOP_LEFT:
case alignment::TOP_RIGHT:
case alignment::TOP_MIDDLE: {
sidenum = 2;
break;
}
case alignment::BOTTOM_LEFT:
case alignment::BOTTOM_RIGHT:
case alignment::BOTTOM_MIDDLE: {
sidenum = 3;
break;
}
case alignment::MIDDLE_LEFT: {
sidenum = 0;
break;
}
case alignment::MIDDLE_RIGHT: {
sidenum = 1;
break;
}
default:
break;
}
if (sidenum != -1) set_struts(sidenum);
set_struts(text_alignment.get(*state));
}
}
#endif

View File

@ -1108,60 +1108,65 @@ constexpr size_t operator*(x11_strut index) {
}
/* reserve window manager space */
void set_struts(int sidenum) {
Atom strut;
if ((strut = ATOM(_NET_WM_STRUT)) != None) {
/* reserve space at left, right, top, bottom */
signed long sizes[12] = {0};
int i;
void set_struts(alignment align) {
// Middle and none align don't have least significant bit set.
// Ensures either vertical or horizontal axis are start/end
if ((*align & 0b0101) == 0) return;
/* define strut depth */
switch (sidenum) {
case 0:
/* left side */
sizes[0] = window.x + window.width;
break;
case 1:
/* right side */
sizes[1] = display_width - window.x;
break;
case 2:
/* top side */
sizes[2] = window.y + window.height;
break;
case 3:
/* bottom side */
sizes[3] = display_height - window.y;
break;
}
Atom strut = ATOM(_NET_WM_STRUT);
if (strut != None) {
long sizes[STRUT_COUNT] = {0};
/* define partial strut length */
if (sidenum <= 1) {
sizes[4 + (sidenum * 2)] = window.y;
sizes[5 + (sidenum * 2)] = window.y + window.height;
} else if (sidenum <= 3) {
sizes[4 + (sidenum * 2)] = window.x;
sizes[5 + (sidenum * 2)] = window.x + window.width;
}
/* check constraints */
for (i = 0; i < 12; i++) {
if (sizes[i] < 0) {
sizes[i] = 0;
} else {
if (i <= 1 || i >= 8) {
if (sizes[i] > display_width) { sizes[i] = display_width; }
} else {
if (sizes[i] > display_height) { sizes[i] = display_height; }
switch (horizontal_alignment(align)) {
case axis_align::START:
sizes[*x11_strut::LEFT] =
std::clamp(window.x + window.width, 0, display_width);
sizes[*x11_strut::LEFT_START_Y] =
std::clamp(window.y, 0, display_height);
sizes[*x11_strut::LEFT_END_Y] =
std::clamp(window.y + window.height, 0, display_height);
break;
case axis_align::END:
sizes[*x11_strut::RIGHT] =
std::clamp(display_width - window.x, 0, display_width);
sizes[*x11_strut::RIGHT_START_Y] =
std::clamp(window.y, 0, display_height);
sizes[*x11_strut::RIGHT_END_Y] =
std::clamp(window.y + window.height, 0, display_height);
break;
case axis_align::MIDDLE:
switch (vertical_alignment(align)) {
case axis_align::START:
sizes[*x11_strut::TOP] =
std::clamp(window.y + window.height, 0, display_height);
sizes[*x11_strut::TOP_START_X] =
std::clamp(window.x, 0, display_width);
sizes[*x11_strut::TOP_END_X] =
std::clamp(window.x + window.width, 0, display_width);
break;
case axis_align::END:
sizes[*x11_strut::BOTTOM] =
std::clamp(display_height - window.y, 0, display_height);
sizes[*x11_strut::BOTTOM_START_X] =
std::clamp(window.x, 0, display_width);
sizes[*x11_strut::BOTTOM_END_X] =
std::clamp(window.x + window.width, 0, display_width);
break;
case axis_align::MIDDLE:
// can't reserve space in middle of the screen
default:
break;
}
}
default:
break;
}
XChangeProperty(display, window.window, strut, XA_CARDINAL, 32,
PropModeReplace, reinterpret_cast<unsigned char *>(&sizes),
4);
if ((strut = ATOM(_NET_WM_STRUT_PARTIAL)) != None) {
strut = ATOM(_NET_WM_STRUT_PARTIAL);
if (strut != None) {
XChangeProperty(display, window.window, strut, XA_CARDINAL, 32,
PropModeReplace,
reinterpret_cast<unsigned char *>(&sizes), 12);

View File

@ -103,7 +103,7 @@ void destroy_window(void);
void create_gc(void);
void set_transparent_background(Window win);
void get_x11_desktop_info(Display *current_display, Atom atom);
void set_struts(int);
void set_struts(alignment alignment);
void x11_init_window(lua::state &l, bool own);
void deinit_x11();

View File

@ -1,9 +1,10 @@
import getConfig from 'next/config'
import CopyleftIcon from './CopyleftIcon'
import Link from 'next/link'
const Footer: React.FunctionComponent = () => {
const { publicRuntimeConfig } = getConfig()
const { modifiedDate, modifiedYear } = publicRuntimeConfig
const { modifiedDate, modifiedYear, gitHash } = publicRuntimeConfig
return (
<div className="max-w-3xl mx-auto flex py-4 items-center">
<div className="px-2 lg:px-4">
@ -11,7 +12,19 @@ const Footer: React.FunctionComponent = () => {
</div>
<div className="pl-1 pr-2 lg:pr-4 font-sans text-xs">
<p>
{modifiedYear} Conky developers, updated {new Date(modifiedDate).toLocaleString()}
{modifiedYear} Conky developers, updated{' '}
{new Date(modifiedDate).toLocaleString()} UTC
{gitHash && (
<>
{' '}
<Link
target="_blank"
href={`https://github.com/brndnmtthws/conky/commit/${gitHash}`}
>
{`(${gitHash})`}
</Link>
</>
)}
</p>
</div>
</div>

1
web/global.d.ts vendored
View File

@ -3,6 +3,7 @@ declare module 'next/config' {
publicRuntimeConfig: {
modifiedDate: string
modifiedYear: string
gitHash: string?
}
}

View File

@ -1,13 +1,28 @@
// @ts-check
import { spawn } from 'child_process'
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
publicRuntimeConfig: {
modifiedDate: new Date().toISOString(),
modifiedYear: new Date().getFullYear(),
},
const config = async (_phase, { _defaultConfig }) => {
const gitHash = await new Promise((resolve) => {
const git = spawn('git', ['rev-parse', '--short', 'HEAD'])
git.stdout.on('data', (data) => {
resolve(data.toString().trim())
})
git.on('error', () => {
resolve(undefined)
})
})
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
publicRuntimeConfig: {
modifiedDate: new Date().toISOString(),
modifiedYear: new Date().getFullYear(),
gitHash,
},
}
return nextConfig
}
export default nextConfig
export default config