ignore solid offsets for MOVE_ADJUST_TO_FIT_SCREEN

This commit is contained in:
nakst 2021-10-06 14:18:14 +01:00
parent d42b31ab28
commit 8274a99521
6 changed files with 26 additions and 21 deletions

View File

@ -17,9 +17,10 @@
// Behaviour of activation clicks. --> Only ignore activation clicks from menus. // Behaviour of activation clicks. --> Only ignore activation clicks from menus.
// Behaviour of the scroll wheel with regards to focused/hovered elements --> Scroll the hovered element only. // Behaviour of the scroll wheel with regards to focused/hovered elements --> Scroll the hovered element only.
// TODO Get these from the theme file.
#define WINDOW_INSET ((int) (19 * theming.scale)) #define WINDOW_INSET ((int) (19 * theming.scale))
#define CONTAINER_TAB_BAND_HEIGHT ((int) (33 * theming.scale)) #define CONTAINER_TAB_BAND_HEIGHT ((int) (33 * theming.scale))
#define BORDER_THICKNESS ((int) (9 * theming.scale)) #define BORDER_THICKNESS ((int) ( 9 * theming.scale))
// #define TRACE_LAYOUT // #define TRACE_LAYOUT
@ -790,7 +791,8 @@ int ProcessRootMessage(EsElement *element, EsMessage *message) {
EsElementMove(window->GetChild(0), WINDOW_INSET, WINDOW_INSET, bounds.r - WINDOW_INSET * 2, CONTAINER_TAB_BAND_HEIGHT); EsElementMove(window->GetChild(0), WINDOW_INSET, WINDOW_INSET, bounds.r - WINDOW_INSET * 2, CONTAINER_TAB_BAND_HEIGHT);
} else if (message->type == ES_MSG_UI_SCALE_CHANGED) { } else if (message->type == ES_MSG_UI_SCALE_CHANGED) {
// This message is also sent when the window is created. // This message is also sent when the window is created.
EsSyscall(ES_SYSCALL_WINDOW_SET_PROPERTY, window->handle, ES_WINDOW_SOLID_TRUE, 10 * theming.scale, ES_WINDOW_PROPERTY_SOLID); EsRectangle solidInsets = ES_RECT_1((WINDOW_INSET - BORDER_THICKNESS) * theming.scale);
EsSyscall(ES_SYSCALL_WINDOW_SET_PROPERTY, window->handle, ES_WINDOW_SOLID_TRUE, (uintptr_t) &solidInsets, ES_WINDOW_PROPERTY_SOLID);
EsRectangle embedInsets = ES_RECT_4(WINDOW_INSET, WINDOW_INSET, WINDOW_INSET + CONTAINER_TAB_BAND_HEIGHT, WINDOW_INSET); EsRectangle embedInsets = ES_RECT_4(WINDOW_INSET, WINDOW_INSET, WINDOW_INSET + CONTAINER_TAB_BAND_HEIGHT, WINDOW_INSET);
EsSyscall(ES_SYSCALL_WINDOW_SET_PROPERTY, window->handle, (uintptr_t) &embedInsets, 0, ES_WINDOW_PROPERTY_EMBED_INSETS); EsSyscall(ES_SYSCALL_WINDOW_SET_PROPERTY, window->handle, (uintptr_t) &embedInsets, 0, ES_WINDOW_PROPERTY_EMBED_INSETS);
EsRectangle opaqueBounds = ES_RECT_4(WINDOW_INSET, window->windowWidth - WINDOW_INSET, WINDOW_INSET, window->windowHeight - WINDOW_INSET); EsRectangle opaqueBounds = ES_RECT_4(WINDOW_INSET, window->windowWidth - WINDOW_INSET, WINDOW_INSET, window->windowHeight - WINDOW_INSET);
@ -937,7 +939,7 @@ EsWindow *EsWindowCreate(EsInstance *instance, EsWindowStyle style) {
EsElementStartTransition(window, ES_TRANSITION_FADE_IN); EsElementStartTransition(window, ES_TRANSITION_FADE_IN);
EsSyscall(ES_SYSCALL_WINDOW_SET_PROPERTY, window->handle, ES_WINDOW_SOLID_TRUE, panel->currentStyle->insets.l, ES_WINDOW_PROPERTY_SOLID); EsSyscall(ES_SYSCALL_WINDOW_SET_PROPERTY, window->handle, ES_WINDOW_SOLID_TRUE, (uintptr_t) &panel->currentStyle->insets, ES_WINDOW_PROPERTY_SOLID);
EsSyscall(ES_SYSCALL_WINDOW_SET_PROPERTY, window->handle, BLEND_WINDOW_MATERIAL_GLASS, 0, ES_WINDOW_PROPERTY_MATERIAL); EsSyscall(ES_SYSCALL_WINDOW_SET_PROPERTY, window->handle, BLEND_WINDOW_MATERIAL_GLASS, 0, ES_WINDOW_PROPERTY_MATERIAL);
} }

View File

@ -418,7 +418,9 @@ SYSCALL_IMPLEMENT(ES_SYSCALL_WINDOW_SET_PROPERTY) {
window->solid = (argument1 & ES_WINDOW_SOLID_TRUE) != 0; window->solid = (argument1 & ES_WINDOW_SOLID_TRUE) != 0;
window->noClickActivate = (argument1 & ES_WINDOW_SOLID_NO_ACTIVATE) != 0; window->noClickActivate = (argument1 & ES_WINDOW_SOLID_NO_ACTIVATE) != 0;
window->noBringToFront = (argument1 & ES_WINDOW_SOLID_NO_BRING_TO_FRONT) != 0; window->noBringToFront = (argument1 & ES_WINDOW_SOLID_NO_BRING_TO_FRONT) != 0;
window->solidInsets = ES_RECT_1I(argument2); EsRectangle solidInsets = ES_RECT_1(0);
if (argument2) SYSCALL_READ(&solidInsets, argument2, sizeof(EsRectangle));
window->solidOffsets = ES_RECT_4(solidInsets.l, -solidInsets.r, solidInsets.t, -solidInsets.b);
KMutexAcquire(&windowManager.mutex); KMutexAcquire(&windowManager.mutex);
windowManager.MoveCursor(0, 0); windowManager.MoveCursor(0, 0);
KMutexRelease(&windowManager.mutex); KMutexRelease(&windowManager.mutex);

View File

@ -34,7 +34,7 @@ struct Window {
// State: // State:
EsWindowStyle style; EsWindowStyle style;
EsRectangle solidInsets, embedInsets; EsRectangle solidOffsets, embedInsets;
bool solid, noClickActivate, hidden, isMaximised, alwaysOnTop, hoveringOverEmbed, queuedScrollUpdate, activationClick, noBringToFront; bool solid, noClickActivate, hidden, isMaximised, alwaysOnTop, hoveringOverEmbed, queuedScrollUpdate, activationClick, noBringToFront;
volatile bool closed; volatile bool closed;
@ -249,7 +249,7 @@ Window *WindowManager::FindWindowAtPosition(int cursorX, int cursorY, EsObjectID
EsRectangle bounds = ES_RECT_4PD(window->position.x, window->position.y, window->width, window->height); EsRectangle bounds = ES_RECT_4PD(window->position.x, window->position.y, window->width, window->height);
if (window->solid && !window->hidden && exclude != window->id if (window->solid && !window->hidden && exclude != window->id
&& EsRectangleContains(EsRectangleAdd(bounds, window->solidInsets), cursorX, cursorY) && EsRectangleContains(EsRectangleAdd(bounds, window->solidOffsets), cursorX, cursorY)
&& (!window->isMaximised || EsRectangleContains(workArea, cursorX, cursorY))) { && (!window->isMaximised || EsRectangleContains(workArea, cursorX, cursorY))) {
return window; return window;
} }
@ -791,25 +791,25 @@ bool Window::Move(EsRectangle rectangle, uint32_t flags) {
// TS("Move window\n"); // TS("Move window\n");
if (flags & ES_WINDOW_MOVE_ADJUST_TO_FIT_SCREEN) { if (flags & ES_WINDOW_MOVE_ADJUST_TO_FIT_SCREEN) {
rectangle = EsRectangleAdd(rectangle, solidOffsets);
if (rectangle.r > (int32_t) graphics.frameBuffer.width) { if (rectangle.r > (int32_t) graphics.frameBuffer.width) {
rectangle.l -= rectangle.r - graphics.frameBuffer.width; rectangle = Translate(rectangle, graphics.frameBuffer.width - rectangle.r, 0);
rectangle.r -= rectangle.r - graphics.frameBuffer.width;
} }
if (rectangle.b > (int32_t) graphics.frameBuffer.height) { if (rectangle.b > (int32_t) graphics.frameBuffer.height) {
rectangle.t -= rectangle.b - graphics.frameBuffer.height; rectangle = Translate(rectangle, 0, graphics.frameBuffer.height - rectangle.b);
rectangle.b -= rectangle.b - graphics.frameBuffer.height;
} }
if (rectangle.l < 0) { if (rectangle.l < 0) {
rectangle.r -= rectangle.l - 0; rectangle = Translate(rectangle, -rectangle.l, 0);
rectangle.l = 0;
} }
if (rectangle.t < 0) { if (rectangle.t < 0) {
rectangle.b -= rectangle.t - 0; rectangle = Translate(rectangle, 0, -rectangle.t);
rectangle.t = 0;
} }
rectangle = EsRectangleSubtract(rectangle, solidOffsets);
} }
size_t newWidth = rectangle.r - rectangle.l; size_t newWidth = rectangle.r - rectangle.l;

View File

@ -1,5 +1,5 @@
if [ ! -d "bin/freetype" ]; then if [ ! -d "bin/freetype" ]; then
echo " Downloading and building FreeType..." echo "Downloading and building FreeType..."
if [ ! -f "bin/freetype-2.9.tar" ]; then if [ ! -f "bin/freetype-2.9.tar" ]; then
curl https://mirrors.up.pt/pub/nongnu/freetype/freetype-2.9.tar.gz > bin/freetype-2.9.tar.gz 2> bin/freetype_dl.txt curl https://mirrors.up.pt/pub/nongnu/freetype/freetype-2.9.tar.gz > bin/freetype-2.9.tar.gz 2> bin/freetype_dl.txt

View File

@ -1,5 +1,5 @@
if [ ! -d "bin/harfbuzz" ]; then if [ ! -d "bin/harfbuzz" ]; then
echo " Downloading and building Harfbuzz..." echo "Downloading and building Harfbuzz..."
if [ ! -f "bin/harfbuzz-2.6.4.tar" ]; then if [ ! -f "bin/harfbuzz-2.6.4.tar" ]; then
curl https://www.freedesktop.org/software/harfbuzz/release/harfbuzz-2.6.4.tar.xz > bin/harfbuzz-2.6.4.tar.xz 2> bin/harfbuzz_dl.txt curl https://www.freedesktop.org/software/harfbuzz/release/harfbuzz-2.6.4.tar.xz > bin/harfbuzz-2.6.4.tar.xz 2> bin/harfbuzz_dl.txt

View File

@ -1431,10 +1431,11 @@ void DoCommand(const char *l) {
fprintf(stderr, "Crash report made at " ColorHighlight "%s" ColorNormal ".\n", cwd); fprintf(stderr, "Crash report made at " ColorHighlight "%s" ColorNormal ".\n", cwd);
} else if (0 == strcmp(l, "help") || 0 == strcmp(l, "h") || 0 == strcmp(l, "?")) { } else if (0 == strcmp(l, "help") || 0 == strcmp(l, "h") || 0 == strcmp(l, "?")) {
printf(ColorHighlight "\n=== Common Commands ===\n" ColorNormal); printf(ColorHighlight "\n=== Common Commands ===\n" ColorNormal);
printf("build (b) - Build.\n"); printf("build (b) - Build.\n");
printf("test (t2) - Build and run in Qemu.\n"); printf("qemu-with-kvm (k) - Build (with optimisations enabled) and run in Qemu with KVM.\n");
printf("vbox (v) - Build (with optimisations enabled) and run in VirtualBox.\n"); printf("test (t2) - Build and run in Qemu.\n");
printf("debug (d) - Build and run in Qemu (GDB server enabled).\n"); printf("vbox (v) - Build (with optimisations enabled) and run in VirtualBox.\n");
printf("debug (d) - Build and run in Qemu (GDB server enabled).\n");
printf("config - Open the local configuration editor.\n"); printf("config - Open the local configuration editor.\n");
printf("exit - Exit the build system.\n"); printf("exit - Exit the build system.\n");
@ -1448,7 +1449,7 @@ void DoCommand(const char *l) {
printf("live - Create a live USB or CDROM.\n"); printf("live - Create a live USB or CDROM.\n");
printf(ColorHighlight "\n=== Utilities ===\n" ColorNormal); printf(ColorHighlight "\n=== Utilities ===\n" ColorNormal);
printf("designer - Open the interface style designer.\n"); printf("designer2 - Open the interface style designer.\n");
printf("line-count - Count lines of code.\n"); printf("line-count - Count lines of code.\n");
printf("ascii <string> - Convert a string to a list of ASCII codepoints.\n"); printf("ascii <string> - Convert a string to a list of ASCII codepoints.\n");
printf("a2l <executable> - Translate addresses to lines.\n"); printf("a2l <executable> - Translate addresses to lines.\n");