77#include " kernel_processes/windows/launcher.h"
88#include " console/kio.h"
99#include " sysregs.h"
10+ #include " ui/graphic_types.h"
1011
1112clinkedlist_t *window_list;
1213window_frame *focused_window;
@@ -29,6 +30,25 @@ void init_window_manager(uintptr_t gpu_driver){
2930 main_gpu_driver = (GPUDriver*)gpu_driver;
3031}
3132
33+ int find_window (void *node, void *key){
34+ if (!node || !key) return -1 ;
35+ window_frame* frame = (window_frame*)node;
36+ uint16_t wid = *(uint16_t *)key;
37+ if (frame->win_id == wid) return 0 ;
38+ return -1 ;
39+ }
40+
41+ gpu_point convert_mouse_position (gpu_point point){
42+ process_t *p = get_current_proc ();
43+ clinkedlist_node_t *node = clinkedlist_find (window_list, PHYS_TO_VIRT_P (&p->win_id ), (typeof (find_window)*)PHYS_TO_VIRT_P (find_window));
44+ if (node && node->data ){
45+ window_frame* frame = (window_frame*)node->data ;
46+ if (point.x > frame->x && point.x < frame->x + frame->width && point.y > frame->y && point.y < frame->y + frame->height )
47+ return (gpu_point){ point.x -frame->x , point.y -frame->y };
48+ }
49+ return (gpu_point){};
50+ }
51+
3252extern " C" void create_window (uint32_t x, uint32_t y, uint32_t width, uint32_t height){
3353 if (win_ids == UINT16_MAX) return ;
3454 window_frame *frame = (window_frame*)malloc (sizeof (window_frame));
@@ -45,14 +65,6 @@ extern "C" void create_window(uint32_t x, uint32_t y, uint32_t width, uint32_t h
4565 dirty_windows = true ;
4666}
4767
48- int find_window (void *node, void *key){
49- if (!node || !key) return -1 ;
50- window_frame* frame = (window_frame*)node;
51- uint16_t wid = *(uint16_t *)key;
52- if (frame->win_id == wid) return 0 ;
53- return -1 ;
54- }
55-
5668void resize_window (uint32_t width, uint32_t height){
5769 process_t *p = get_current_proc ();
5870 clinkedlist_node_t *node = clinkedlist_find (window_list, PHYS_TO_VIRT_P (&p->win_id ), (typeof (find_window)*)PHYS_TO_VIRT_P (find_window));
0 commit comments