__zone = zone;
__zone->registerCallbackWindowCreated(this, std::bind(&DSSeat::__onWindowCreated, this, std::placeholders::_1));
+ __zone->registerCallbackWindowDestroy(this, std::bind(&DSSeat::__onWindowDestroy, this, std::placeholders::_1));
return true;
}
//TODO : emit MouseOut signal
//set the window as pointer focus window
- __pointer->setFocus(window);
+ if (window)
+ __pointer->setFocus(window);
//send pointer enter to the new pointer focus window
std::shared_ptr evMouseIn = std::make_shared<DSInputMouseEvent>(ev->getDevice(), DSInputEvent::MouseInEvent, ev->getTimestamp(), ev->getButton(), 0, 0, 0);
//get window whose geometry has intersection with the touch coordinates
auto window = getTopWindowOnPosition(ev->getX(), ev->getY());
+ DSLOG_INF("DSSeat", "window=%p, window.get()=%p", window, window.get());
+
//set the window as touch focus window
- __touch->setFocus(window);
+ if (window)
+ __touch->setFocus(window);
//TODO : emit touch focus changed signal
}
void DSSeat::__onWindowCreated(std::shared_ptr<DSWindow> window)
{
- DSLOG_INF("DSSeat", "window created : %p", window);
-
- if (window == nullptr)
- {
- DSLOG_ERR("DSSeat", "Invalid window is given.");
- return;
- }
+ DSLOG_INF("DSSeat", "window created : %p (%p)", window, window.get());
- /* Set newly created window as focus window for keyboard/pointer/touch temporarily */
- /* FIXME when DSWindowShell and DSWMPolicy has been implmented properly */
+ /* FIXME : get focus window for keyboard from DSWindowManager/DSWindowPolicy later */
if (__keyboard)
{
- DSLOG_INF("DSSeat", "keyboard focus : %p -> %p", __focusWin, window);
- __keyboard->setFocus(window);
- }
+ std::shared_ptr<DSWindow> focusWin = getTopWindow(__focusWin);
+ DSLOG_INF("DSSeat", "keyboard focus : %p -> %p", __focusWin ? __focusWin.get() : nullptr, focusWin ? focusWin.get() : nullptr);
- if (__pointer)
- {
- DSLOG_INF("DSSeat", "pointer focus : %p -> %p", __focusWin, window);
- __pointer->setFocus(window);
+ if (focusWin)
+ __keyboard->setFocus(focusWin);
}
+}
+
+void DSSeat::__onWindowDestroy(std::shared_ptr<DSWindow> window)
+{
+ DSLOG_INF("DSSeat", "window destroy : %p (%p)", window, window.get());
+
+ std::shared_ptr<DSWindow> currentFocus = nullptr;
+
+ if (__keyboard && (currentFocus = __keyboard->getFocus()) && (currentFocus.get() == window.get()))
+ __keyboard->resetFocus();
+ if (__pointer && (currentFocus = __pointer->getFocus()) && (currentFocus.get() == window.get()))
+ __pointer->resetFocus();
+ if (__touch && (currentFocus = __touch->getFocus()) && (currentFocus.get() == window.get()))
+ __touch->resetFocus();
- if (__touch)
+ /* FIXME : get focus window for keyboard from DSWindowManager/DSWindowPolicy later */
+ if (__keyboard)
{
- DSLOG_INF("DSSeat", "touch focus : %p -> %p", __focusWin, window);
- __touch->setFocus(window);
+ std::shared_ptr<DSWindow> focusWin = getTopWindow(window);
+ DSLOG_INF("DSSeat", "keyboard focus : %p -> %p", __focusWin ? __focusWin.get() : nullptr, focusWin ? focusWin.get() : nullptr);
+
+ if (focusWin)
+ __keyboard->setFocus(focusWin);
}
}
return EINA_TRUE;
}
+std::shared_ptr<DSWindow> DSSeat::getTopWindow(std::shared_ptr<DSWindow> winExcl)
+{
+ for (std::shared_ptr<DSWindow> w : __zone->getWindowList())
+ {
+ if (w && w.get() == winExcl.get())
+ continue;
+
+ /* We suppose that the window located at the top of the window stack is at the front of the list. */
+ return w;
+
+ }
+
+ return nullptr;
+}
+
std::shared_ptr<DSWindow> DSSeat::getTopWindowOnPosition(int x, int y)
{
stPosition wPos;