MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / HandleEventInternal

Method HandleEventInternal

Source/Engine/Platform/SDL/SDLPlatform.Linux.cpp:1114–1215  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1112}
1113
1114bool SDLWindow::HandleEventInternal(SDL_Event& event)
1115{
1116 switch (event.type)
1117 {
1118 case SDL_EVENT_WINDOW_MOVED:
1119 {
1120 if (SDLPlatform::UsesX11())
1121 {
1122 // X11 doesn't report any mouse events when mouse is over the caption area, send a simulated event instead...
1123 Float2 mousePosition;
1124 auto buttons = SDL_GetGlobalMouseState(&mousePosition.X, &mousePosition.Y);
1125 if ((buttons & SDL_BUTTON_MASK(SDL_BUTTON_LEFT)) != 0 && X11Impl::DraggedWindow == nullptr)
1126 {
1127 // TODO: verify mouse position, window focus
1128 bool result = false;
1129 OnLeftButtonHit(WindowHitCodes::Caption, result);
1130 if (result)
1131 X11Impl::DraggedWindow = this;
1132 }
1133 }
1134 break;
1135 }
1136 case SDL_EVENT_MOUSE_BUTTON_UP:
1137 case SDL_EVENT_MOUSE_MOTION:
1138 {
1139 if (SDLPlatform::UsesWayland() && WaylandImpl::DraggingActive)
1140 {
1141 // Ignore mouse events in dragged window
1142 return true;
1143 }
1144 break;
1145 }
1146 case SDL_EVENT_WINDOW_MOUSE_LEAVE:
1147 {
1148 OnDragLeave(); // Check for release of mouse button too?
1149 break;
1150 }
1151 case SDL_EVENT_DROP_BEGIN:
1152 case SDL_EVENT_DROP_POSITION:
1153 case SDL_EVENT_DROP_FILE:
1154 case SDL_EVENT_DROP_TEXT:
1155 case SDL_EVENT_DROP_COMPLETE:
1156 {
1157 if (SDLPlatform::UsesWayland())
1158 {
1159 // HACK: We can't use Wayland listeners due to SDL also using them at the same time causes
1160 // some of the events to drop and make it impossible to implement dragging on application side.
1161 // We can get enough information through SDL_EVENT_DROP_* events to fill in the blanks for the
1162 // drag and drop implementation.
1163
1164 auto dpiScale = GetDpiScale();
1165 const Float2 mousePos = Float2(event.drop.x * dpiScale, event.drop.y * dpiScale);
1166 DragDropEffect effect = DragDropEffect::None;
1167 String text(event.drop.data);
1168 LinuxDropTextData textData;
1169 LinuxDropFilesData filesData;
1170
1171 if (WaylandImpl::DraggingActive && (event.type == SDL_EVENT_DROP_BEGIN || event.type == SDL_EVENT_DROP_POSITION))

Callers

nothing calls this directly

Calls 5

GetDpiScaleFunction · 0.85
Float2Class · 0.85
ClientToScreenFunction · 0.85
OnMouseMoveMethod · 0.45
SplitMethod · 0.45

Tested by

no test coverage detected