| 382 | } |
| 383 | |
| 384 | void WMInstance::MouseUp(){ |
| 385 | if(contextMenuActive && Lemon::Graphics::PointInRect(contextMenuBounds, input.mouse.pos)){ |
| 386 | Lemon::LemonEvent ev; |
| 387 | ev.event = Lemon::EventWindowCommand; |
| 388 | |
| 389 | ContextMenuItem item = menu.items[(input.mouse.pos.y - contextMenuBounds.y) / CONTEXT_ITEM_HEIGHT]; |
| 390 | |
| 391 | ev.windowCmd = item.id; |
| 392 | |
| 393 | printf("[LemonWM] Context Item: %s, ID: %d\n", item.name.c_str(), item.id); |
| 394 | PostEvent(ev, menu.owner); |
| 395 | |
| 396 | contextMenuActive = false; |
| 397 | return; |
| 398 | } |
| 399 | |
| 400 | contextMenuActive = resize = drag = false; |
| 401 | |
| 402 | if(active){ |
| 403 | if(PointInWindowProper(active, input.mouse.pos)){ |
| 404 | Lemon::LemonEvent ev; |
| 405 | ev.event = Lemon::EventMouseReleased; |
| 406 | ev.mousePos = input.mouse.pos - active->pos; |
| 407 | |
| 408 | if(!(active->flags & WINDOW_FLAGS_NODECORATION)) ev.mousePos = ev.mousePos - (vector2i_t){1, 25}; |
| 409 | |
| 410 | PostEvent(ev, active); |
| 411 | } else if (Lemon::Graphics::PointInRect(active->GetCloseRect(), input.mouse.pos)){ |
| 412 | Lemon::LemonEvent ev; |
| 413 | ev.event = Lemon::EventWindowClosed; |
| 414 | |
| 415 | PostEvent(ev, active); |
| 416 | } else if (Lemon::Graphics::PointInRect(active->GetMinimizeRect(), input.mouse.pos)){ |
| 417 | MinimizeWindow(active, true); |
| 418 | } |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | void WMInstance::MouseMove(){ |
| 423 | if(resize && active){ |
no test coverage detected