diff options
Diffstat (limited to 'src/compositor/wayland_wrapper')
-rw-r--r-- | src/compositor/wayland_wrapper/qwlkeyboard.cpp | 56 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/qwlkeyboard_p.h | 1 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/qwlsurface.cpp | 8 |
3 files changed, 45 insertions, 20 deletions
diff --git a/src/compositor/wayland_wrapper/qwlkeyboard.cpp b/src/compositor/wayland_wrapper/qwlkeyboard.cpp index bcee40fb..06096566 100644 --- a/src/compositor/wayland_wrapper/qwlkeyboard.cpp +++ b/src/compositor/wayland_wrapper/qwlkeyboard.cpp @@ -72,6 +72,7 @@ Keyboard::Keyboard(Compositor *compositor, InputDevice *seat) , m_group() , m_pendingKeymap(false) #ifndef QT_NO_WAYLAND_XKB + , m_keymap_fd(-1) , m_state(0) #endif { @@ -349,42 +350,57 @@ void Keyboard::initXKB() createXKBKeymap(); } -void Keyboard::createXKBKeymap() +void Keyboard::createXKBState(xkb_keymap *keymap) { - if (!m_context) - return; - - if (m_state) - xkb_state_unref(m_state); - - struct xkb_rule_names rule_names = { strdup(qPrintable(m_keymap.rules())), - strdup(qPrintable(m_keymap.model())), - strdup(qPrintable(m_keymap.layout())), - strdup(qPrintable(m_keymap.variant())), - strdup(qPrintable(m_keymap.options())) }; - struct xkb_keymap *keymap = xkb_keymap_new_from_names(m_context, &rule_names, static_cast<xkb_keymap_compile_flags>(0)); - char *keymap_str = xkb_keymap_get_as_string(keymap, XKB_KEYMAP_FORMAT_TEXT_V1); - if (!keymap_str) - qFatal("Failed to compile global XKB keymap"); + if (!keymap_str) { + qWarning("Failed to compile global XKB keymap"); + return; + } m_keymap_size = strlen(keymap_str) + 1; + if (m_keymap_fd >= 0) + close(m_keymap_fd); m_keymap_fd = createAnonymousFile(m_keymap_size); - if (m_keymap_fd < 0) - qFatal("Failed to create anonymous file of size %lu", static_cast<unsigned long>(m_keymap_size)); + if (m_keymap_fd < 0) { + qWarning("Failed to create anonymous file of size %lu", static_cast<unsigned long>(m_keymap_size)); + return; + } m_keymap_area = static_cast<char *>(mmap(0, m_keymap_size, PROT_READ | PROT_WRITE, MAP_SHARED, m_keymap_fd, 0)); if (m_keymap_area == MAP_FAILED) { close(m_keymap_fd); - qFatal("Failed to map shared memory segment"); + m_keymap_fd = -1; + qWarning("Failed to map shared memory segment"); + return; } strcpy(m_keymap_area, keymap_str); free(keymap_str); + if (m_state) + xkb_state_unref(m_state); m_state = xkb_state_new(keymap); +} + +void Keyboard::createXKBKeymap() +{ + if (!m_context) + return; - xkb_keymap_unref(keymap); + struct xkb_rule_names rule_names = { strdup(qPrintable(m_keymap.rules())), + strdup(qPrintable(m_keymap.model())), + strdup(qPrintable(m_keymap.layout())), + strdup(qPrintable(m_keymap.variant())), + strdup(qPrintable(m_keymap.options())) }; + struct xkb_keymap *keymap = xkb_keymap_new_from_names(m_context, &rule_names, static_cast<xkb_keymap_compile_flags>(0)); + + if (keymap) { + createXKBState(keymap); + xkb_keymap_unref(keymap); + } else { + qWarning("Failed to load the '%s' XKB keymap.", qPrintable(m_keymap.layout())); + } free((char *)rule_names.rules); free((char *)rule_names.model); diff --git a/src/compositor/wayland_wrapper/qwlkeyboard_p.h b/src/compositor/wayland_wrapper/qwlkeyboard_p.h index d394aad1..c4df3126 100644 --- a/src/compositor/wayland_wrapper/qwlkeyboard_p.h +++ b/src/compositor/wayland_wrapper/qwlkeyboard_p.h @@ -127,6 +127,7 @@ private: #ifndef QT_NO_WAYLAND_XKB void initXKB(); void createXKBKeymap(); + void createXKBState(xkb_keymap *keymap); #endif Compositor *m_compositor; diff --git a/src/compositor/wayland_wrapper/qwlsurface.cpp b/src/compositor/wayland_wrapper/qwlsurface.cpp index 9b378908..d23c6aeb 100644 --- a/src/compositor/wayland_wrapper/qwlsurface.cpp +++ b/src/compositor/wayland_wrapper/qwlsurface.cpp @@ -436,6 +436,14 @@ void Surface::surface_destroy_resource(Resource *) m_extendedSurface = 0; } + if (transientParent()) { + foreach (Surface *surface, compositor()->surfaces()) { + if (surface->transientParent() == this) { + surface->setTransientParent(0); + } + } + } + m_destroyed = true; m_waylandSurface->destroy(); emit m_waylandSurface->surfaceDestroyed(); |