Skip to content

Commit 069b6f5

Browse files
committed
Fix mouse leaving marks when stuck to the right
~ Off by ones, when you get me ~ Unrelatedly, fixes a clang-format stupidity involving macros spanning multiple lines.
1 parent 1452e1a commit 069b6f5

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

.clang-format

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ AllowAllArgumentsOnNextLine: true
2929
PenaltyBreakAssignment: 100
3030
PenaltyExcessCharacter: 1
3131
SpaceBeforeParens: ControlStatementsExceptForEachMacros
32+
AlignEscapedNewlines: DontAlign
3233
SpaceBeforeSquareBrackets: false
3334
SpacesInContainerLiterals: true
3435
SpaceInEmptyBlock: true
3536
SpacesBeforeTrailingComments: 1
3637
SpaceAfterCStyleCast: true
37-
StatementMacros: ['UNUSED']
38+
StatementMacros: ['UNUSED']

kernel/include/kernel/sys.h

+9-7
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@
66

77
#define UNUSED(param) (void) param
88
#define PHYS_TO_VIRT(addr) ((addr) + KERNEL_BASE_VIRT)
9-
#define VIRT_TO_PHYS(addr) ((addr) -KERNEL_BASE_VIRT)
9+
#define VIRT_TO_PHYS(addr) ((addr) - KERNEL_BASE_VIRT)
1010

1111
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
12+
1213
#define printk(format, ...) printf("[\x1B[32m%s\x1B[0m] " format "\n", __FILENAME__, ##__VA_ARGS__)
13-
#define printke(format, ...) \
14+
15+
#define printke(format, ...) \
1416
printf("[\x1B[31;1m%s\x1B[0m] " format "\n", __FILENAME__, ##__VA_ARGS__)
1517

16-
#define BREAK() \
17-
do { \
18-
asm("xchgw %bx, %bx\n"); \
18+
#define BREAK() \
19+
do { \
20+
asm("xchgw %bx, %bx\n"); \
1921
} while (false)
2022

2123
/* Returns the next multiple of `align` greater than `n`, or `n` if it is a
@@ -40,12 +42,12 @@ static uint32_t divide_up(uint32_t n, uint32_t d) {
4042
}
4143

4244
/* Dumps any contiguous memory structure's bytes as a string of hex octets with
43-
* position numbers to aid in debugging efforts
45+
* position numbers to aid in debugging efforts.
4446
*/
4547
inline void dbg_buffer_dump(void* buff, size_t len) {
4648
for (size_t i = 0; i < len; i++) {
4749
printf("%d:%#2X ", i, ((uint8_t*) buff)[i]);
4850
}
4951

5052
printf("\n");
51-
}
53+
}

kernel/src/misc/wm/wm.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -451,14 +451,14 @@ void wm_draw_mouse(rect_t new) {
451451
uintptr_t addr = fb.address + new.top*fb.pitch + new.left*fb.bpp/8;
452452

453453
for (int32_t y = 0; y < new.bottom - new.top - 6; y++) {
454-
memset((void*) addr, 127, (y+1)*fb.bpp/8);
454+
memset((void*) addr, 127, (y + 1) * fb.bpp/8);
455455
addr += fb.pitch;
456456
}
457457

458458
addr += 4*fb.bpp/8;
459459

460460
for (int32_t y = 0; y < 6; y++) {
461-
memset((void*) addr, 127, 3*fb.bpp/8);
461+
memset((void*) addr, 127, 3 * fb.bpp/8);
462462
addr += fb.bpp/8;
463463
addr += fb.pitch;
464464
}
@@ -474,8 +474,8 @@ void wm_mouse_callback(mouse_t raw_curr) {
474474

475475
const mouse_t prev = mouse;
476476
const float sens = 0.7f;
477-
const int32_t max_x = fb.width - MOUSE_SIZE;
478-
const int32_t max_y = fb.height - MOUSE_SIZE;
477+
const int32_t max_x = fb.width - MOUSE_SIZE - 1;
478+
const int32_t max_y = fb.height - MOUSE_SIZE - 1;
479479

480480
// Move the cursor
481481
float dx = (raw_curr.x - raw_prev.x)*sens;
@@ -554,7 +554,7 @@ void wm_mouse_callback(mouse_t raw_curr) {
554554
event.mouse.position.top -= r.top;
555555
event.mouse.position.left -= r.left;
556556

557-
ringbuffer_write(under_cursor->events, sizeof(wm_event_t), (uint8_t*)&event);
557+
ringbuffer_write(under_cursor->events, sizeof(wm_event_t), (uint8_t*) &event);
558558
}
559559
}
560560

@@ -573,7 +573,7 @@ void wm_mouse_callback(mouse_t raw_curr) {
573573

574574
void wm_kbd_callback(kbd_event_t event) {
575575
wm_event_t kbd_event;
576-
576+
577577
if (!list_empty(&windows)) {
578578
list_t* iter;
579579
wm_window_t* win;

0 commit comments

Comments
 (0)