mirror of
https://gitlab.com/cc-ru/ocelot/ocelot-desktop.git
synced 2025-12-20 11:09:20 +01:00
Remove the window focusing hack
This commit is contained in:
parent
1c19df7cf3
commit
87b13e66b1
@ -501,11 +501,6 @@ object UiHandler extends Logging {
|
|||||||
for (mouseTarget <- mouseTarget) {
|
for (mouseTarget <- mouseTarget) {
|
||||||
dispatchCapturing(mouseTarget)(event)
|
dispatchCapturing(mouseTarget)(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: this should be done in the event capturing phase in [[Window]] itself.
|
|
||||||
for (mouseTarget <- mouseTarget if !mouseTarget.isInstanceOf[Window]) {
|
|
||||||
focusParentWindow(mouseTarget.parent)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
dispatchEvent(hierarchy)(Capturing(event))
|
dispatchEvent(hierarchy)(Capturing(event))
|
||||||
dispatchEvent(hierarchy.reverseIterator)(event)
|
dispatchEvent(hierarchy.reverseIterator)(event)
|
||||||
@ -525,15 +520,6 @@ object UiHandler extends Logging {
|
|||||||
root.update()
|
root.update()
|
||||||
}
|
}
|
||||||
|
|
||||||
@tailrec
|
|
||||||
private def focusParentWindow(parent: Option[Widget]): Unit = {
|
|
||||||
parent match {
|
|
||||||
case Some(window: Window) => window.focus()
|
|
||||||
case Some(widget) => focusParentWindow(widget.parent)
|
|
||||||
case None =>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private def updateWindowSizeAndPosition(): Unit = {
|
private def updateWindowSizeAndPosition(): Unit = {
|
||||||
val width = Display.getWidth
|
val width = Display.getWidth
|
||||||
val height = Display.getHeight
|
val height = Display.getHeight
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import ocelot.desktop.Settings
|
|||||||
import ocelot.desktop.geometry.{Rect2D, Size2D, Vector2D}
|
import ocelot.desktop.geometry.{Rect2D, Size2D, Vector2D}
|
||||||
import ocelot.desktop.ui.UiHandler
|
import ocelot.desktop.ui.UiHandler
|
||||||
import ocelot.desktop.ui.event.handlers.MouseHandler
|
import ocelot.desktop.ui.event.handlers.MouseHandler
|
||||||
import ocelot.desktop.ui.event.{DragEvent, KeyEvent, MouseEvent}
|
import ocelot.desktop.ui.event.{Capturing, DragEvent, KeyEvent, MouseEvent}
|
||||||
import ocelot.desktop.ui.widget.Widget
|
import ocelot.desktop.ui.widget.Widget
|
||||||
import ocelot.desktop.util.Persistable
|
import ocelot.desktop.util.Persistable
|
||||||
import org.lwjgl.input.Keyboard
|
import org.lwjgl.input.Keyboard
|
||||||
@ -30,7 +30,7 @@ trait Window extends Widget with Persistable with MouseHandler {
|
|||||||
override protected def receiveDragEvents: Boolean = true
|
override protected def receiveDragEvents: Boolean = true
|
||||||
|
|
||||||
eventHandlers += {
|
eventHandlers += {
|
||||||
case MouseEvent(MouseEvent.State.Pressed, _) =>
|
case Capturing(MouseEvent(MouseEvent.State.Pressed, _)) =>
|
||||||
focus()
|
focus()
|
||||||
|
|
||||||
case ev @ DragEvent(DragEvent.State.Start, MouseEvent.Button.Left, mousePos) =>
|
case ev @ DragEvent(DragEvent.State.Start, MouseEvent.Button.Left, mousePos) =>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user