| 158 | } |
| 159 | |
| 160 | bool SDLWindow::HandleEventInternal(SDL_Event& event) |
| 161 | { |
| 162 | switch (event.type) |
| 163 | { |
| 164 | case SDL_EVENT_WINDOW_MOVED: |
| 165 | { |
| 166 | // Quartz doesn't report any mouse events when mouse is over the caption area, send a simulated event instead... |
| 167 | Float2 mousePosition; |
| 168 | auto buttons = SDL_GetGlobalMouseState(&mousePosition.X, &mousePosition.Y); |
| 169 | if ((buttons & SDL_BUTTON_MASK(SDL_BUTTON_LEFT)) != 0) |
| 170 | { |
| 171 | if (MacImpl::DraggedWindow == nullptr) |
| 172 | { |
| 173 | // TODO: verify mouse position, window focus |
| 174 | bool result = false; |
| 175 | OnLeftButtonHit(WindowHitCodes::Caption, result); |
| 176 | if (result) |
| 177 | MacImpl::DraggedWindow = this; |
| 178 | } |
| 179 | else |
| 180 | { |
| 181 | Float2 mousePos = Platform::GetMousePosition(); |
| 182 | Input::Mouse->OnMouseMove(mousePos, this); |
| 183 | } |
| 184 | } |
| 185 | break; |
| 186 | } |
| 187 | case SDL_EVENT_MOUSE_BUTTON_UP: |
| 188 | case SDL_EVENT_MOUSE_BUTTON_DOWN: |
| 189 | { |
| 190 | if (MacImpl::LastMouseDragPosition.HasValue()) |
| 191 | { |
| 192 | // SDL reports wrong mouse position after dragging has ended |
| 193 | Float2 mouseClientPosition = ScreenToClient(MacImpl::LastMouseDragPosition.GetValue()); |
| 194 | event.button.x = mouseClientPosition.X; |
| 195 | event.button.y = mouseClientPosition.Y; |
| 196 | } |
| 197 | break; |
| 198 | } |
| 199 | case SDL_EVENT_MOUSE_MOTION: |
| 200 | { |
| 201 | if (MacImpl::LastMouseDragPosition.HasValue()) |
| 202 | MacImpl::LastMouseDragPosition.Reset(); |
| 203 | if (MacImpl::DraggedWindow != nullptr) |
| 204 | return true; |
| 205 | break; |
| 206 | } |
| 207 | case SDL_EVENT_WINDOW_MOUSE_LEAVE: |
| 208 | { |
| 209 | OnDragLeave(); // Check for release of mouse button too? |
| 210 | break; |
| 211 | } |
| 212 | case SDL_EVENT_DROP_BEGIN: |
| 213 | case SDL_EVENT_DROP_POSITION: |
| 214 | case SDL_EVENT_DROP_FILE: |
| 215 | case SDL_EVENT_DROP_TEXT: |
| 216 | case SDL_EVENT_DROP_COMPLETE: |
| 217 | { |
nothing calls this directly
no test coverage detected