#include "DSWaylandSurface.h"
#include "DSStruct.h"
#include "DSWindowManager.h"
+#include "IDSBuffer.h"
namespace display_server {
__dsTextInputPrivate(nullptr),
__eventLoop(nullptr),
__waitUpdate(false),
- __rerunPanelShow(false)
+ __rerunPanelShow(false),
+ __wlSurface(nullptr)
{
__inputPanelSurface = new DSWaylandInputPanelSurface(__compositor, this);
__inputPanelFloating = new DSWaylandInputPanelFloating(this);
__dsTextInputPrivate(dsTextInputPrivate),
__eventLoop(nullptr),
__waitUpdate(false),
- __rerunPanelShow(false)
+ __rerunPanelShow(false),
+ __wlSurface(nullptr)
{
__inputPanelSurface = new DSWaylandInputPanelSurface(__compositor, this);
__inputPanelFloating = new DSWaylandInputPanelFloating(this);
__inputPanelSurface->createGlobal(client, inputPanelResource, id, surface);
/* TODO: Find window from surface and set some data */
+ DSWaylandSurface *wlSurface = DSWaylandSurface::fromWlResource((struct ::wl_resource *)surface);
+ __wlSurface = wlSurface;
+
+ if (!wlSurface)
+ {
+ DSLOG_WRN("DSWaylandInputPanel", "%p wl_surface has no DSWaylandSurface", surface);
+ return;
+ }
+
+ DSWindowManager *windowManager = DSWindowManager::getInstance();
+ windowManager->setWindowTitle(wlSurface, "Keyboard");
+ windowManager->setWindowAllowUserGeometry(wlSurface, true);
+ windowManager->releaseInstance();
+
+ wlSurface->registerCallbackSurfaceCommitted(this, std::bind(&DSWaylandInputPanel::__onSurfaceCommitted, this, std::placeholders::_1));
}
void DSWaylandInputPanel::clearSurfaces(void *inputPanelResource)
return __dsTextInputPrivate->getTextInputSurface();
}
+void DSWaylandInputPanel::__onSurfaceCommitted(std::shared_ptr<DSWaylandSurfaceCommitInfo> waylandSurfaceCommitInfo)
+{
+ if (!waylandSurfaceCommitInfo->bufferChanged())
+ return;
+
+ std::shared_ptr<IDSBuffer> buffer = waylandSurfaceCommitInfo->getBuffer();
+ std::shared_ptr<stSize> bufferSize = buffer->getSize();
+
+ DSWindowManager *windowManager = DSWindowManager::getInstance();
+ stGeometry geo = windowManager->getWindowGeometry(__wlSurface);
+
+ /* FIXME: This calc is only for 0 angle. Use others calc if window is rotated */
+ int nx = geo.x + (geo.w - bufferSize->w) / 2;
+ int ny = geo.y + geo.h - bufferSize->h;
+
+ windowManager->setWindowGeometry(__wlSurface, nx, ny, bufferSize->w, bufferSize->h);
+ windowManager->releaseInstance();
+}
+
void DSWaylandInputPanel::__onEventIdleEnterer(void *data)
{
}