From 46d42d5fa49b92e21db2a02fc64b77d31133ee06 Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 7 Aug 2020 20:01:44 +0900 Subject: [PATCH 01/16] DSWaylandInputMethod: process wl_input_method_context requests Change-Id: I16e146c3d5cce0a004e462a4bfa16cd4d44bbb2f --- src/DSTextInput/DSTextInput.cpp | 111 +++++ src/DSTextInput/DSTextInputPrivate.h | 25 ++ src/DSWaylandServer/DSWaylandInputMethod.cpp | 264 ++++++++++- src/DSWaylandServer/DSWaylandInputMethod.h | 26 ++ src/DSWaylandServer/DSWaylandTextInput.cpp | 560 +++++++++++++++++++++++- src/DSWaylandServer/DSWaylandTextInput.h | 23 + src/DSWaylandServer/DSWaylandTextInputManager.h | 23 + src/DSWaylandServer/DSWaylandTextInputPrivate.h | 22 + tests/DSWaylandInputMethod-test.cpp | 323 ++++++++++++++ tests/DSWaylandTextInput-test.cpp | 308 +++++++++++++ tests/DSWaylandTextInputManager-test.cpp | 264 +++++++++++ 11 files changed, 1926 insertions(+), 23 deletions(-) diff --git a/src/DSTextInput/DSTextInput.cpp b/src/DSTextInput/DSTextInput.cpp index 9c2f256..784a8ea 100644 --- a/src/DSTextInput/DSTextInput.cpp +++ b/src/DSTextInput/DSTextInput.cpp @@ -139,6 +139,117 @@ void DSTextInputPrivate::predictionHintData(std::string key, std::string value) } +void DSTextInputPrivate::contextCommitString(unsigned int serial, std::string text) +{ + __wlTextInputManager->contextCommitString(serial, text); +} + +void DSTextInputPrivate::contextPreeditString(unsigned int serial, std::string text, std::string commit) +{ + __wlTextInputManager->contextPreeditString(serial, text, commit); +} + +void DSTextInputPrivate::contextPreeditStyling(int index, unsigned int length, unsigned int style) +{ + __wlTextInputManager->contextPreeditStyling(index, length, style); +} + +void DSTextInputPrivate::contextPreeditCursor(int index) +{ + __wlTextInputManager->contextPreeditCursor(index); +} + +void DSTextInputPrivate::contextDeleteSurroundingText(int index, unsigned int length) +{ + __wlTextInputManager->contextDeleteSurroundingText(index, length); +} + +void DSTextInputPrivate::contextCursorPosition(int index, int anchor) +{ + __wlTextInputManager->contextCursorPosition(index, anchor); +} + +void DSTextInputPrivate::contextModifiersMap(std::string map) +{ + __wlTextInputManager->contextModifiersMap(map); +} + +void DSTextInputPrivate::contextKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers) +{ + __wlTextInputManager->contextKeysym(serial, time, sym, state, modifiers); +} + +void DSTextInputPrivate::contextLanguage(unsigned int serial, std::string language) +{ + __wlTextInputManager->contextLanguage(serial, language); +} + +void DSTextInputPrivate::contextTextDirection(unsigned int serial, unsigned int direction) +{ + __wlTextInputManager->contextTextDirection(serial, direction); +} + +void DSTextInputPrivate::contextSelectionRegion(unsigned int serial, int start, int end) +{ + __wlTextInputManager->contextSelectionRegion(serial, start, end); +} + +void DSTextInputPrivate::contextPrivateCommand(unsigned int serial, std::string command) +{ + __wlTextInputManager->contextPrivateCommand(serial, command); +} + +void DSTextInputPrivate::contextUpdateInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength) +{ + __wlTextInputManager->contextUpdateInputPanelData(serial, inputPanelData, inputPanelDataLength); +} + +void DSTextInputPrivate::contextShowInputPanel() +{ + __wlTextInputManager->contextShowInputPanel(); +} + +void DSTextInputPrivate::contextHideInputPanel() +{ + __wlTextInputManager->contextHideInputPanel(); +} + +void DSTextInputPrivate::contextGetSelectionText(int fd) +{ + __wlTextInputManager->contextGetSelectionText(fd); +} + +void DSTextInputPrivate::contextGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd) +{ + __wlTextInputManager->contextGetSurroundingText(maxlenBefore, maxlenAfter, fd); +} + +void DSTextInputPrivate::contextFilterKeyEventDone(unsigned int serial, unsigned int state) +{ + __wlTextInputManager->contextFilterKeyEventDone(serial, state); +} + +void DSTextInputPrivate::contextUpdateIseGeometry(unsigned int x, unsigned int y, unsigned int width, unsigned int height) +{ + __wlTextInputManager->contextUpdateIseGeometry(x, y, width, height); +} + +void DSTextInputPrivate::contextRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit) +{ + __wlTextInputManager->contextRecaptureString(serial, index, length, preedit, preeditCommit, commit); +} + +void DSTextInputPrivate::contextInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value) +{ + __wlTextInputManager->contextInputPanelEvent(serial, eventType, value); +} + +void DSTextInputPrivate::contextCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes) +{ + __wlTextInputManager->contextCommitContent(serial, content, description, mimeTypes); +} + + DSTextInput::DSTextInput() : DS_INIT_PRIVATE_PTR(DSTextInput) { diff --git a/src/DSTextInput/DSTextInputPrivate.h b/src/DSTextInput/DSTextInputPrivate.h index dec7d69..a380fd8 100644 --- a/src/DSTextInput/DSTextInputPrivate.h +++ b/src/DSTextInput/DSTextInputPrivate.h @@ -34,6 +34,7 @@ public: void setInputPanelState(InputPanelState state); InputPanelState getInputPanelState(); + /* DSWaylandTextInput request */ void activateTextInput(DSWaylandTextInput *wlTextInput, int id); void deactivateTextInput(DSWaylandTextInput *wlTextInput); void showInputPanel(DSWaylandTextInput *wlTextInput, int id); @@ -56,6 +57,30 @@ public: void finalizeContent(std::string text, unsigned int cursorPosition); void predictionHintData(std::string key, std::string value); + /* DSWaylandInputMethodContext request */ + void contextCommitString(unsigned int serial, std::string text); + void contextPreeditString(unsigned int serial, std::string text, std::string commit); + void contextPreeditStyling(int index, unsigned int length, unsigned int style); + void contextPreeditCursor(int index); + void contextDeleteSurroundingText(int index, unsigned int length); + void contextCursorPosition(int index, int anchor); + void contextModifiersMap(std::string map); + void contextKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers); + void contextLanguage(unsigned int serial, std::string language); + void contextTextDirection(unsigned int serial, unsigned int direction); + void contextSelectionRegion(unsigned int serial, int start, int end); + void contextPrivateCommand(unsigned int serial, std::string command); + void contextUpdateInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength); + void contextShowInputPanel(); + void contextHideInputPanel(); + void contextGetSelectionText(int fd); + void contextGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd); + void contextFilterKeyEventDone(unsigned int serial, unsigned int state); + void contextUpdateIseGeometry(unsigned int x, unsigned int y, unsigned int width, unsigned int height); + void contextRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit); + void contextInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value); + void contextCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes); + private: DSWaylandCompositor *__wlCompositor; DSWaylandTextInputManager *__wlTextInputManager; diff --git a/src/DSWaylandServer/DSWaylandInputMethod.cpp b/src/DSWaylandServer/DSWaylandInputMethod.cpp index 9a9acbf..67d82e3 100644 --- a/src/DSWaylandServer/DSWaylandInputMethod.cpp +++ b/src/DSWaylandServer/DSWaylandInputMethod.cpp @@ -114,106 +114,190 @@ void DSWaylandInputMethodContextPrivate::input_method_context_destroy(Resource * void DSWaylandInputMethodContextPrivate::input_method_context_commit_string(Resource *resource, uint32_t serial, const std::string &text) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextCommitString(serial, text); } void DSWaylandInputMethodContextPrivate::input_method_context_preedit_string(Resource *resource, uint32_t serial, const std::string &text, const std::string &commit) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextPreeditString(serial, text, commit); } void DSWaylandInputMethodContextPrivate::input_method_context_preedit_styling(Resource *resource, uint32_t index, uint32_t length, uint32_t style) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextPreeditStyling(index, length, style); } void DSWaylandInputMethodContextPrivate::input_method_context_preedit_cursor(Resource *resource, int32_t index) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextPreeditCursor(index); } void DSWaylandInputMethodContextPrivate::input_method_context_delete_surrounding_text(Resource *resource, int32_t index, uint32_t length) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextDeleteSurroundingText(index, length); } void DSWaylandInputMethodContextPrivate::input_method_context_cursor_position(Resource *resource, int32_t index, int32_t anchor) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextCursorPosition(index, anchor); } void DSWaylandInputMethodContextPrivate::input_method_context_modifiers_map(Resource *resource, wl_array *map) { + DS_GET_PUB(DSWaylandInputMethodContext); + std::string mapData = (char *)map->data; + + pub->__inputMethod->contextModifiersMap(mapData); } void DSWaylandInputMethodContextPrivate::input_method_context_keysym(Resource *resource, uint32_t serial, uint32_t time, uint32_t sym, uint32_t state, uint32_t modifiers) { + DS_GET_PUB(DSWaylandInputMethodContext); + + if (pub->__inputMethod->contextActivated()) + { + pub->__inputMethod->contextKeysym(serial, time, sym, state, modifiers); + } + else + { + /* TODO: generate key events for server */ + } } void DSWaylandInputMethodContextPrivate::input_method_context_grab_keyboard(Resource *resource, uint32_t keyboard) { + /* TODO: this is optional, currently disable this option */ } void DSWaylandInputMethodContextPrivate::input_method_context_key(Resource *resource, uint32_t serial, uint32_t time, uint32_t key, uint32_t state) { + /* Nothing to do in this request */ } void DSWaylandInputMethodContextPrivate::input_method_context_modifiers(Resource *resource, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) { + /* Nothing to do in this request */ } void DSWaylandInputMethodContextPrivate::input_method_context_language(Resource *resource, uint32_t serial, const std::string &language) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextLanguage(serial, language); } void DSWaylandInputMethodContextPrivate::input_method_context_text_direction(Resource *resource, uint32_t serial, uint32_t direction) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextTextDirection(serial, direction); } void DSWaylandInputMethodContextPrivate::input_method_context_selection_region(Resource *resource, uint32_t serial, int32_t start, int32_t end) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextSelectionRegion(serial, start, end); } void DSWaylandInputMethodContextPrivate::input_method_context_private_command(Resource *resource, uint32_t serial, const std::string &command) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextPrivateCommand(serial, command); } void DSWaylandInputMethodContextPrivate::input_method_context_update_input_panel_data(Resource *resource, uint32_t serial, const std::string &input_panel_data, uint32_t input_panel_data_length) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextUpdateInputPanelData(serial, input_panel_data, input_panel_data_length); } void DSWaylandInputMethodContextPrivate::input_method_context_hide_input_panel(Resource *resource, uint32_t serial) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextHideInputPanel(serial); } void DSWaylandInputMethodContextPrivate::input_method_context_get_selection_text(Resource *resource, int32_t fd) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextGetSelectionText(fd); + + close(fd); } void DSWaylandInputMethodContextPrivate::input_method_context_get_surrounding_text(Resource *resource, uint32_t maxlen_before, uint32_t maxlen_after, int32_t fd) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextGetSurroundingText(maxlen_before, maxlen_after, fd); + + close(fd); } void DSWaylandInputMethodContextPrivate::input_method_context_filter_key_event_done(Resource *resource, uint32_t serial, uint32_t state) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextFilterKeyEventDone(serial, state); } void DSWaylandInputMethodContextPrivate::input_method_context_update_ise_geometry(Resource *resource, uint32_t serial, uint32_t x, uint32_t y, uint32_t width, uint32_t height) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextUpdateIseGeometry(serial, x, y, width, height); } void DSWaylandInputMethodContextPrivate::input_method_context_recapture_string(Resource *resource, uint32_t serial, int32_t index, uint32_t length, const std::string &preedit, const std::string &preedit_commit, const std::string &commit) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextRecaptureString(serial, index, length, preedit, preedit_commit, commit); } void DSWaylandInputMethodContextPrivate::input_method_context_input_panel_event(Resource *resource, uint32_t serial, uint32_t event_type, uint32_t value) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextInputPanelEvent(serial, event_type, value); } void DSWaylandInputMethodContextPrivate::input_method_context_commit_content(Resource *resource, uint32_t serial, const std::string &content, const std::string &description, const std::string &mime_types) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextCommitContent(serial, content, description, mime_types); } void DSWaylandInputMethodContextPrivate::input_method_context_update_candidate_state(Resource *resource, uint32_t state) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextUpdateCandidateState(state); } void DSWaylandInputMethodContextPrivate::input_method_context_reshow_input_panel(Resource *resource) { + DS_GET_PUB(DSWaylandInputMethodContext); + + pub->__inputMethod->contextReshowInputPanel(); } @@ -463,7 +547,8 @@ DSWaylandInputMethod::DSWaylandInputMethod(DSWaylandCompositor *compositor) : DSObject(), _d_ptr(std::make_unique(this, compositor)), __dsTextInputPrivate(nullptr), __compositor(compositor), - __activateContext(nullptr) + __activateContext(nullptr), + __candidateState(0) { __inputMethodContext = new DSWaylandInputMethodContext(compositor, this); } @@ -486,6 +571,12 @@ DSWaylandInputMethodContext* DSWaylandInputMethod::getContext() return __inputMethodContext; } +bool DSWaylandInputMethod::contextActivated() +{ + if (__activateContext) return true; + else return false; +} + void DSWaylandInputMethod::activate(int textInputId) { DS_GET_PRIV(DSWaylandInputMethod); @@ -612,5 +703,176 @@ void DSWaylandInputMethod::predictionHintData(std::string key, std::string value __inputMethodContext->sendPredictionHintData(__activateContext, key, value); } +void DSWaylandInputMethod::contextCommitString(unsigned int serial, std::string text) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextCommitString(serial, text); +} + +void DSWaylandInputMethod::contextPreeditString(unsigned int serial, std::string text, std::string commit) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextPreeditString(serial, text, commit); +} + +void DSWaylandInputMethod::contextPreeditStyling(int index, unsigned int length, unsigned int style) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextPreeditStyling(index, length, style); +} + +void DSWaylandInputMethod::contextPreeditCursor(int index) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextPreeditCursor(index); +} + +void DSWaylandInputMethod::contextDeleteSurroundingText(int index, unsigned int length) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextDeleteSurroundingText(index, length); +} + +void DSWaylandInputMethod::contextCursorPosition(int index, int anchor) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextCursorPosition(index, anchor); +} + +void DSWaylandInputMethod::contextModifiersMap(std::string map) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextModifiersMap(map); +} + +void DSWaylandInputMethod::contextKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextKeysym(serial, time, sym, state, modifiers); +} + +void DSWaylandInputMethod::contextLanguage(unsigned int serial, std::string language) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextLanguage(serial, language); +} + +void DSWaylandInputMethod::contextTextDirection(unsigned int serial, unsigned int direction) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextTextDirection(serial, direction); +} + +void DSWaylandInputMethod::contextSelectionRegion(unsigned int serial, int start, int end) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextSelectionRegion(serial, start, end); +} + +void DSWaylandInputMethod::contextPrivateCommand(unsigned int serial, std::string command) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextPrivateCommand(serial, command); +} + +void DSWaylandInputMethod::contextUpdateInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextUpdateInputPanelData(serial, inputPanelData, inputPanelDataLength); +} + +void DSWaylandInputMethod::contextHideInputPanel(unsigned int serial) +{ + DS_GET_PRIV(DSWaylandInputMethod); + + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextHideInputPanel(); + + if (__activateContext) + { + priv->hideInputPanel(__activateContext); + } +} + +void DSWaylandInputMethod::contextGetSelectionText(int fd) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextGetSelectionText(fd); +} + +void DSWaylandInputMethod::contextGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextGetSurroundingText(maxlenBefore, maxlenAfter, fd); +} + +void DSWaylandInputMethod::contextFilterKeyEventDone(unsigned int serial, unsigned int state) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextFilterKeyEventDone(serial, state); +} + +void DSWaylandInputMethod::contextUpdateIseGeometry(unsigned int serial, unsigned int x, unsigned int y, unsigned int width, unsigned int height) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextUpdateIseGeometry(x, y, width, height); +} + +void DSWaylandInputMethod::contextRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextRecaptureString(serial, index, length, preedit, preeditCommit, commit); +} + +void DSWaylandInputMethod::contextInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextInputPanelEvent(serial, eventType, value); +} + +void DSWaylandInputMethod::contextCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes) +{ + if (__dsTextInputPrivate) + __dsTextInputPrivate->contextCommitContent(serial, content, description, mimeTypes); +} + +void DSWaylandInputMethod::contextUpdateCandidateState(unsigned int state) +{ + if (!__dsTextInputPrivate) return; + + unsigned int prevCandidateState = __candidateState; + __candidateState = state; + + if (__dsTextInputPrivate->getInputPanelState() == DSTextInputPrivate::InputPanelStateDidHide) + { + prevCandidateState = (unsigned int)false; + } + + if (!state) + { + /* TODO: need to check g_disable_show_panel */ + if (!__candidateState && prevCandidateState) + { + __dsTextInputPrivate->contextHideInputPanel(); + } + } + else + { + /* TODO: need to check g_disable_show_panel */ + if (__candidateState && !prevCandidateState) + { + __dsTextInputPrivate->contextShowInputPanel(); + int x = 0, y = 0, w = 0, h = 0; + /* TODO: get gemetry from input panel */ + __dsTextInputPrivate->contextUpdateIseGeometry(x, y, w, h); + } + } +} + +void DSWaylandInputMethod::contextReshowInputPanel() +{ + /* TODO: update input panel */ +} + } diff --git a/src/DSWaylandServer/DSWaylandInputMethod.h b/src/DSWaylandServer/DSWaylandInputMethod.h index 4360e50..d2a9298 100644 --- a/src/DSWaylandServer/DSWaylandInputMethod.h +++ b/src/DSWaylandServer/DSWaylandInputMethod.h @@ -21,6 +21,7 @@ public: ~DSWaylandInputMethod() override; DSWaylandInputMethodContext* getContext(); + bool contextActivated(); void activate(int textInputId); void deactivate(); void showInputPanel(int textInputId); @@ -43,6 +44,30 @@ public: void finalizeContent(std::string text, unsigned int cursorPosition); void predictionHintData(std::string key, std::string value); + void contextCommitString(unsigned int serial, std::string text); + void contextPreeditString(unsigned int serial, std::string text, std::string commit); + void contextPreeditStyling(int index, unsigned int length, unsigned int style); + void contextPreeditCursor(int index); + void contextDeleteSurroundingText(int index, unsigned int length); + void contextCursorPosition(int index, int anchor); + void contextModifiersMap(std::string map); + void contextKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers); + void contextLanguage(unsigned int serial, std::string language); + void contextTextDirection(unsigned int serial, unsigned int direction); + void contextSelectionRegion(unsigned int serial, int start, int end); + void contextPrivateCommand(unsigned int serial, std::string command); + void contextUpdateInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength); + void contextHideInputPanel(unsigned int serial); + void contextGetSelectionText(int fd); + void contextGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd); + void contextFilterKeyEventDone(unsigned int serial, unsigned int state); + void contextUpdateIseGeometry(unsigned int serial, unsigned int x, unsigned int y, unsigned int width, unsigned int height); + void contextRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit); + void contextInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value); + void contextCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes); + void contextUpdateCandidateState(unsigned int state); + void contextReshowInputPanel(); + protected: private: @@ -50,6 +75,7 @@ private: DSWaylandCompositor *__compositor; DSWaylandInputMethodContext *__inputMethodContext; void *__activateContext; + unsigned int __candidateState; }; } diff --git a/src/DSWaylandServer/DSWaylandTextInput.cpp b/src/DSWaylandServer/DSWaylandTextInput.cpp index bab5d34..cce0ebf 100644 --- a/src/DSWaylandServer/DSWaylandTextInput.cpp +++ b/src/DSWaylandServer/DSWaylandTextInput.cpp @@ -60,6 +60,117 @@ int DSWaylandTextInputManager::allocTextInputId() return __textInputId++; } +void DSWaylandTextInputManager::contextCommitString(unsigned int serial, std::string text) +{ + __textInput->sendCommitString(serial, text); +} + +void DSWaylandTextInputManager::contextPreeditString(unsigned int serial, std::string text, std::string commit) +{ + __textInput->sendPreeditString(serial, text, commit); +} + +void DSWaylandTextInputManager::contextPreeditStyling(int index, unsigned int length, unsigned int style) +{ + __textInput->sendPreeditStyling(index, length, style); +} + +void DSWaylandTextInputManager::contextPreeditCursor(int index) +{ + __textInput->sendPreeditCursor(index); +} + +void DSWaylandTextInputManager::contextDeleteSurroundingText(int index, unsigned int length) +{ + __textInput->sendDeleteSurroundingText(index, length); +} + +void DSWaylandTextInputManager::contextCursorPosition(int index, int anchor) +{ + __textInput->sendCursorPosition(index, anchor); +} + +void DSWaylandTextInputManager::contextModifiersMap(std::string map) +{ + __textInput->sendModifiersMap(map); +} + +void DSWaylandTextInputManager::contextKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers) +{ + __textInput->sendKeysym(serial, time, sym, state, modifiers); +} + +void DSWaylandTextInputManager::contextLanguage(unsigned int serial, std::string language) +{ + __textInput->sendLanguage(serial, language); +} + +void DSWaylandTextInputManager::contextTextDirection(unsigned int serial, unsigned int direction) +{ + __textInput->sendTextDirection(serial, direction); +} + +void DSWaylandTextInputManager::contextSelectionRegion(unsigned int serial, int start, int end) +{ + __textInput->sendSelectionRegion(serial, start, end); +} + +void DSWaylandTextInputManager::contextPrivateCommand(unsigned int serial, std::string command) +{ + __textInput->sendPrivateCommand(serial, command); +} + +void DSWaylandTextInputManager::contextUpdateInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength) +{ + __textInput->sendInputPanelData(serial, inputPanelData, inputPanelDataLength); +} + +void DSWaylandTextInputManager::contextShowInputPanel() +{ + __textInput->showInputPanel(); +} + +void DSWaylandTextInputManager::contextHideInputPanel() +{ + __textInput->hideInputPanel(); +} + +void DSWaylandTextInputManager::contextGetSelectionText(int fd) +{ + __textInput->sendGetSelectionText(fd); +} + +void DSWaylandTextInputManager::contextGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd) +{ + __textInput->sendGetSurroundingText(maxlenBefore, maxlenAfter, fd); +} + +void DSWaylandTextInputManager::contextFilterKeyEventDone(unsigned int serial, unsigned int state) +{ + __textInput->sendFilterKeyEventDone(serial, state); +} + +void DSWaylandTextInputManager::contextUpdateIseGeometry(unsigned int x, unsigned int y, unsigned int width, unsigned int height) +{ + __textInput->sendInputPanelGeometry(x, y, width, height); +} + +void DSWaylandTextInputManager::contextRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit) +{ + __textInput->sendRecaptureString(serial, index, length, preedit, preeditCommit, commit); +} + +void DSWaylandTextInputManager::contextInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value) +{ + __textInput->sendInputPanelEvent(serial, eventType, value); +} + +void DSWaylandTextInputManager::contextCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes) +{ + __textInput->sendCommitContent(serial, content, description, mimeTypes); +} + + DSWaylandTextInputPrivate::DSWaylandTextInputPrivate(DSWaylandTextInput *p_ptr, DSWaylandCompositor *compositor) : DSObjectPrivate(p_ptr), __p_ptr(p_ptr), @@ -102,6 +213,34 @@ int DSWaylandTextInputPrivate::getResourceId(Resource *resource) return id; } +void DSWaylandTextInputPrivate::showInputPanel(void *resource) +{ + DS_GET_PUB(DSWaylandTextInput); + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + Resource *privateResource = Resource::fromResource((struct ::wl_resource *)resource); + + /* NOTE: bug, sometimes in this time, input_method_context is not exist */ + int id = getResourceId(privateResource); + + if (id >= 0) + { + pub->__dsTextInputPrivate->showInputPanel(pub, id); + __showClient = privateResource->client(); + /* TODO: inputpanel wait update set */ + if (pub->__dsTextInputPrivate->getInputPanelState() == DSTextInputPrivate::InputPanelStateWillHide) + { + send_private_command(privateResource->handle, 0, "CONFORMANT_RESTORE"); + } + pub->__dsTextInputPrivate->setInputPanelState(DSTextInputPrivate::InputPanelStateWillShow); + /* TODO: inputpanel transient for set */ + } +} + void DSWaylandTextInputPrivate::text_input_destroy(Resource *resource) { __resourceIdMap.erase(resource); @@ -141,28 +280,7 @@ void DSWaylandTextInputPrivate::text_input_deactivate(Resource *resource, struct void DSWaylandTextInputPrivate::text_input_show_input_panel(Resource *resource) { - DS_GET_PUB(DSWaylandTextInput); - if (!__activatedResource) - { - DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); - return; - } - - /* NOTE: bug, sometimes in this time, input_method_context is not exist */ - int id = getResourceId(resource); - - if (id >= 0) - { - pub->__dsTextInputPrivate->showInputPanel(pub, id); - __showClient = resource->client(); - /* TODO: inputpanel wait update set */ - if (pub->__dsTextInputPrivate->getInputPanelState() == DSTextInputPrivate::InputPanelStateWillHide) - { - send_private_command(resource->handle, 0, "CONFORMANT_RESTORE"); - } - pub->__dsTextInputPrivate->setInputPanelState(DSTextInputPrivate::InputPanelStateWillShow); - /* TODO: inputpanel transient for set */ - } + showInputPanel(resource->handle); } void DSWaylandTextInputPrivate::hideInputPanel(Resource *resource, bool forceHide) @@ -463,6 +581,226 @@ void DSWaylandTextInputPrivate::text_input_prediction_hint_data(Resource *resour pub->__dsTextInputPrivate->predictionHintData(key, value); } +void DSWaylandTextInputPrivate::sendCommitString(unsigned int serial, std::string text) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_commit_string(__activatedResource->handle, serial, text); +} + +void DSWaylandTextInputPrivate::sendPreeditString(unsigned int serial, std::string text, std::string commit) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_preedit_string(__activatedResource->handle, serial, text, commit); +} + +void DSWaylandTextInputPrivate::sendPreeditStyling(int index, unsigned int length, unsigned int style) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_preedit_styling(__activatedResource->handle, index, length, style); +} + +void DSWaylandTextInputPrivate::sendPreeditCursor(int index) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_preedit_cursor(__activatedResource->handle, index); +} + +void DSWaylandTextInputPrivate::sendDeleteSurroundingText(int index, unsigned int length) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_delete_surrounding_text(__activatedResource->handle, index, length); +} + +void DSWaylandTextInputPrivate::sendCursorPosition(int index, int anchor) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_cursor_position(__activatedResource->handle, index, anchor); +} + +void DSWaylandTextInputPrivate::sendModifiersMap(std::string map) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_modifiers_map(__activatedResource->handle, map); +} + +void DSWaylandTextInputPrivate::sendKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_keysym(__activatedResource->handle, serial, time, sym, state, modifiers); +} + +void DSWaylandTextInputPrivate::sendLanguage(unsigned int serial, std::string language) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_language(__activatedResource->handle, serial, language); +} + +void DSWaylandTextInputPrivate::sendTextDirection(unsigned int serial, unsigned int direction) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_text_direction(__activatedResource->handle, serial, direction); +} + +void DSWaylandTextInputPrivate::sendSelectionRegion(unsigned int serial, int start, int end) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_selection_region(__activatedResource->handle, serial, start, end); +} + +void DSWaylandTextInputPrivate::sendPrivateCommand(unsigned int serial, std::string command) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_private_command(__activatedResource->handle, serial, command); +} + +void DSWaylandTextInputPrivate::sendInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_input_panel_data(__activatedResource->handle, serial, inputPanelData, inputPanelDataLength); +} + +void DSWaylandTextInputPrivate::sendGetSelectionText(int fd) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_get_selection_text(__activatedResource->handle, fd); +} + +void DSWaylandTextInputPrivate::sendGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_get_surrounding_text(__activatedResource->handle, maxlenBefore, maxlenAfter, fd); +} + +void DSWaylandTextInputPrivate::sendFilterKeyEventDone(unsigned int serial, unsigned int state) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_filter_key_event_done(__activatedResource->handle, serial, state); +} + +void DSWaylandTextInputPrivate::sendInputPanelGeometry(unsigned int x, unsigned int y, unsigned int width, unsigned int height) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_input_panel_geometry(__activatedResource->handle, x, y, width, height); +} + +void DSWaylandTextInputPrivate::sendRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_recapture_string(__activatedResource->handle, serial, index, length, preedit, preeditCommit, commit); +} + +void DSWaylandTextInputPrivate::sendInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_input_panel_event(__activatedResource->handle, serial, eventType, value); +} + +void DSWaylandTextInputPrivate::sendCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes) +{ + if (!__activatedResource) + { + DSLOG_WRN("DSWaylandTextInput", "No Text Input For Resource"); + return; + } + + send_commit_content(__activatedResource->handle, serial, content, description, mimeTypes); +} + DSWaylandTextInput::DSWaylandTextInput(DSWaylandCompositor *compositor, DSWaylandTextInputManager *textInputManager) : DSObject(), _d_ptr(std::make_unique(this, compositor)), @@ -491,4 +829,182 @@ void DSWaylandTextInput::createGlobal(void *client, int id) priv->createGlobal(client, id); } +void DSWaylandTextInput::showInputPanel() +{ + DS_GET_PRIV(DSWaylandTextInput); + + if (priv->__activatedResource) + priv->showInputPanel(priv->__activatedResource); +} + +void DSWaylandTextInput::hideInputPanel() +{ + DS_GET_PRIV(DSWaylandTextInput); + + if (priv->__activatedResource) + priv->hideInputPanel(priv->__activatedResource, false); +} + +void DSWaylandTextInput::sendCommitString(unsigned int serial, std::string text) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendCommitString(serial, text); +} + +void DSWaylandTextInput::sendPreeditString(unsigned int serial, std::string text, std::string commit) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendPreeditString(serial, text, commit); +} + +void DSWaylandTextInput::sendPreeditStyling(int index, unsigned int length, unsigned int style) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendPreeditStyling(index, length, style); +} + +void DSWaylandTextInput::sendPreeditCursor(int index) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendPreeditCursor(index); +} + +void DSWaylandTextInput::sendDeleteSurroundingText(int index, unsigned int length) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendDeleteSurroundingText(index, length); +} + +void DSWaylandTextInput::sendCursorPosition(int index, int anchor) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendCursorPosition(index, anchor); +} + +void DSWaylandTextInput::sendModifiersMap(std::string map) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendModifiersMap(map); +} + +void DSWaylandTextInput::sendKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendKeysym(serial, time, sym, state, modifiers); +} + +void DSWaylandTextInput::sendLanguage(unsigned int serial, std::string language) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendLanguage(serial, language); +} + +void DSWaylandTextInput::sendTextDirection(unsigned int serial, unsigned int direction) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendTextDirection(serial, direction); +} + +void DSWaylandTextInput::sendSelectionRegion(unsigned int serial, int start, int end) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendSelectionRegion(serial, start, end); +} + +void DSWaylandTextInput::sendPrivateCommand(unsigned int serial, std::string command) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendPrivateCommand(serial, command); +} + +void DSWaylandTextInput::sendInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendInputPanelData(serial, inputPanelData, inputPanelDataLength); +} + +void DSWaylandTextInput::sendGetSelectionText(int fd) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendGetSelectionText(fd); +} + +void DSWaylandTextInput::sendGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendGetSurroundingText(maxlenBefore, maxlenAfter, fd); +} + +void DSWaylandTextInput::sendFilterKeyEventDone(unsigned int serial, unsigned int state) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendFilterKeyEventDone(serial, state); +} + +void DSWaylandTextInput::sendInputPanelGeometry(unsigned int x, unsigned int y, unsigned int width, unsigned int height) +{ + DS_GET_PRIV(DSWaylandTextInput); + + int angle = 0; + char geometry[128] = {0, }; + + if (priv->__clientSurface) + { + /* TODO: calculate angle and set this value to vconf */ + } + + snprintf(geometry, sizeof(geometry), "%d,%d,%d,%d", x, y, width, height); + + switch(angle) + { + case 90: + case 270: + //vconf_set_str(VCONFKEY_ISF_IME_RECENT_LAND_GEOMETRY, geometry); + break; + default: + //vconf_set_str(VCONFKEY_ISF_IME_RECENT_PORT_GEOMETRY, geometry); + break; + } + + priv->sendInputPanelGeometry(x, y, width, height); +} + +void DSWaylandTextInput::sendRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendRecaptureString(serial, index, length, preedit, preeditCommit, commit); +} + +void DSWaylandTextInput::sendInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendInputPanelEvent(serial, eventType, value); +} + +void DSWaylandTextInput::sendCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes) +{ + DS_GET_PRIV(DSWaylandTextInput); + + priv->sendCommitContent(serial, content, description, mimeTypes); +} + + } diff --git a/src/DSWaylandServer/DSWaylandTextInput.h b/src/DSWaylandServer/DSWaylandTextInput.h index 2d38eb2..c0b98ff 100644 --- a/src/DSWaylandServer/DSWaylandTextInput.h +++ b/src/DSWaylandServer/DSWaylandTextInput.h @@ -20,6 +20,29 @@ public: ~DSWaylandTextInput() override; void createGlobal(void *client, int id); + void showInputPanel(); + void hideInputPanel(); + + void sendCommitString(unsigned int serial, std::string text); + void sendPreeditString(unsigned int serial, std::string text, std::string commit); + void sendPreeditStyling(int index, unsigned int length, unsigned int style); + void sendPreeditCursor(int index); + void sendDeleteSurroundingText(int index, unsigned int length); + void sendCursorPosition(int index, int anchor); + void sendModifiersMap(std::string map); + void sendKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers); + void sendLanguage(unsigned int serial, std::string language); + void sendTextDirection(unsigned int serial, unsigned int direction); + void sendSelectionRegion(unsigned int serial, int start, int end); + void sendPrivateCommand(unsigned int serial, std::string command); + void sendInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength); + void sendGetSelectionText(int fd); + void sendGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd); + void sendFilterKeyEventDone(unsigned int serial, unsigned int state); + void sendInputPanelGeometry(unsigned int x, unsigned int y, unsigned int width, unsigned int height); + void sendRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit); + void sendInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value); + void sendCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes); protected: diff --git a/src/DSWaylandServer/DSWaylandTextInputManager.h b/src/DSWaylandServer/DSWaylandTextInputManager.h index 7131cc7..9f8654a 100644 --- a/src/DSWaylandServer/DSWaylandTextInputManager.h +++ b/src/DSWaylandServer/DSWaylandTextInputManager.h @@ -23,6 +23,29 @@ public: void createTextInput(void *client); int allocTextInputId(); + void contextCommitString(unsigned int serial, std::string text); + void contextPreeditString(unsigned int serial, std::string text, std::string commit); + void contextPreeditStyling(int index, unsigned int length, unsigned int style); + void contextPreeditCursor(int index); + void contextDeleteSurroundingText(int index, unsigned int length); + void contextCursorPosition(int index, int anchor); + void contextModifiersMap(std::string map); + void contextKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers); + void contextLanguage(unsigned int serial, std::string language); + void contextTextDirection(unsigned int serial, unsigned int direction); + void contextSelectionRegion(unsigned int serial, int start, int end); + void contextPrivateCommand(unsigned int serial, std::string command); + void contextUpdateInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength); + void contextShowInputPanel(); + void contextHideInputPanel(); + void contextGetSelectionText(int fd); + void contextGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd); + void contextFilterKeyEventDone(unsigned int serial, unsigned int state); + void contextUpdateIseGeometry(unsigned int x, unsigned int y, unsigned int width, unsigned int height); + void contextRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit); + void contextInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value); + void contextCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes); + protected: private: diff --git a/src/DSWaylandServer/DSWaylandTextInputPrivate.h b/src/DSWaylandServer/DSWaylandTextInputPrivate.h index cb4ca6a..1201aca 100644 --- a/src/DSWaylandServer/DSWaylandTextInputPrivate.h +++ b/src/DSWaylandServer/DSWaylandTextInputPrivate.h @@ -19,8 +19,30 @@ public: void createGlobal(void *client, int id); int getResourceId(Resource *resource); + void showInputPanel(void *resource); void hideInputPanel(Resource *resource, bool forceHide); + void sendCommitString(unsigned int serial, std::string text); + void sendPreeditString(unsigned int serial, std::string text, std::string commit); + void sendPreeditStyling(int index, unsigned int length, unsigned int style); + void sendPreeditCursor(int index); + void sendDeleteSurroundingText(int index, unsigned int length); + void sendCursorPosition(int index, int anchor); + void sendModifiersMap(std::string map); + void sendKeysym(unsigned int serial, unsigned int time, unsigned int sym, unsigned int state, unsigned int modifiers); + void sendLanguage(unsigned int serial, std::string language); + void sendTextDirection(unsigned int serial, unsigned int direction); + void sendSelectionRegion(unsigned int serial, int start, int end); + void sendPrivateCommand(unsigned int serial, std::string command); + void sendInputPanelData(unsigned int serial, std::string inputPanelData, unsigned int inputPanelDataLength); + void sendGetSelectionText(int fd); + void sendGetSurroundingText(unsigned int maxlenBefore, unsigned int maxlenAfter, int fd); + void sendFilterKeyEventDone(unsigned int serial, unsigned int state); + void sendInputPanelGeometry(unsigned int x, unsigned int y, unsigned int width, unsigned int height); + void sendRecaptureString(unsigned int serial, int index, unsigned int length, std::string preedit, std::string preeditCommit, std::string commit); + void sendInputPanelEvent(unsigned int serial, unsigned int eventType, unsigned int value); + void sendCommitContent(unsigned int serial, std::string content, std::string description, std::string mimeTypes); + protected: void text_input_destroy(Resource *resource); void text_input_activate(Resource *resource, struct ::wl_resource *seat, struct ::wl_resource *surface); diff --git a/tests/DSWaylandInputMethod-test.cpp b/tests/DSWaylandInputMethod-test.cpp index 7e78c92..147a1f9 100644 --- a/tests/DSWaylandInputMethod-test.cpp +++ b/tests/DSWaylandInputMethod-test.cpp @@ -34,6 +34,7 @@ TEST_F(DSWaylandInputMethodTest, ActivateDeactivate) EXPECT_TRUE(inputMethod != nullptr); inputMethod->activate(0); + bool activated = inputMethod->contextActivated(); inputMethod->deactivate(); delete inputMethod; @@ -293,3 +294,325 @@ TEST_F(DSWaylandInputMethodTest, PredictionHintData) DSWaylandCompositor::releaseInstance(); } +TEST_F(DSWaylandInputMethodTest, ContextCommitString) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextCommitString(0, ""); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextPreeditString) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextPreeditString(1, "", ""); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextPreeditStyling) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextPreeditStyling(1, 1, 1); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextPreeditCursor) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextPreeditCursor(0); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextDeleteSurroundingText) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextDeleteSurroundingText(1, 1); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextCursorPosition) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextCursorPosition(1, 1); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextModifiersMap) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextModifiersMap(""); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextKeysym) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextKeysym(1, 10, 65, 1, 1); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextLanguage) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextLanguage(1, "en_US"); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextTextDirection) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextTextDirection(1, 1); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextSelectionRegion) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextSelectionRegion(1, 10, 20); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextPrivateCommand) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextPrivateCommand(1, "CONFORMANT_RESET"); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextUpdateInputPanelData) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextUpdateInputPanelData(1, "", 0); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextHideInputPanel) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextHideInputPanel(1); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextGetSelectionText) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextGetSelectionText(5); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextGetSurroundingText) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextGetSurroundingText(5, 10, 5); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextFilterKeyEventDone) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextFilterKeyEventDone(1, 0); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextUpdateIseGeometry) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextUpdateIseGeometry(1, 0, 100, 200, 100); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextRecaptureString) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextRecaptureString(1, 1, 0, "", "", ""); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextInputPanelEvent) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextInputPanelEvent(1, 1, 0); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextCommitContent) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextCommitContent(1, "", "", ""); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextUpdateCandidateState) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextUpdateCandidateState(0); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandInputMethodTest, ContextReshowInputPanel) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandInputMethod *inputMethod = new DSWaylandInputMethod(comp); + EXPECT_TRUE(inputMethod != nullptr); + + inputMethod->activate(0); + inputMethod->contextReshowInputPanel(); + inputMethod->deactivate(); + + delete inputMethod; + DSWaylandCompositor::releaseInstance(); +} + diff --git a/tests/DSWaylandTextInput-test.cpp b/tests/DSWaylandTextInput-test.cpp index b69622d..75015ce 100644 --- a/tests/DSWaylandTextInput-test.cpp +++ b/tests/DSWaylandTextInput-test.cpp @@ -30,3 +30,311 @@ TEST_F(DSWaylandTextInputTest, NewDSWaylandTextInput) DSWaylandCompositor::releaseInstance(); } +TEST_F(DSWaylandTextInputTest, ShowInputPanel) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->showInputPanel(); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, HideInputPanel) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->hideInputPanel(); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendCommitString) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendCommitString(0, ""); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendPreeditString) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendPreeditString(1, "", ""); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendPreeditStyling) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendPreeditStyling(1, 1, 1); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendPreeditCursor) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendPreeditCursor(0); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendDeleteSurroundingText) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendDeleteSurroundingText(1, 1); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendCursorPosition) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendCursorPosition(1, 1); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendModifiersMap) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendModifiersMap(""); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendKeysym) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendKeysym(1, 10, 65, 1, 1); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendLanguage) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendLanguage(1, "en_US"); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendTextDirection) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendTextDirection(1, 1); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendSelectionRegion) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendSelectionRegion(1, 10, 20); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendPrivateCommand) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendPrivateCommand(1, "CONFORMANT_RESET"); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendInputPanelData) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendInputPanelData(1, "", 0); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendGetSelectionText) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendGetSelectionText(5); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendGetSurroundingText) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendGetSurroundingText(5, 10, 5); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendFilterKeyEventDone) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendFilterKeyEventDone(1, 0); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendInputPanelGeometry) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendInputPanelGeometry(0, 100, 200, 100); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendRecaptureString) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendRecaptureString(1, 1, 0, "", "", ""); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendInputPanelEvent) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendInputPanelEvent(1, 1, 0); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputTest, SendCommitContent) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + DSWaylandTextInput *textInput = new DSWaylandTextInput(comp, textInputManager); + EXPECT_TRUE(textInput != nullptr); + + textInput->sendCommitContent(1, "", "", ""); + + delete textInput; + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + diff --git a/tests/DSWaylandTextInputManager-test.cpp b/tests/DSWaylandTextInputManager-test.cpp index f05fbdb..2bb00c1 100644 --- a/tests/DSWaylandTextInputManager-test.cpp +++ b/tests/DSWaylandTextInputManager-test.cpp @@ -27,3 +27,267 @@ TEST_F(DSWaylandTextInputManagerTest, NewDSWaylandTextInputManager) DSWaylandCompositor::releaseInstance(); } +TEST_F(DSWaylandTextInputManagerTest, ContextCommitString) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextCommitString(0, ""); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextPreeditString) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextPreeditString(1, "", ""); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextPreeditStyling) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextPreeditStyling(1, 1, 1); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextPreeditCursor) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextPreeditCursor(0); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextDeleteSurroundingText) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextDeleteSurroundingText(1, 1); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextCursorPosition) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextCursorPosition(1, 1); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextModifiersMap) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextModifiersMap(""); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextKeysym) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextKeysym(1, 10, 65, 1, 1); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextLanguage) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextLanguage(1, "en_US"); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextTextDirection) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextTextDirection(1, 1); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextSelectionRegion) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextSelectionRegion(1, 10, 20); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextPrivateCommand) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextPrivateCommand(1, "CONFORMANT_RESET"); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextUpdateInputPanelData) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextUpdateInputPanelData(1, "", 0); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextShowInputPanel) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextShowInputPanel(); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextHideInputPanel) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextHideInputPanel(); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextGetSelectionText) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextGetSelectionText(5); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextGetSurroundingText) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextGetSurroundingText(5, 10, 5); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextFilterKeyEventDone) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextFilterKeyEventDone(1, 0); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextUpdateIseGeometry) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextUpdateIseGeometry(0, 100, 200, 100); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextRecaptureString) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextRecaptureString(1, 1, 0, "", "", ""); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextInputPanelEvent) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextInputPanelEvent(1, 1, 0); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + +TEST_F(DSWaylandTextInputManagerTest, ContextCommitContent) +{ + DSWaylandCompositor *comp = DSWaylandCompositor::getInstance(); + DSWaylandTextInputManager *textInputManager = new DSWaylandTextInputManager(comp); + EXPECT_TRUE(textInputManager != nullptr); + + textInputManager->contextCommitContent(1, "", "", ""); + + delete textInputManager; + DSWaylandCompositor::releaseInstance(); +} + -- 2.7.4 From 584df55c7381adf84f2f4f91982402a497d91e04 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Sun, 9 Aug 2020 14:28:19 +0900 Subject: [PATCH 02/16] DSDebug: add code to print line number Change-Id: Ibbdb6852f991727712183a9dcb07ad72a5e9661c --- src/DSDebug/DSDebugLog.cpp | 4 ++-- src/DSDebug/DSDebugLog.h | 10 +++++----- tests/DSDebugLog-test.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/DSDebug/DSDebugLog.cpp b/src/DSDebug/DSDebugLog.cpp index 877eb89..730a9ec 100644 --- a/src/DSDebug/DSDebugLog.cpp +++ b/src/DSDebug/DSDebugLog.cpp @@ -31,7 +31,7 @@ DSDebugLog *DSDebugLog::GetInstance() return mInstance; } -void DSDebugLog::printLog(int logLevel, const char *funcName, const char *fmt, ...) +void DSDebugLog::printLog(int logLevel, const char *funcName, int line, const char *fmt, ...) { //TODO: apply logLevel //TODO: use dlog or stdout @@ -43,7 +43,7 @@ void DSDebugLog::printLog(int logLevel, const char *funcName, const char *fmt, . va_start(arg, fmt); printf("%s", color[logLevel]); printf("[%s]", lvl_str[logLevel]); - printf(":[%s]", funcName); + printf(":[%s(%d)]", funcName, line); vprintf(fmt, arg); printf("\n"); va_end(arg); diff --git a/src/DSDebug/DSDebugLog.h b/src/DSDebug/DSDebugLog.h index 775130f..33c19b5 100644 --- a/src/DSDebug/DSDebugLog.h +++ b/src/DSDebug/DSDebugLog.h @@ -22,7 +22,7 @@ public: void operator=(const DSDebugLog &) = delete; // should not be assignable static DSDebugLog *GetInstance(); - void printLog(int logLevel, const char *funcName, const char *fmt, ...); + void printLog(int logLevel, const char *funcName, int line, const char *fmt, ...); int getLogLevel(); private: @@ -37,28 +37,28 @@ private: #define DSLOG_DBG(domain, fmt, args...) \ do { \ DSDebugLog *log = DSDebugLog::GetInstance(); \ - log->printLog(DSDebugLog::LOG_LEVEL_DEBUG, __func__, "[" domain "]: " fmt, \ + log->printLog(DSDebugLog::LOG_LEVEL_DEBUG, __func__, __LINE__, "[" domain "]: " fmt, \ ##args); \ } while (0) #define DSLOG_INF(domain, fmt, args...) \ do { \ DSDebugLog *log = DSDebugLog::GetInstance(); \ - log->printLog(DSDebugLog::LOG_LEVEL_INFO, __func__, "[" domain "]: " fmt, \ + log->printLog(DSDebugLog::LOG_LEVEL_INFO, __func__, __LINE__, "[" domain "]: " fmt, \ ##args); \ } while (0) #define DSLOG_WRN(domain, fmt, args...) \ do { \ DSDebugLog *log = DSDebugLog::GetInstance(); \ - log->printLog(DSDebugLog::LOG_LEVEL_WARN, __func__, "[" domain "]: " fmt, \ + log->printLog(DSDebugLog::LOG_LEVEL_WARN, __func__, __LINE__, "[" domain "]: " fmt, \ ##args); \ } while (0) #define DSLOG_ERR(domain, fmt, args...) \ do { \ DSDebugLog *log = DSDebugLog::GetInstance(); \ - log->printLog(DSDebugLog::LOG_LEVEL_ERR, __func__, "[" domain "]: " fmt, \ + log->printLog(DSDebugLog::LOG_LEVEL_ERR, __func__, __LINE__, "[" domain "]: " fmt, \ ##args); \ } while (0) } diff --git a/tests/DSDebugLog-test.cpp b/tests/DSDebugLog-test.cpp index b86456d..d4757f4 100644 --- a/tests/DSDebugLog-test.cpp +++ b/tests/DSDebugLog-test.cpp @@ -23,10 +23,10 @@ TEST_F(DSDebugLogTest, PrintLog) const char *str = "Hi world"; DSDebugLog *log = DSDebugLog::GetInstance(); - log->printLog(DSDebugLog::LOG_LEVEL_DEBUG, __func__, "Hello world"); - log->printLog(DSDebugLog::LOG_LEVEL_INFO, __func__, "%s", str); - log->printLog(DSDebugLog::LOG_LEVEL_WARN, __func__, "Greeting world"); - log->printLog(DSDebugLog::LOG_LEVEL_ERR, __func__, "Hey world"); + log->printLog(DSDebugLog::LOG_LEVEL_DEBUG, __func__, __LINE__, "Hello world"); + log->printLog(DSDebugLog::LOG_LEVEL_INFO, __func__, __LINE__, "%s", str); + log->printLog(DSDebugLog::LOG_LEVEL_WARN, __func__, __LINE__, "Greeting world"); + log->printLog(DSDebugLog::LOG_LEVEL_ERR, __func__, __LINE__, "Hey world"); EXPECT_TRUE(true); } -- 2.7.4 From 5b695813bddded894847ecbd1938dc22ff277d02 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Thu, 6 Aug 2020 10:10:11 +0900 Subject: [PATCH 03/16] DSRenderEngineDaliImpl-test: Temporarily disabled all tests. Change-Id: I0b789997998a2513c871e5e31dca50a184026b2e Signed-off-by: Joonbum Ko --- tests/DSRenderEngineDaliImpl-test.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/DSRenderEngineDaliImpl-test.cpp b/tests/DSRenderEngineDaliImpl-test.cpp index 3f553ad..f10dd4e 100644 --- a/tests/DSRenderEngineDaliImpl-test.cpp +++ b/tests/DSRenderEngineDaliImpl-test.cpp @@ -75,6 +75,8 @@ private: DSEventLoop *__eventLoop; }; +#if 0 + TEST_F(DSRenderEngineDaliTest, RenderEngine_Create) { auto bufferQueue = std::make_shared(3, 100, 100, IDSBuffer::FORMAT_ARGB8888); @@ -187,3 +189,4 @@ TEST_F(DSRenderEngineDaliTest, RenderEngine_RenderOnlyOneFrame) usleep(1000000); } } +#endif -- 2.7.4 From 94aab5503d51f648f6a17ff3892cffbefbbd1425 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Sun, 9 Aug 2020 13:31:05 +0900 Subject: [PATCH 04/16] samples: use xdg shell at samples Change-Id: Iabe2a0793bb0e9565c0e25b13971bfdb508e3734 --- packaging/libds.spec | 2 ++ samples/exampleClientNoShellRendering.cpp | 4 +-- samples/exampleClientShellRendering.cpp | 44 +++++++++++++++++-------------- samples/meson.build | 6 +++-- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/packaging/libds.spec b/packaging/libds.spec index 9e330b4..6366760 100644 --- a/packaging/libds.spec +++ b/packaging/libds.spec @@ -36,6 +36,8 @@ BuildRequires: pkgconfig(dali2-extension) BuildRequires: pkgconfig(wayland-client) BuildRequires: pkgconfig(xkbcommon) BuildRequires: pkgconfig(wayland-tbm-client) +BuildRequires: pkgconfig(xdg-shell-client) +BuildRequires: pkgconfig(xdg-shell-unstable-v6-client) # for ignoring the libds.a %define _unpackaged_files_terminate_build 0 diff --git a/samples/exampleClientNoShellRendering.cpp b/samples/exampleClientNoShellRendering.cpp index 1cbe5cc..f08ee70 100644 --- a/samples/exampleClientNoShellRendering.cpp +++ b/samples/exampleClientNoShellRendering.cpp @@ -279,8 +279,6 @@ int WlClientSimpleRendering::RenderingBuffer(int bufferNum, unsigned char color) void WlClientSimpleRendering::CommitBuffer(int bufferNum) { - int ret = 0; - if (__wlSurface == nullptr || __wlDisplay == nullptr) { std::cout << __func__ << " Error. execute connect first" << std::endl; @@ -299,6 +297,8 @@ void WlClientSimpleRendering::CommitBuffer(int bufferNum) std::cout << __func__ << " commit " << bufferNum << " buffer(tbm_surface:" << __tbmSurface[bufferNum] << ", wl_buffer:" << __wlBuffer[bufferNum] << ")" << std::endl; #if 0 + int ret = 0; + ret = wl_display_dispatch(__wlDisplay); if (ret < 0) { std::cout << __func__ << " Error. wl_display_dispatch error:" << ret << std::endl; diff --git a/samples/exampleClientShellRendering.cpp b/samples/exampleClientShellRendering.cpp index 91f6006..c34dd90 100644 --- a/samples/exampleClientShellRendering.cpp +++ b/samples/exampleClientShellRendering.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include #include #include @@ -45,15 +47,15 @@ public: __wlDisplay = nullptr; __wlRegistry = nullptr; __wlCompositor = nullptr; - __wlShell = nullptr; + __zxdgShell = nullptr; __wlSurface = nullptr; - __wlShellSurface = nullptr; + __zxdgShellSurface = nullptr; __wlTbmClient = nullptr; } ~WlClientSimpleRendering() { - if (__wlShellSurface != nullptr) wl_shell_surface_destroy(__wlShellSurface); + if (__zxdgShellSurface != nullptr) zxdg_surface_v6_destroy(__zxdgShellSurface); if (__wlSurface != nullptr) wl_surface_destroy(__wlSurface); for (int i = 0; i < BUF_NUM; i++) { @@ -61,7 +63,7 @@ public: if (__tbmSurface[i] != nullptr) tbm_surface_destroy(__tbmSurface[i]); } if (__wlTbmClient != nullptr) wayland_tbm_client_deinit(__wlTbmClient); - if (__wlShell != nullptr) wl_shell_destroy(__wlShell); + if (__zxdgShell != nullptr) zxdg_shell_v6_destroy(__zxdgShell); if (__wlCompositor != nullptr) wl_compositor_destroy(__wlCompositor); if (__wlRegistry != nullptr) wl_registry_destroy(__wlRegistry); @@ -76,9 +78,9 @@ public: void CommitBuffer(int bufferNum); struct wl_compositor *__wlCompositor; - struct wl_shell *__wlShell; + struct zxdg_shell_v6 *__zxdgShell; struct wl_surface *__wlSurface; - struct wl_shell_surface *__wlShellSurface; + struct zxdg_surface_v6 *__zxdgShellSurface; struct wl_buffer *__wlBuffer[BUF_NUM]; struct wayland_tbm_client *__wlTbmClient; }; @@ -94,9 +96,9 @@ handle_global(void *data, struct wl_registry *registry, uint32_t name, const cha std::cout << __func__ << " Error. fail to bind " << interface << std::endl; else std::cout << __func__ << " bind " << interface << std::endl; - } else if (strcmp(interface, "wl_shell") == 0) { - temp->__wlShell = (struct wl_shell *)wl_registry_bind(registry, name, &wl_shell_interface, 1); - if (temp->__wlShell == nullptr) + } else if (strcmp(interface, "zxdg_shell_v6") == 0) { + temp->__zxdgShell = (struct zxdg_shell_v6 *)wl_registry_bind(registry, name, &zxdg_shell_v6_interface, 1); + if (temp->__zxdgShell == nullptr) std::cout << __func__ << " Error. fail to bind " << interface << std::endl; else std::cout << __func__ << " bind " << interface << std::endl; @@ -144,7 +146,7 @@ int WlClientSimpleRendering::ConnectDisplay() wl_display_dispatch(__wlDisplay); wl_display_roundtrip(__wlDisplay); - if (__wlCompositor == nullptr || __wlShell == nullptr) + if (__wlCompositor == nullptr || __zxdgShell == nullptr) { std::cout << __func__ << " Error. fail binding" << std::endl; this->DisconnectDisplay(); @@ -167,10 +169,10 @@ int WlClientSimpleRendering::ConnectDisplay() return -1; } - __wlShellSurface = wl_shell_get_shell_surface(__wlShell, __wlSurface); - if (__wlShellSurface == nullptr) + __zxdgShellSurface = zxdg_shell_v6_get_xdg_surface(__zxdgShell, __wlSurface); + if (__zxdgShellSurface == nullptr) { - std::cout << __func__ << " Error. fail wl_shell_get_shell_surface" << std::endl; + std::cout << __func__ << " Error. fail zxdg_shell_v6_get_xdg_surface" << std::endl; this->DisconnectDisplay(); return -1; } @@ -182,8 +184,8 @@ void WlClientSimpleRendering::DisconnectDisplay() { int i; - if (__wlShellSurface != nullptr) wl_shell_surface_destroy(__wlShellSurface); - __wlShellSurface = nullptr; + if (__zxdgShellSurface != nullptr) zxdg_surface_v6_destroy(__zxdgShellSurface); + __zxdgShellSurface = nullptr; if (__wlSurface != nullptr) wl_surface_destroy(__wlSurface); __wlSurface = nullptr; for (i = 0; i < BUF_NUM; i++) @@ -193,8 +195,8 @@ void WlClientSimpleRendering::DisconnectDisplay() if (__wlTbmClient != nullptr) wayland_tbm_client_deinit(__wlTbmClient); __wlTbmClient = nullptr; - if (__wlShell != nullptr) wl_shell_destroy(__wlShell); - __wlShell = nullptr; + if (__zxdgShell != nullptr) zxdg_shell_v6_destroy(__zxdgShell); + __zxdgShell = nullptr; if (__wlCompositor) wl_compositor_destroy(__wlCompositor); __wlCompositor = nullptr; @@ -306,8 +308,6 @@ int WlClientSimpleRendering::RenderingBuffer(int bufferNum, unsigned char color) void WlClientSimpleRendering::CommitBuffer(int bufferNum) { - int ret = 0; - if (__wlSurface == nullptr || __wlDisplay == nullptr) { std::cout << __func__ << " Error. execute connect first" << std::endl; @@ -326,11 +326,15 @@ void WlClientSimpleRendering::CommitBuffer(int bufferNum) std::cout << __func__ << " commit " << bufferNum << " buffer(tbm_surface:" << __tbmSurface[bufferNum] << ", wl_buffer:" << __wlBuffer[bufferNum] << ")" << std::endl; +#if 0 + int ret = 0; + ret = wl_display_dispatch(__wlDisplay); if (ret < 0) { std::cout << __func__ << " Error. wl_display_dispatch error:" << ret << std::endl; return; } +#endif wl_display_roundtrip(__wlDisplay); } @@ -371,7 +375,7 @@ int main (void) } } - wl_shell_surface_set_toplevel(simpleRenderSample->__wlShellSurface); + zxdg_surface_v6_get_toplevel(simpleRenderSample->__zxdgShellSurface); /* main loop */ i = 0; diff --git a/samples/meson.build b/samples/meson.build index 435afec..50d5216 100644 --- a/samples/meson.build +++ b/samples/meson.build @@ -42,15 +42,17 @@ ecore_wayland2_dep = dependency('ecore-wl2') wayland_tbm_client_dep = dependency('wayland-tbm-client') executable('exampleClientNoShellRendering', 'exampleClientNoShellRendering.cpp', - dependencies : [libds_declared_dep, wayland_client_dep, ecore_wayland2_dep, wayland_tbm_client_dep], + dependencies : [libds_declared_dep, wayland_client_dep, tizen_extension_client_dep, ecore_wayland2_dep, wayland_tbm_client_dep], install_dir : libds_prefix_bindir, install : true ) wayland_tbm_client_dep = dependency('wayland-tbm-client') +xdg_shell_client_dep = dependency('xdg-shell-client') +xdg_shell_unstable_v6_client_dep = dependency('xdg-shell-unstable-v6-client') executable('exampleClientShellRendering', 'exampleClientShellRendering.cpp', - dependencies : [libds_declared_dep, wayland_client_dep, ecore_wayland2_dep, wayland_tbm_client_dep], + dependencies : [libds_declared_dep, wayland_client_dep, xdg_shell_client_dep, xdg_shell_unstable_v6_client_dep, ecore_wayland2_dep, wayland_tbm_client_dep], install_dir : libds_prefix_bindir, install : true ) -- 2.7.4 From b7301669f595c1e919d121d935d7b487995d212b Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Sun, 9 Aug 2020 13:32:05 +0900 Subject: [PATCH 05/16] DSDisplayDevice: add get functions. add getRefreshRate(), getName() functions Change-Id: I18b3dcba30f15ab0c8babb64e9bd3328151f8ea1 --- src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.cpp | 16 ++++++++++++++++ src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.h | 4 ++++ src/DSDisplayDevice/IDSDisplayDeviceOutput.h | 2 ++ 3 files changed, 22 insertions(+) diff --git a/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.cpp b/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.cpp index 4ef1821..514ae74 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.cpp +++ b/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.cpp @@ -13,6 +13,7 @@ DSDisplayDeviceOutputTDMImpl::DSDisplayDeviceOutputTDMImpl() __resolutionHeight(0), __physicalMMWidth(0), __physicalMMHeight(0), + __refreshRate(0), __outputMode(nullptr), __dpmsMode(IDSDisplayDeviceOutput::DPMS_OFF), __displayDeviceHWC(nullptr) @@ -27,6 +28,7 @@ DSDisplayDeviceOutputTDMImpl::DSDisplayDeviceOutputTDMImpl(tdm_output *toutput) __resolutionHeight(0), __physicalMMWidth(0), __physicalMMHeight(0), + __refreshRate(0), __outputMode(nullptr), __dpmsMode(IDSDisplayDeviceOutput::DPMS_OFF), __displayDeviceHWC(nullptr) @@ -90,6 +92,16 @@ int DSDisplayDeviceOutputTDMImpl::getPhysicalMMHeight() return __physicalMMHeight; } +int DSDisplayDeviceOutputTDMImpl::getRefreshRate() +{ + return __refreshRate; +} + +std::string DSDisplayDeviceOutputTDMImpl::getName() +{ + return __name; +} + bool DSDisplayDeviceOutputTDMImpl::setMode(std::shared_ptr outputMode) { tdm_error terror; @@ -103,6 +115,10 @@ bool DSDisplayDeviceOutputTDMImpl::setMode(std::shared_ptrgetHorizontalSize(); + __resolutionHeight = __outputMode->getVertialSize(); + __refreshRate = __outputMode->getRefreshRate(); + __name = __outputMode->getName(); return true; } diff --git a/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.h b/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.h index 36cebfe..afd5294 100644 --- a/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.h +++ b/src/DSDisplayDevice/DSDisplayDeviceOutputTDMImpl.h @@ -22,6 +22,8 @@ public: int getResolutionHeight() override; int getPhysicalMMWidth() override; int getPhysicalMMHeight() override; + int getRefreshRate() override; + std::string getName() override; std::list> getAvailableModes() override; bool setMode(std::shared_ptr outputMode) override; @@ -56,6 +58,8 @@ private: std::list> __availableModeList; unsigned int __resolutionWidth, __resolutionHeight; unsigned int __physicalMMWidth, __physicalMMHeight; + unsigned int __refreshRate; + std::string __name; std::shared_ptr __outputMode; IDSDisplayDeviceOutput::DPMSMode __dpmsMode; diff --git a/src/DSDisplayDevice/IDSDisplayDeviceOutput.h b/src/DSDisplayDevice/IDSDisplayDeviceOutput.h index 766bb9d..495d325 100644 --- a/src/DSDisplayDevice/IDSDisplayDeviceOutput.h +++ b/src/DSDisplayDevice/IDSDisplayDeviceOutput.h @@ -58,6 +58,8 @@ public: virtual int getResolutionHeight() = 0; virtual int getPhysicalMMWidth() = 0; virtual int getPhysicalMMHeight() = 0; + virtual int getRefreshRate() = 0; + virtual std::string getName() = 0; virtual std::list> getAvailableModes() = 0; virtual bool setMode(std::shared_ptr outputMode) = 0; -- 2.7.4 From 3eb5151af9b94b9820b66a871eac127a1c00fc68 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Sun, 9 Aug 2020 13:33:20 +0900 Subject: [PATCH 06/16] DSOutput: create DSWaylandOutput object after IDSDisplayDeviceOutput sets the mode. Change-Id: I742344d68185a87ea5b88cde483e17cb9149e408 --- src/DSOutput/DSOutputImpl.cpp | 19 ++++++++++++++----- src/DSOutput/DSOutputImpl.h | 4 ++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/DSOutput/DSOutputImpl.cpp b/src/DSOutput/DSOutputImpl.cpp index b51dbd4..60dfbd8 100644 --- a/src/DSOutput/DSOutputImpl.cpp +++ b/src/DSOutput/DSOutputImpl.cpp @@ -5,9 +5,7 @@ namespace display_server { DSOutputImpl::DSOutputImpl(std::shared_ptr displayDeviceOutput) - : __resolutionWidth{0}, - __resolutionHeight{0}, - __displayDeviceOutput{displayDeviceOutput} + : __displayDeviceOutput{displayDeviceOutput} {} DSOutputImpl::~DSOutputImpl() @@ -15,12 +13,12 @@ DSOutputImpl::~DSOutputImpl() int DSOutputImpl::getResolutionWidth() { - return __resolutionWidth; + return __displayDeviceOutput->getResolutionWidth(); } int DSOutputImpl::getResolutionHeight() { - return __resolutionHeight; + return __displayDeviceOutput->getResolutionHeight(); } bool DSOutputImpl::applyResolutionAuto() @@ -47,6 +45,17 @@ bool DSOutputImpl::applyResolutionAuto() return false; } + // TODO: get more information from DSOutputImpl to set them toDSWaylandOutput. + __waylandOutput = std::make_shared(DSWaylandCompositor::getInstance(), + __displayDeviceOutput->getName(), "tm1", "tm1", + 0, 0, __displayDeviceOutput->getResolutionWidth(), __displayDeviceOutput->getResolutionHeight(), + __displayDeviceOutput->getPhysicalMMWidth(), __displayDeviceOutput->getPhysicalMMHeight(), + __displayDeviceOutput->getRefreshRate(), 0, 0); + DSWaylandCompositor::releaseInstance(); + + // send output information + __waylandOutput->sendWaylandOutputInfo(); + return true; } diff --git a/src/DSOutput/DSOutputImpl.h b/src/DSOutput/DSOutputImpl.h index de0eb85..528ce63 100644 --- a/src/DSOutput/DSOutputImpl.h +++ b/src/DSOutput/DSOutputImpl.h @@ -3,6 +3,7 @@ #include "IDSOutput.h" #include "IDSDisplayDeviceOutput.h" +#include "DSWaylandOutput.h" namespace display_server { @@ -20,9 +21,8 @@ public: std::shared_ptr getDisplayDeviceOutput(); private: - int __resolutionWidth; - int __resolutionHeight; std::shared_ptr __displayDeviceOutput; + std::shared_ptr __waylandOutput; }; } -- 2.7.4 From 7fa26f4bdeb7a49f349892f2f663db0f358c12e4 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Mon, 10 Aug 2020 14:37:33 +0900 Subject: [PATCH 07/16] DSWaylandTizenPosition: add skeleton code Change-Id: Icd4b3b8d26c66f2af29acde6f9ac1a8ce2acff72 --- src/DSWaylandServer/DSWaylandTizenPolicy.cpp | 5 ++ src/DSWaylandServer/DSWaylandTizenPosition.cpp | 63 ++++++++++++++++++++++ src/DSWaylandServer/DSWaylandTizenPosition.h | 30 +++++++++++ .../DSWaylandTizenPositionPrivate.h | 37 +++++++++++++ src/meson.build | 1 + 5 files changed, 136 insertions(+) create mode 100644 src/DSWaylandServer/DSWaylandTizenPosition.cpp create mode 100644 src/DSWaylandServer/DSWaylandTizenPosition.h create mode 100644 src/DSWaylandServer/DSWaylandTizenPositionPrivate.h diff --git a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp index e61a8fa..df772d4 100644 --- a/src/DSWaylandServer/DSWaylandTizenPolicy.cpp +++ b/src/DSWaylandServer/DSWaylandTizenPolicy.cpp @@ -1,6 +1,8 @@ #include "DSWaylandTizenPolicy.h" #include "DSWaylandTizenPolicyPrivate.h" +#include "DSWaylandTizenPosition.h" + const int TIZEN_POLICY_VERSION = 7; namespace display_server @@ -52,6 +54,9 @@ void DSWaylandTizenPolicyPrivate::tizen_policy_get_visibility(Resource *resource void DSWaylandTizenPolicyPrivate::tizen_policy_get_position(Resource *resource, uint32_t id, struct ::wl_resource *surface) { DSLOG_DBG("TizenPolicyPriv", ""); + + DSWaylandTizenPosition *tzPos = new DSWaylandTizenPosition(resource->client(), id, TIZEN_POLICY_VERSION, surface); + // DO something using tzPos } void DSWaylandTizenPolicyPrivate::tizen_policy_activate(Resource *resource, struct ::wl_resource *surface) diff --git a/src/DSWaylandServer/DSWaylandTizenPosition.cpp b/src/DSWaylandServer/DSWaylandTizenPosition.cpp new file mode 100644 index 0000000..10ead4a --- /dev/null +++ b/src/DSWaylandServer/DSWaylandTizenPosition.cpp @@ -0,0 +1,63 @@ +#include "DSWaylandTizenPosition.h" +#include "DSWaylandTizenPositionPrivate.h" + +namespace display_server +{ + +DSWaylandTizenPosition::DSWaylandTizenPosition(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface) + : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandTizenPosition) +{ + DSLOG_DBG("TIZEN_POSITION", "CREATOR... TizenPosition:%p", this); + init(client, id, version, surface); +} + +DSWaylandTizenPosition::~DSWaylandTizenPosition() +{ + DSLOG_DBG("TIZEN_POSITION", "DESTORYER... TizenPosition:%p", this); +} + +void DSWaylandTizenPosition::init(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface) +{ + DS_GET_PRIV(DSWaylandTizenPosition); + priv->init(client, id, version, surface); +} + +DSWaylandTizenPositionPrivate::DSWaylandTizenPositionPrivate(DSWaylandTizenPosition *p_ptr) + : DSObjectPrivate(p_ptr), + __p_ptr(p_ptr), + __wlSurface(nullptr) +{ +} + +DSWaylandTizenPositionPrivate::~DSWaylandTizenPositionPrivate() +{ +} + +void DSWaylandTizenPositionPrivate::init(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface) +{ + tizen_position::init(client, id, version); + __wlSurface = surface; +} + +void DSWaylandTizenPositionPrivate::tizen_position_bind_resource(Resource *resource) +{ + +} + +void DSWaylandTizenPositionPrivate::tizen_position_destroy_resource(Resource *resource) +{ + +} + +void DSWaylandTizenPositionPrivate::tizen_position_destroy(Resource *resource) +{ + +} + +void DSWaylandTizenPositionPrivate::tizen_position_set(Resource *resource, int32_t x, int32_t y) +{ + DSLOG_DBG("TIZEN_POSITION", "Requested pos(%d,%d)", x, y); +} + + +} // namespace display_server diff --git a/src/DSWaylandServer/DSWaylandTizenPosition.h b/src/DSWaylandServer/DSWaylandTizenPosition.h new file mode 100644 index 0000000..720251a --- /dev/null +++ b/src/DSWaylandServer/DSWaylandTizenPosition.h @@ -0,0 +1,30 @@ +#ifndef __DS_WAYLAND_TIZEN_POSITION_H__ +#define __DS_WAYLAND_TIZEN_POSITION_H__ + +#include "DSCore.h" +#include "DSObject.h" +#include + +namespace display_server +{ + +class DSWaylandTizenPositionPrivate; + +class DSWaylandTizenPosition : public DSObject +{ +DS_PIMPL_USE_PRIVATE(DSWaylandTizenPosition); + +public: + DSWaylandTizenPosition(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface); + ~DSWaylandTizenPosition() override; + + void init(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface); + +protected: + +private: +}; + +} // namespace display_server + +#endif //__DS_WAYLAND_TIZEN_POSITION_H__ diff --git a/src/DSWaylandServer/DSWaylandTizenPositionPrivate.h b/src/DSWaylandServer/DSWaylandTizenPositionPrivate.h new file mode 100644 index 0000000..0522555 --- /dev/null +++ b/src/DSWaylandServer/DSWaylandTizenPositionPrivate.h @@ -0,0 +1,37 @@ +#ifndef __DS_WAYLAND_TIZEN_POLICY_PRIVATE__ +#define __DS_WAYLAND_TIZEN_POLICY_PRIVATE__ + +#include "dswayland-server-tizen-extension.h" +#include "DSWaylandTizenPosition.h" + +namespace display_server +{ + +class DSWaylandTizenPositionPrivate : public DSObjectPrivate, public DSWaylandServer::tizen_position +{ +DS_PIMPL_USE_PUBLIC(DSWaylandTizenPosition); + +public: + DSWaylandTizenPositionPrivate() = delete; + //DSWaylandTizenPositionPrivate(DSWaylandTizenPosition *p_ptr, struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface); + DSWaylandTizenPositionPrivate(DSWaylandTizenPosition *p_ptr); + ~DSWaylandTizenPositionPrivate() override; + + void init(struct ::wl_client *client, uint32_t id, int version, struct ::wl_resource *surface); + +protected: + void tizen_position_bind_resource(Resource *resource) override; + void tizen_position_destroy_resource(Resource *resource) override; + + void tizen_position_destroy(Resource *resource) override; + void tizen_position_set(Resource *resource, int32_t x, int32_t y) override; + +private: + struct ::wl_resource *__wlSurface; + //DSWaylandSurface *__waylandSurface; + +}; + +} + +#endif //__DS_WAYLAND_TIZEN_POLICY_PRIVATE__ diff --git a/src/meson.build b/src/meson.build index c6ac5dd..6bde3ed 100644 --- a/src/meson.build +++ b/src/meson.build @@ -104,6 +104,7 @@ libds_wayland_srcs = [ 'DSWaylandServer/DSWaylandTizenInputDeviceManager.h', 'DSWaylandServer/DSWaylandTizenInputDeviceManagerPrivate.h', 'DSWaylandServer/DSWaylandTizenPolicy.cpp', + 'DSWaylandServer/DSWaylandTizenPosition.cpp', 'DSWaylandServer/DSWaylandTizenSurface.cpp', 'DSWaylandServer/DSWaylandTizenSurface.h', 'DSWaylandServer/DSWaylandTizenSurfacePrivate.h', -- 2.7.4 From ca5cac2f1e354515ddc6788c997313d176b603ba Mon Sep 17 00:00:00 2001 From: Duna Oh Date: Fri, 7 Aug 2020 15:36:48 +0900 Subject: [PATCH 08/16] DSTizenAppinfo/DSTizenAppinfoMgr: add new classes and test codes Change-Id: I26c4a6a5e158daab32c1de9ae5e0854d31cb9cfb --- samples/exampleClient.c | 23 ++++- samples/meson.build | 3 +- src/DSWaylandExtension/DSTizenAppinfo.cpp | 61 ++++++++++++ src/DSWaylandExtension/DSTizenAppinfo.h | 33 +++++++ src/DSWaylandExtension/DSTizenAppinfoMgr.cpp | 84 ++++++++++++++++ src/DSWaylandExtension/DSTizenAppinfoMgr.h | 39 ++++++++ src/DSWaylandExtension/DSWaylandExtension.cpp | 14 +++ src/DSWaylandExtension/DSWaylandExtensionPrivate.h | 3 + src/DSWaylandServer/DSWaylandTizenAppinfo.cpp | 109 +++++++++++++++++++-- src/DSWaylandServer/DSWaylandTizenAppinfo.h | 16 ++- src/DSWaylandServer/DSWaylandTizenAppinfoPrivate.h | 4 + src/meson.build | 4 + tests/DSTizenAppinfo-test.cpp | 58 +++++++++++ tests/DSWaylandTizenAppinfo-test.cpp | 22 ++++- tests/meson.build | 2 + 15 files changed, 461 insertions(+), 14 deletions(-) create mode 100644 src/DSWaylandExtension/DSTizenAppinfo.cpp create mode 100644 src/DSWaylandExtension/DSTizenAppinfo.h create mode 100644 src/DSWaylandExtension/DSTizenAppinfoMgr.cpp create mode 100644 src/DSWaylandExtension/DSTizenAppinfoMgr.h create mode 100644 tests/DSTizenAppinfo-test.cpp diff --git a/samples/exampleClient.c b/samples/exampleClient.c index 7038611..6bf344d 100644 --- a/samples/exampleClient.c +++ b/samples/exampleClient.c @@ -12,6 +12,7 @@ #include #include #include +#include struct wl_display *display = NULL; struct wl_compositor *compositor = NULL; @@ -23,6 +24,7 @@ struct wl_touch *touch = NULL; struct xkb_context *xkb_context = NULL; struct xkb_keymap *keymap = NULL; struct tizen_policy *tz_policy = NULL; +struct tizen_launch_appinfo *tz_appinfo = NULL; static void pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t surface_x, wl_fixed_t surface_y) { @@ -397,10 +399,20 @@ static const struct tizen_policy_listener tz_policy_listener = { }; static void +_tizen_launch_appinfo_cb_base_output_resolution_done(void *data, struct tizen_launch_appinfo *tizen_appinfo, uint32_t pid, uint32_t width, uint32_t height) +{ + printf("Tizen Appinfo callback: base_output_resolution_done pid:(%d) w,h:(%d,%d)\n", pid, width, height); +} + +static const struct tizen_launch_appinfo_listener tz_appinfo_listener = { + _tizen_launch_appinfo_cb_base_output_resolution_done, +}; + +static void global_registry_handler(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version) { - printf("Registry event : global added (interface:%s, id:%d)\n", interface, id); + printf("Registry event : global added (interface:%s, id:%d, version:%d)\n", interface, id, version); if (strcmp(interface, "wl_compositor") == 0) { @@ -416,6 +428,15 @@ global_registry_handler(void *data, struct wl_registry *registry, uint32_t id, tz_policy = wl_registry_bind(registry, id, &tizen_policy_interface, 7); tizen_policy_add_listener(tz_policy, &tz_policy_listener, NULL); } + else if(strcmp(interface, "tizen_launch_appinfo") == 0) + { + tz_appinfo = wl_registry_bind(registry, id, &tizen_launch_appinfo_interface, 1); + + /* TODO: This request should be used by AMD.*/ + tizen_launch_appinfo_add_listener(tz_appinfo, &tz_appinfo_listener, NULL); + tizen_launch_appinfo_register_appid(tz_appinfo, "com.samsung.clocksetting"); + tizen_launch_appinfo_set_pid(tz_appinfo, "com.samsung.clocksetting", 4077); + } } static void diff --git a/samples/meson.build b/samples/meson.build index 50d5216..176e86b 100644 --- a/samples/meson.build +++ b/samples/meson.build @@ -29,10 +29,11 @@ executable('exampleCompositor', # exampleClient written for testing exampleCompositor wayland_client_dep = dependency('wayland-client') tizen_extension_client_dep = dependency('tizen-extension-client') +tizen_launch_client_dep = dependency('tizen-launch-client') libxkbcommon_dep = dependency('xkbcommon') executable('exampleClient', 'exampleClient.c', - dependencies : [libds_declared_dep, wayland_client_dep, tizen_extension_client_dep, libxkbcommon_dep], + dependencies : [libds_declared_dep, wayland_client_dep, tizen_extension_client_dep, libxkbcommon_dep, tizen_launch_client_dep], install_dir : libds_prefix_bindir, install : true ) diff --git a/src/DSWaylandExtension/DSTizenAppinfo.cpp b/src/DSWaylandExtension/DSTizenAppinfo.cpp new file mode 100644 index 0000000..d3ea3e5 --- /dev/null +++ b/src/DSWaylandExtension/DSTizenAppinfo.cpp @@ -0,0 +1,61 @@ +#include + +namespace display_server +{ +DSTizenAppinfo::DSTizenAppinfo() + : __pid(-1), + __base_output_available(false), + __base_output_width(0), + __base_output_height(0) +{ +} + +DSTizenAppinfo::DSTizenAppinfo(std::string appid) + : __pid(-1), + __base_output_available(false), + __base_output_width(0), + __base_output_height(0) +{ + __appId = appid; +} + +void DSTizenAppinfo::setAppId(std::string appId) +{ + __appId = appId; +} + +void DSTizenAppinfo::setPid(pid_t pid) +{ + __pid = pid; +} + +DSTizenAppinfo::~DSTizenAppinfo() +{ +} + +pid_t DSTizenAppinfo::pid() +{ + return __pid; +} + +std::string DSTizenAppinfo::appId() +{ + return __appId; +} + +bool DSTizenAppinfo::base_output_available() +{ + return __base_output_available; +} + +int DSTizenAppinfo::base_output_width() +{ + return __base_output_width; +} + +int DSTizenAppinfo::base_output_height() +{ + return __base_output_height; +} + +} \ No newline at end of file diff --git a/src/DSWaylandExtension/DSTizenAppinfo.h b/src/DSWaylandExtension/DSTizenAppinfo.h new file mode 100644 index 0000000..4967630 --- /dev/null +++ b/src/DSWaylandExtension/DSTizenAppinfo.h @@ -0,0 +1,33 @@ +#ifndef _DS_TIZENAPPINFO_H_ +#define _DS_TIZENAPPINFO_H_ + +#include + +namespace display_server +{ + +class DSTizenAppinfo : public DSObject +{ +public: + DSTizenAppinfo(); + DSTizenAppinfo(std::string appid); + virtual ~DSTizenAppinfo(); + + void setAppId(std::string appId); + void setPid(pid_t pid); + pid_t pid(void); + std::string appId(void); + bool base_output_available(void); + int base_output_width(void); + int base_output_height(void); + +private: + std::string __appId; + pid_t __pid; + bool __base_output_available; + int __base_output_width; + int __base_output_height; +}; + +} +#endif \ No newline at end of file diff --git a/src/DSWaylandExtension/DSTizenAppinfoMgr.cpp b/src/DSWaylandExtension/DSTizenAppinfoMgr.cpp new file mode 100644 index 0000000..7e07120 --- /dev/null +++ b/src/DSWaylandExtension/DSTizenAppinfoMgr.cpp @@ -0,0 +1,84 @@ +#include "DSTizenAppinfoMgr.h" +#include "DSWaylandTizenAppinfo.h" +#include "DSDebugLog.h" + +namespace display_server +{ + +DSTizenAppinfoMgr::DSTizenAppinfoMgr() + :__numAppinfo(0) +{ + __wlCompositor = DSWaylandCompositor::getInstance(); + __wlAppinfo = new DSWaylandTizenAppinfo(__wlCompositor, this); +} + +DSTizenAppinfoMgr::~DSTizenAppinfoMgr() +{ +} + +std::shared_ptr DSTizenAppinfoMgr::getTizenAppinfo(std::string appId) +{ + auto it = __appIdMap.find(appId); + if (it != __appIdMap.end()) + { + DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) returned by appId:%s", appId); + return it->second; + } + return nullptr; +} + +std::shared_ptr DSTizenAppinfoMgr::getTizenAppinfo(pid_t pid) +{ + std::unordered_map >::iterator it; + for (it = __appIdMap.begin(); it != __appIdMap.end(); it++) { + std::shared_ptr ptr_appinfo = it->second; + DSTizenAppinfo * appinfo; + appinfo = ptr_appinfo.get() ; + if (appinfo->pid() == pid) { + DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo returned by pid:%d", pid); + return ptr_appinfo; + } + } + return nullptr; +} + +std::shared_ptr DSTizenAppinfoMgr::addTizenAppinfo(std::string appId) +{ + std::shared_ptr appinfo = getTizenAppinfo(appId); + if (appinfo == nullptr) { + appinfo = std::make_shared(appId); + if (appinfo != nullptr) + { + __appIdMap.emplace(appId, appinfo); + __numAppinfo++; + DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) added", appId); + return appinfo; + } + } + DSLOG_INF("DSTizenAppinfoMgr", "No TizenAppinfo added by apppId:%s", appId); + return appinfo; +} + +void DSTizenAppinfoMgr::removeTizenAppinfo(std::string appId) +{ + auto it = __appIdMap.find(appId); + if (it != __appIdMap.end()) { + __appIdMap.erase(it); + --__numAppinfo; + DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) removed", appId); + } + return; +} + +void DSTizenAppinfoMgr::updateTizenAppinfo(std::string appId, pid_t pid) +{ + std::shared_ptr ptr_appinfo = getTizenAppinfo(appId); + DSTizenAppinfo * appinfo; + appinfo = ptr_appinfo.get(); + if (appinfo != nullptr) + { + appinfo->setPid(pid); + DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) set to pid:%d", appId, pid); + } +} +} \ No newline at end of file diff --git a/src/DSWaylandExtension/DSTizenAppinfoMgr.h b/src/DSWaylandExtension/DSTizenAppinfoMgr.h new file mode 100644 index 0000000..03db0ea --- /dev/null +++ b/src/DSWaylandExtension/DSTizenAppinfoMgr.h @@ -0,0 +1,39 @@ +#ifndef _DS_TIZENAPPINFO_MGR_H_ +#define _DS_TIZENAPPINFO_MGR_H_ + +#include +#include "DSWaylandCompositor.h" + +namespace display_server +{ + +class DSTizenAppinfoMgr : public DSObject +{ +public: + DSTizenAppinfoMgr(); + virtual ~DSTizenAppinfoMgr(); + + std::shared_ptr getTizenAppinfo(std::string appId); + std::shared_ptr getTizenAppinfo(pid_t pid); + + std::shared_ptr addTizenAppinfo(std::string appId); + + void removeTizenAppinfo(std::string appId); + + void updateTizenAppinfo(std::string appId, pid_t pid); + + int numAppinfo() + { + return __numAppinfo; + }; + +private: + DSWaylandCompositor *__wlCompositor; + DSWaylandTizenAppinfo *__wlAppinfo; + std::unordered_map > __appIdMap; + int __numAppinfo; +}; + +} + +#endif \ No newline at end of file diff --git a/src/DSWaylandExtension/DSWaylandExtension.cpp b/src/DSWaylandExtension/DSWaylandExtension.cpp index bc6e57c..3a38a3a 100644 --- a/src/DSWaylandExtension/DSWaylandExtension.cpp +++ b/src/DSWaylandExtension/DSWaylandExtension.cpp @@ -3,6 +3,7 @@ #include "DSWaylandCompositor.h" #include "DSWaylandZxdgShellV6.h" #include "DSWaylandTizenPolicy.h" +#include "DSTizenAppinfoMgr.h" namespace display_server @@ -32,6 +33,7 @@ bool DSWaylandExtensionPrivate::init(DSWaylandCompositor *compositor) { __initZxdgShellV6(); __initTizenPolicy(); + __initTizenAppinfoMgr(); } catch(const std::runtime_error& e) { @@ -70,6 +72,18 @@ bool DSWaylandExtensionPrivate::__initTizenPolicy(void) return true; } +bool DSWaylandExtensionPrivate::__initTizenAppinfoMgr(void) +{ + __tzAppinfoMgr = std::make_shared(); + if (__tzAppinfoMgr == nullptr) + { + throw std::runtime_error(__func__); + return false; + } + + return true; +} + DSWaylandExtension::DSWaylandExtension(DSWaylandCompositor *compositor) : DS_INIT_PRIVATE_PTR(DSWaylandExtension) { diff --git a/src/DSWaylandExtension/DSWaylandExtensionPrivate.h b/src/DSWaylandExtension/DSWaylandExtensionPrivate.h index 0521cb8..c7b8ab0 100644 --- a/src/DSWaylandExtension/DSWaylandExtensionPrivate.h +++ b/src/DSWaylandExtension/DSWaylandExtensionPrivate.h @@ -6,6 +6,7 @@ namespace display_server class DSWaylandZxdgShellV6; class DSWaylandTizenPolicy; +class DSTizenAppinfoMgr; class DSWaylandExtensionPrivate : public DSObjectPrivate { @@ -21,11 +22,13 @@ public: private: bool __initZxdgShellV6(void); bool __initTizenPolicy(void); + bool __initTizenAppinfoMgr(void); private: DSWaylandCompositor *__compositor; std::shared_ptr __zxdgShell; std::shared_ptr __tzPolicy; + std::shared_ptr __tzAppinfoMgr; }; diff --git a/src/DSWaylandServer/DSWaylandTizenAppinfo.cpp b/src/DSWaylandServer/DSWaylandTizenAppinfo.cpp index 1950c42..27585fb 100644 --- a/src/DSWaylandServer/DSWaylandTizenAppinfo.cpp +++ b/src/DSWaylandServer/DSWaylandTizenAppinfo.cpp @@ -1,61 +1,152 @@ #include "DSWaylandTizenAppinfo.h" #include "DSWaylandTizenAppinfoPrivate.h" +#include "DSTizenAppinfoMgr.h" + +const int TIZEN_APPINFO_VERSION = 1; namespace display_server { - -DSWaylandTizenAppinfo::DSWaylandTizenAppinfo() - : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandTizenAppinfo) +DSWaylandTizenAppinfoPrivate::DSWaylandTizenAppinfoPrivate(DSWaylandTizenAppinfo *p_ptr) + : DSObjectPrivate(p_ptr), + __p_ptr(p_ptr) { } -DSWaylandTizenAppinfo::~DSWaylandTizenAppinfo() +DSWaylandTizenAppinfoPrivate::~DSWaylandTizenAppinfoPrivate() { } -DSWaylandTizenAppinfoPrivate::DSWaylandTizenAppinfoPrivate(DSWaylandTizenAppinfo *p_ptr) - : DSObjectPrivate(p_ptr), - __p_ptr(p_ptr) +void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_initialize(DSWaylandCompositor *wlCompositor) { -} + ::wl_display *display; + display = wlCompositor->display(); -DSWaylandTizenAppinfoPrivate::~DSWaylandTizenAppinfoPrivate() + init(display, TIZEN_APPINFO_VERSION); +} +void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_finalize(void) { } void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_bind_resource(Resource *resource) { + DSLOG_DBG("TizenAppinfoPriv", ""); } void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_destroy_resource(Resource *resource) { + DSLOG_DBG("TizenAppinfoPriv", ""); } void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_destroy(Resource *resource) { + DSLOG_DBG("TizenAppinfoPriv", ""); } void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_register_pid(Resource *resource, uint32_t pid) { + DSLOG_DBG("TizenAppinfoPriv", ""); } void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_deregister_pid(Resource *resource, uint32_t pid) { + DSLOG_DBG("TizenAppinfoPriv", ""); } void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_set_appid(Resource *resource, uint32_t pid, const std::string &appid) { + DSLOG_DBG("TizenAppinfoPriv", ""); } void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_get_base_output_resolution(Resource *resource, uint32_t pid) { + DSLOG_DBG("TizenAppinfoPriv", ""); + DS_GET_PUB(DSWaylandTizenAppinfo); + if (pub->__dsAppinfoMgr == nullptr) + return; + + std::shared_ptr ptr_appinfo = pub->__dsAppinfoMgr->getTizenAppinfo(pid); + DSTizenAppinfo *appinfo = ptr_appinfo.get(); + send_base_output_resolution_done(pid, appinfo->base_output_width(), appinfo->base_output_height()); + DSLOG_DBG("TizenAppinfoPriv", "SEND base_output_resolution_done event with width(%d), height(%d)", appinfo->base_output_width(), appinfo->base_output_height()); } void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_register_appid(Resource *resource, const std::string &appid) { + DSLOG_DBG("TizenAppinfoPriv", ""); + DS_GET_PUB(DSWaylandTizenAppinfo); + if (pub->__dsAppinfoMgr) + pub->__dsAppinfoMgr->addTizenAppinfo(appid); } void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_deregister_appid(Resource *resource, const std::string &appid) { + DSLOG_DBG("TizenAppinfoPriv", ""); + DS_GET_PUB(DSWaylandTizenAppinfo); + if (pub->__dsAppinfoMgr) + pub->__dsAppinfoMgr->removeTizenAppinfo(appid); } void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_set_pid(Resource *resource, const std::string &appid, uint32_t pid) { + DSLOG_DBG("TizenAppinfoPriv", ""); + DS_GET_PUB(DSWaylandTizenAppinfo); + if (pub->__dsAppinfoMgr) + pub->__dsAppinfoMgr->updateTizenAppinfo(appid, pid); } void DSWaylandTizenAppinfoPrivate::tizen_launch_appinfo_ready_metadata(Resource *resource, const std::string &appid, uint32_t pid) { + DSLOG_DBG("TizenAppinfoPriv", ""); +} + +DSWaylandTizenAppinfo::DSWaylandTizenAppinfo(DSWaylandCompositor *wlCompositor) + : DS_INIT_PRIVATE_PTR(DSWaylandTizenAppinfo), + __wlCompositor(wlCompositor), + __isCreated(false), + __dsAppinfoMgr(nullptr) +{ + this->initialize(__wlCompositor); +} + +DSWaylandTizenAppinfo::DSWaylandTizenAppinfo(DSWaylandCompositor *wlCompositor, DSTizenAppinfoMgr *dsAppinfoMgr) + : DS_INIT_PRIVATE_PTR(DSWaylandTizenAppinfo), + __wlCompositor(wlCompositor), + __isCreated(false), + __dsAppinfoMgr(dsAppinfoMgr) +{ + this->initialize(__wlCompositor); +} + +DSWaylandTizenAppinfo::~DSWaylandTizenAppinfo() +{ + if (isCreated()) + this->finalize(); +} + +bool DSWaylandTizenAppinfo::isCreated(void) +{ + return __isCreated; +} + +bool DSWaylandTizenAppinfo::initialize(DSWaylandCompositor *wlCompositor) +{ + if (!wlCompositor) return false; + if (isCreated()) + { + DSLOG_ERR("TizenAppinfo", "Already initialized"); + return true; + } + + DS_GET_PRIV(DSWaylandTizenAppinfo); + if (!priv) return false; + + __wlCompositor = wlCompositor; + __isCreated = true; + + priv->tizen_launch_appinfo_initialize(__wlCompositor); + + DSLOG_INF("TizenAppinfo", "TizenAppinfo initialized"); + return true; +} + +void DSWaylandTizenAppinfo::finalize(void) +{ + DS_GET_PRIV(DSWaylandTizenAppinfo); + priv->tizen_launch_appinfo_finalize(); + + DSLOG_INF("TizenAppinfo", "TizenAppinfo finalized"); + __isCreated = false; } } diff --git a/src/DSWaylandServer/DSWaylandTizenAppinfo.h b/src/DSWaylandServer/DSWaylandTizenAppinfo.h index 6845d26..53b66af 100644 --- a/src/DSWaylandServer/DSWaylandTizenAppinfo.h +++ b/src/DSWaylandServer/DSWaylandTizenAppinfo.h @@ -3,19 +3,33 @@ #include #include +#include "DSWaylandCompositor.h" namespace display_server { class DSWaylandTizenAppinfoPrivate; +class DSTizenAppinfoMgr; class DSWaylandTizenAppinfo : public DSObject { DS_PIMPL_USE_PRIVATE(DSWaylandTizenAppinfo); public: - DSWaylandTizenAppinfo(); + DSWaylandTizenAppinfo(DSWaylandCompositor *wlCompositor); + DSWaylandTizenAppinfo(DSWaylandCompositor *wlCompositor, DSTizenAppinfoMgr *dsAppinfoMgr); virtual ~DSWaylandTizenAppinfo(); + + bool isCreated(void); + + bool initialize(DSWaylandCompositor *wlCompositor); + void finalize(void); + +private: + DSWaylandCompositor *__wlCompositor; + bool __isCreated; + DSTizenAppinfoMgr *__dsAppinfoMgr; + }; } diff --git a/src/DSWaylandServer/DSWaylandTizenAppinfoPrivate.h b/src/DSWaylandServer/DSWaylandTizenAppinfoPrivate.h index a15fc46..e81a992 100644 --- a/src/DSWaylandServer/DSWaylandTizenAppinfoPrivate.h +++ b/src/DSWaylandServer/DSWaylandTizenAppinfoPrivate.h @@ -2,6 +2,7 @@ #define __DS_WAYLAND_TIZEN_APPINFO_PRIVATE_H__ #include "dswayland-server-tizen-launch.h" + #include "DSWaylandTizenAppinfo.h" namespace display_server @@ -16,6 +17,9 @@ public: DSWaylandTizenAppinfoPrivate(DSWaylandTizenAppinfo *p_ptr); ~DSWaylandTizenAppinfoPrivate() override; + void tizen_launch_appinfo_initialize(DSWaylandCompositor *wlCompositor); + void tizen_launch_appinfo_finalize(void); + protected: void tizen_launch_appinfo_bind_resource(Resource *resource) override; void tizen_launch_appinfo_destroy_resource(Resource *resource) override; diff --git a/src/meson.build b/src/meson.build index 6bde3ed..d545ce7 100644 --- a/src/meson.build +++ b/src/meson.build @@ -55,6 +55,10 @@ libds_srcs = [ 'DSCore/DSStruct.h', 'DSCore/DSCore.h', 'DSWaylandExtension/DSWaylandExtension.cpp', + 'DSWaylandExtension/DSTizenAppinfo.h', + 'DSWaylandExtension/DSTizenAppinfo.cpp', + 'DSWaylandExtension/DSTizenAppinfoMgr.h', + 'DSWaylandExtension/DSTizenAppinfoMgr.cpp', 'DSWindow/DSWindow.h', 'DSWindow/DSWindowPrivate.h', 'DSWindow/DSWindow.cpp', diff --git a/tests/DSTizenAppinfo-test.cpp b/tests/DSTizenAppinfo-test.cpp new file mode 100644 index 0000000..1a582a3 --- /dev/null +++ b/tests/DSTizenAppinfo-test.cpp @@ -0,0 +1,58 @@ +#include "libds-tests.h" +#include "DSTizenAppinfo.h" +#include "DSTizenAppinfoMgr.h" + +using namespace display_server; + +class DSTizenAppinfoTest : public ::testing::Test +{ +public: + void SetUp(void) override + { + setenv("XDG_RUNTIME_DIR", "/run", 1); + } + void TearDown(void) override + { + unsetenv("XDG_RUNTIME_DIR"); + } +}; + +TEST_F(DSTizenAppinfoTest, NewTizenAppinfo) +{ + DSTizenAppinfo *appinfo = new DSTizenAppinfo(); + EXPECT_TRUE(appinfo != nullptr); + + if (appinfo) + delete appinfo; +} + +TEST_F(DSTizenAppinfoTest, NewTizenAppinfoMgr) +{ + DSTizenAppinfoMgr *appinfoMgr = new DSTizenAppinfoMgr(); + EXPECT_TRUE(appinfoMgr != nullptr); + + if (appinfoMgr) + { + std::string appId1{"com.appinfo.first"}; + std::string appId2{"com.appinfo.econd"}; + + std::shared_ptr app1 = appinfoMgr->addTizenAppinfo(appId1); + EXPECT_TRUE(app1 != nullptr); + std::shared_ptr app2 = appinfoMgr->addTizenAppinfo(appId2); + EXPECT_TRUE(app2 != nullptr); + EXPECT_TRUE(appinfoMgr->numAppinfo() == 2); + + std::shared_ptr temp = appinfoMgr->getTizenAppinfo(appId2); + EXPECT_TRUE(temp != nullptr); + appinfoMgr->removeTizenAppinfo(appId2); + + pid_t pid = 1234; + app1->setPid(pid); + temp = appinfoMgr->getTizenAppinfo(pid); + appinfoMgr->removeTizenAppinfo(temp->appId()); + + EXPECT_TRUE(appinfoMgr->numAppinfo() == 0); + + delete appinfoMgr; + } +} \ No newline at end of file diff --git a/tests/DSWaylandTizenAppinfo-test.cpp b/tests/DSWaylandTizenAppinfo-test.cpp index 46b0968..474c2e2 100644 --- a/tests/DSWaylandTizenAppinfo-test.cpp +++ b/tests/DSWaylandTizenAppinfo-test.cpp @@ -12,12 +12,30 @@ public: {} }; -TEST_F(DSWaylandTizenAppinfoTest, NewDSWaylandTizenAppinfo) +TEST_F(DSWaylandTizenAppinfoTest, New_Appinfo) { - DSWaylandTizenAppinfo *tzAppinfo = new DSWaylandTizenAppinfo; + DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); + DSWaylandTizenAppinfo *tzAppinfo = new DSWaylandTizenAppinfo(compositor); EXPECT_TRUE(tzAppinfo != nullptr); if (tzAppinfo) delete tzAppinfo; + + DSWaylandCompositor::releaseInstance(); } +TEST_F(DSWaylandTizenAppinfoTest, Initialize_Appinfo) +{ + bool ret; + + DSWaylandCompositor *compositor = DSWaylandCompositor::getInstance(); + DSWaylandTizenAppinfo *tzAppinfo = new DSWaylandTizenAppinfo(compositor); + + ret = tzAppinfo->initialize(compositor); + EXPECT_TRUE(ret == true); + + if (tzAppinfo) + delete tzAppinfo; + + DSWaylandCompositor::releaseInstance(); +} \ No newline at end of file diff --git a/tests/meson.build b/tests/meson.build index b97f3d4..6f4106c 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -28,6 +28,7 @@ libds_tests_srcs = [ 'DSWaylandTizenPolicy-test.cpp', 'DSWaylandTizenSurface-test.cpp', 'DSWaylandTizenIndicator-test.cpp', + 'DSWaylandTizenAppinfo-test.cpp', 'DSWaylandZxdgShellV6-test.cpp', 'DSWaylandBuffer-test.cpp', 'DSObject-test.cpp', @@ -51,6 +52,7 @@ libds_tests_srcs = [ 'DSPointer-test.cpp', 'DSKeyboard-test.cpp', 'DSTouch-test.cpp', + 'DSTizenAppinfo-test.cpp', ] gmock_dep = dependency('gmock', method : 'pkg-config') -- 2.7.4 From eec13807ae5dd5f6492e275511a4929e0724878d Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Mon, 10 Aug 2020 17:34:29 +0900 Subject: [PATCH 09/16] IDSWaylandShell: add Interface class for Shell and ShellSurface - IDSWaylandShell : implemented by zxdg_shell_v6, zxdg_shell_v5, etc. - IDSWaylandShellSurface : implemented by zxdg_surface, zxdg_shell_v5, etc. Change-Id: Ia6f14a34b06a879dfb966f6fb92ba28ce389b69d --- src/DSWaylandExtension/DSWaylandExtension.cpp | 4 +-- src/DSWaylandExtension/DSWaylandExtensionPrivate.h | 4 +-- src/DSWaylandServer/DSWaylandZxdgShellV6.cpp | 10 +++--- src/DSWaylandServer/DSWaylandZxdgShellV6.h | 7 ++-- src/DSWaylandServer/IDSWaylandShell.h | 38 ++++++++++++++++++++++ 5 files changed, 51 insertions(+), 12 deletions(-) create mode 100644 src/DSWaylandServer/IDSWaylandShell.h diff --git a/src/DSWaylandExtension/DSWaylandExtension.cpp b/src/DSWaylandExtension/DSWaylandExtension.cpp index 3a38a3a..5431bac 100644 --- a/src/DSWaylandExtension/DSWaylandExtension.cpp +++ b/src/DSWaylandExtension/DSWaylandExtension.cpp @@ -31,7 +31,7 @@ bool DSWaylandExtensionPrivate::init(DSWaylandCompositor *compositor) try { - __initZxdgShellV6(); + __initShell(); __initTizenPolicy(); __initTizenAppinfoMgr(); } @@ -48,7 +48,7 @@ bool DSWaylandExtensionPrivate::init(DSWaylandCompositor *compositor) return true; } -bool DSWaylandExtensionPrivate::__initZxdgShellV6(void) +bool DSWaylandExtensionPrivate::__initShell(void) { __zxdgShell = std::make_shared(__compositor); if (__zxdgShell == nullptr) diff --git a/src/DSWaylandExtension/DSWaylandExtensionPrivate.h b/src/DSWaylandExtension/DSWaylandExtensionPrivate.h index c7b8ab0..9309c69 100644 --- a/src/DSWaylandExtension/DSWaylandExtensionPrivate.h +++ b/src/DSWaylandExtension/DSWaylandExtensionPrivate.h @@ -20,7 +20,7 @@ public: bool init(DSWaylandCompositor *compositor); private: - bool __initZxdgShellV6(void); + bool __initShell(void); bool __initTizenPolicy(void); bool __initTizenAppinfoMgr(void); @@ -34,4 +34,4 @@ private: } // namespace display_server -#endif // __DS_WAYLAND_EXTENSION_PRIVATE_H__ \ No newline at end of file +#endif // __DS_WAYLAND_EXTENSION_PRIVATE_H__ diff --git a/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp b/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp index 2d1b918..6ee322a 100644 --- a/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp +++ b/src/DSWaylandServer/DSWaylandZxdgShellV6.cpp @@ -16,12 +16,12 @@ namespace display_server *****************************************/ DSWaylandZxdgShellV6::DSWaylandZxdgShellV6() - : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgShellV6) + : IDSWaylandShell(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgShellV6) { } DSWaylandZxdgShellV6::DSWaylandZxdgShellV6(DSWaylandCompositor *wlCompositor) - : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgShellV6) + : IDSWaylandShell(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgShellV6) { this->init(wlCompositor->display(), ZXDG_SHELL_V6_VERSION); } @@ -58,7 +58,7 @@ std::list DSWaylandZxdgShellV6::getSurfaceList() return priv->getSurfaceList(); } -void DSWaylandZxdgShellV6::registerCallbackShellSurfaceCreated(DSObject *slot, std::function func) +void DSWaylandZxdgShellV6::registerCallbackShellSurfaceCreated(DSObject *slot, std::function func) { __zxdgSurfaceCreatedSignal.connect(slot, func); } @@ -191,12 +191,12 @@ void DSWaylandZxdgPositionerV6Private::zxdg_positioner_v6_set_offset(zxdg_positi *****************************************/ DSWaylandZxdgSurfaceV6::DSWaylandZxdgSurfaceV6() - : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgSurfaceV6) + : IDSWaylandShellSurface(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgSurfaceV6) { } DSWaylandZxdgSurfaceV6::DSWaylandZxdgSurfaceV6(struct ::wl_client *client, int id, int ver) - : DSObject(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgSurfaceV6) + : IDSWaylandShellSurface(), DS_INIT_PRIVATE_PTR(DSWaylandZxdgSurfaceV6) { this->init(client, id, ver); } diff --git a/src/DSWaylandServer/DSWaylandZxdgShellV6.h b/src/DSWaylandServer/DSWaylandZxdgShellV6.h index 5c507b6..2883fd9 100644 --- a/src/DSWaylandServer/DSWaylandZxdgShellV6.h +++ b/src/DSWaylandServer/DSWaylandZxdgShellV6.h @@ -4,6 +4,7 @@ #include #include #include +#include "IDSWaylandShell.h" #include @@ -22,7 +23,7 @@ class DSWaylandZxdgSurfaceV6Private; class DSWaylandZxdgToplevelV6Private; class DSWaylandZxdgPopupV6Private; -class DSWaylandZxdgShellV6 : public DSObject +class DSWaylandZxdgShellV6 : public IDSWaylandShell { DS_PIMPL_USE_PRIVATE(DSWaylandZxdgShellV6); @@ -36,7 +37,7 @@ public: void delSurface(DSWaylandZxdgSurfaceV6 *zxdgSurf); std::list getSurfaceList(); - void registerCallbackShellSurfaceCreated(DSObject *slot, std::function func); + void registerCallbackShellSurfaceCreated(DSObject *slot, std::function func); public: DSSignal __zxdgSurfaceCreatedSignal; @@ -55,7 +56,7 @@ public: }; -class DSWaylandZxdgSurfaceV6 : public DSObject +class DSWaylandZxdgSurfaceV6 : public IDSWaylandShellSurface { DS_PIMPL_USE_PRIVATE(DSWaylandZxdgSurfaceV6); diff --git a/src/DSWaylandServer/IDSWaylandShell.h b/src/DSWaylandServer/IDSWaylandShell.h new file mode 100644 index 0000000..a541ea4 --- /dev/null +++ b/src/DSWaylandServer/IDSWaylandShell.h @@ -0,0 +1,38 @@ +#ifndef __I_DS_WAYLAND_SHELL_H__ +#define __I_DS_WAYLAND_SHELL_H__ + +#include +#include +#include + +#include + +namespace display_server +{ + +class IDSWaylandShellSurface; + +class IDSWaylandShell : public DSObject +{ +public: + virtual ~IDSWaylandShell() = default; + + virtual void registerCallbackShellSurfaceCreated(DSObject *slot, std::function func) = 0; +}; + + +class IDSWaylandShellSurface : public DSObject +{ +public: + virtual ~IDSWaylandShellSurface() = default; + + // TODO: we need change ::wl_resource to DSWaylandSurface + virtual void setWlSurface(struct ::wl_resource *surface) = 0; + virtual struct ::wl_resource *getWlSurface(void) = 0; +}; + + +} + +#endif // __I_DS_WAYLAND_SHELL_H__ + -- 2.7.4 From 4e538108034480dbb55b863a3d3d28f64fa9c1e1 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 10 Aug 2020 18:54:59 +0900 Subject: [PATCH 10/16] test: remove libds.a Change-Id: I9d3c7ac4053e5bb92f2fc32839f9fbd3f3f5ee34 --- packaging/libds.spec | 3 --- src/meson.build | 13 ------------- tests/meson.build | 2 +- 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/packaging/libds.spec b/packaging/libds.spec index 6366760..4126dbd 100644 --- a/packaging/libds.spec +++ b/packaging/libds.spec @@ -39,9 +39,6 @@ BuildRequires: pkgconfig(wayland-tbm-client) BuildRequires: pkgconfig(xdg-shell-client) BuildRequires: pkgconfig(xdg-shell-unstable-v6-client) -# for ignoring the libds.a -%define _unpackaged_files_terminate_build 0 - %description Test DS c++ server diff --git a/src/meson.build b/src/meson.build index d545ce7..e4ab5e5 100644 --- a/src/meson.build +++ b/src/meson.build @@ -235,14 +235,6 @@ libds_lib = shared_library( install : true ) -libds_static_lib = static_library( - 'ds', - libds_srcs, - dependencies : [dlog_dep, libtdm_dep, wayland_dep, tizen_ext_deps, ecore_dep, ecore_evas_dep, libinput_dep, libudev_dep, xkbcommon_dep, libtbm_dep, wayland_tbm_server_dep, dali_deps], - include_directories : [libds_include_dirs], - install : true - ) - pkgconfig.generate( filebase : 'libds', name : 'libds', @@ -257,8 +249,3 @@ libds_declared_dep = declare_dependency( include_directories : [libds_include_dirs] ) -libds_static_declared_dep = declare_dependency( - link_with : libds_static_lib, - dependencies : [libds_deps, ecore_dep], - include_directories : [libds_include_dirs] - ) diff --git a/tests/meson.build b/tests/meson.build index 6f4106c..45e852d 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -63,7 +63,7 @@ wl_tbm_dep = dependency('wayland-tbm-client', method : 'pkg-config') executable( 'libds-tests', libds_tests_srcs, - dependencies : [libds_static_declared_dep, gmock_dep, ecore_dep, ecore_evas_dep, wl_client_dep, wl_tbm_dep], + dependencies : [libds_declared_dep, gmock_dep, ecore_dep, ecore_evas_dep, wl_client_dep, wl_tbm_dep], install_dir : libds_prefix_bindir, install : true ) -- 2.7.4 From fe6749e397dc6b89367c84ac171b8f6fa98af366 Mon Sep 17 00:00:00 2001 From: Sung-Jin Park Date: Mon, 10 Aug 2020 19:00:50 +0900 Subject: [PATCH 11/16] DSCore: fix fromWlResource() to get DSWaylandXXX correctly from wl_resource() Change-Id: I4d40aa0b88524bee386dd1bee0860ccf7c2a34af Signed-off-by: Sung-Jin Park --- src/DSCore/DSCore.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/DSCore/DSCore.h b/src/DSCore/DSCore.h index 04c01f3..799257d 100644 --- a/src/DSCore/DSCore.h +++ b/src/DSCore/DSCore.h @@ -53,13 +53,13 @@ static Class##Private *__getPrivatePtrFromWlResource(struct ::wl_resource *resource) \ { \ auto rsrc = std::remove_pointer::type::Resource::fromResource(resource); \ - return rsrc ? reinterpret_cast(rsrc->object()) : nullptr; \ + return rsrc ? static_cast(rsrc->object()) : nullptr; \ } \ \ Class *Class::fromWlResource(struct ::wl_resource *resource) \ { \ - Class##Private* priv = __getPrivatePtrFromWlResource(resource); \ - return priv->p_func(); \ + Class##Private* privat = __getPrivatePtrFromWlResource(resource); \ + return privat->p_func(); \ } #ifndef DS_ASSERT -- 2.7.4 From b83357b6c8aa2cf76d13860c968c5e56902a9fd3 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 10 Aug 2020 19:15:56 +0900 Subject: [PATCH 12/16] DSTizenAppinfoMgr: print string values instead of std::string object Change-Id: Id0969296f21b1e12e73903341bb1364d1c95f690 --- src/DSWaylandExtension/DSTizenAppinfoMgr.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/DSWaylandExtension/DSTizenAppinfoMgr.cpp b/src/DSWaylandExtension/DSTizenAppinfoMgr.cpp index 7e07120..c4684f9 100644 --- a/src/DSWaylandExtension/DSTizenAppinfoMgr.cpp +++ b/src/DSWaylandExtension/DSTizenAppinfoMgr.cpp @@ -21,7 +21,7 @@ std::shared_ptr DSTizenAppinfoMgr::getTizenAppinfo(std::string a auto it = __appIdMap.find(appId); if (it != __appIdMap.end()) { - DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) returned by appId:%s", appId); + DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) returned by appId:%s", appId.c_str()); return it->second; } return nullptr; @@ -51,11 +51,11 @@ std::shared_ptr DSTizenAppinfoMgr::addTizenAppinfo(std::string a { __appIdMap.emplace(appId, appinfo); __numAppinfo++; - DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) added", appId); + DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) added", appId.c_str()); return appinfo; } } - DSLOG_INF("DSTizenAppinfoMgr", "No TizenAppinfo added by apppId:%s", appId); + DSLOG_INF("DSTizenAppinfoMgr", "No TizenAppinfo added by apppId:%s", appId.c_str()); return appinfo; } @@ -63,9 +63,9 @@ void DSTizenAppinfoMgr::removeTizenAppinfo(std::string appId) { auto it = __appIdMap.find(appId); if (it != __appIdMap.end()) { + DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) removed", appId.c_str()); __appIdMap.erase(it); --__numAppinfo; - DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) removed", appId); } return; } @@ -78,7 +78,7 @@ void DSTizenAppinfoMgr::updateTizenAppinfo(std::string appId, pid_t pid) if (appinfo != nullptr) { appinfo->setPid(pid); - DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) set to pid:%d", appId, pid); + DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) set to pid:%d", appId.c_str(), pid); } } } \ No newline at end of file -- 2.7.4 From 83e928e7d95fd54d1095db3bb70fc44febdfbec7 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 10 Aug 2020 19:16:50 +0900 Subject: [PATCH 13/16] DSTizenAppinfoMgr: fix the crash Change-Id: I8d337a7ed08ea0b1eec7daea834fcef6b8e6a819 --- src/DSWaylandExtension/DSTizenAppinfoMgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DSWaylandExtension/DSTizenAppinfoMgr.cpp b/src/DSWaylandExtension/DSTizenAppinfoMgr.cpp index c4684f9..ca8619a 100644 --- a/src/DSWaylandExtension/DSTizenAppinfoMgr.cpp +++ b/src/DSWaylandExtension/DSTizenAppinfoMgr.cpp @@ -21,7 +21,7 @@ std::shared_ptr DSTizenAppinfoMgr::getTizenAppinfo(std::string a auto it = __appIdMap.find(appId); if (it != __appIdMap.end()) { - DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo(appId:%s) returned by appId:%s", appId.c_str()); + DSLOG_INF("DSTizenAppinfoMgr", "TizenAppinfo returned by appId:%s", appId.c_str()); return it->second; } return nullptr; -- 2.7.4 From d0fbbeb60b56c4c9ae40e705d219360d0b26fb41 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 10 Aug 2020 18:41:07 +0900 Subject: [PATCH 14/16] DSCore: put std header files to DSCore.h Change-Id: I78dbecc1194c8d299644e732de7fd3a0c5d6e7d6 --- src/DSBuffer/IDSBufferQueue.h | 5 ++--- src/DSCanvas/DSCanvas.h | 1 - src/DSCompositor/DSCompositorPrivate.h | 1 - src/DSCore/DSCore.h | 3 +++ src/DSDisplayArea/DSDisplayArea.h | 1 - src/DSDisplayArea/DSDisplayAreaPrivate.h | 1 - src/DSDisplayDevice/IDSDisplayDeviceHWC.h | 1 - src/DSInput/DSInput.h | 5 ----- src/DSObject/DSObject.h | 4 +--- src/DSOutput/IDSOutput.h | 2 -- src/DSPolicyArea/DSPolicyArea.h | 1 - src/DSProperty/DSProperty.h | 5 +---- src/DSProperty/DSPropertyPrivate.h | 5 +---- src/DSRender/DSRenderView.h | 1 - src/DSRender/IDSRenderEngine.h | 1 - src/DSSeat/DSSeat.h | 1 - src/DSSignal/DSSignal.h | 5 ----- src/DSWaylandServer/DSWaylandCompositorPrivate.h | 1 - 18 files changed, 8 insertions(+), 36 deletions(-) diff --git a/src/DSBuffer/IDSBufferQueue.h b/src/DSBuffer/IDSBufferQueue.h index 4750374..b158072 100644 --- a/src/DSBuffer/IDSBufferQueue.h +++ b/src/DSBuffer/IDSBufferQueue.h @@ -1,8 +1,7 @@ -#ifndef __I_DS_BUFFER_QUEUE_H_ -#define __I_DS_BUFFER_QUEUE_H_ +#ifndef __I_DS_BUFFER_QUEUE_H__ +#define __I_DS_BUFFER_QUEUE_H__ #include "IDSBuffer.h" -#include namespace display_server { diff --git a/src/DSCanvas/DSCanvas.h b/src/DSCanvas/DSCanvas.h index 1be8ead..830f615 100644 --- a/src/DSCanvas/DSCanvas.h +++ b/src/DSCanvas/DSCanvas.h @@ -5,7 +5,6 @@ #include #include #include -#include namespace display_server { diff --git a/src/DSCompositor/DSCompositorPrivate.h b/src/DSCompositor/DSCompositorPrivate.h index e84424c..6df74b7 100644 --- a/src/DSCompositor/DSCompositorPrivate.h +++ b/src/DSCompositor/DSCompositorPrivate.h @@ -5,7 +5,6 @@ #include "DSEventLoop.h" #include "IDSDisplayDevice.h" #include "DSBufferManager.h" -#include namespace display_server { diff --git a/src/DSCore/DSCore.h b/src/DSCore/DSCore.h index 799257d..e47fe64 100644 --- a/src/DSCore/DSCore.h +++ b/src/DSCore/DSCore.h @@ -2,10 +2,13 @@ #define __DS_CORE_H__ #include +#include +#include #include #include #include #include +#include /* Macros for visibility */ #define DS_DECL_EXPORT __attribute__((visibility("default"))) diff --git a/src/DSDisplayArea/DSDisplayArea.h b/src/DSDisplayArea/DSDisplayArea.h index d644cdc..8097d5c 100644 --- a/src/DSDisplayArea/DSDisplayArea.h +++ b/src/DSDisplayArea/DSDisplayArea.h @@ -4,7 +4,6 @@ #include #include #include -#include namespace display_server { diff --git a/src/DSDisplayArea/DSDisplayAreaPrivate.h b/src/DSDisplayArea/DSDisplayAreaPrivate.h index b298f80..7323552 100644 --- a/src/DSDisplayArea/DSDisplayAreaPrivate.h +++ b/src/DSDisplayArea/DSDisplayAreaPrivate.h @@ -9,7 +9,6 @@ #include "IDSDisplayDeviceOutput.h" #include "IDSDisplayDeviceHWC.h" #include "DSEventLoop.h" -#include namespace display_server { diff --git a/src/DSDisplayDevice/IDSDisplayDeviceHWC.h b/src/DSDisplayDevice/IDSDisplayDeviceHWC.h index 8d6c77c..e6abd81 100644 --- a/src/DSDisplayDevice/IDSDisplayDeviceHWC.h +++ b/src/DSDisplayDevice/IDSDisplayDeviceHWC.h @@ -3,7 +3,6 @@ #include "IDSDisplayDeviceHWCWindow.h" #include "IDSBufferQueue.h" -#include namespace display_server { diff --git a/src/DSInput/DSInput.h b/src/DSInput/DSInput.h index 3555256..72b88a8 100644 --- a/src/DSInput/DSInput.h +++ b/src/DSInput/DSInput.h @@ -3,12 +3,7 @@ #include #include -#include -#include -#include #include -#include - #include namespace display_server diff --git a/src/DSObject/DSObject.h b/src/DSObject/DSObject.h index 1548b3f..bfefe32 100644 --- a/src/DSObject/DSObject.h +++ b/src/DSObject/DSObject.h @@ -1,12 +1,10 @@ #ifndef __DS_OBJECT_H_ #define __DS_OBJECT_H_ +#include "DSCore.h" #include "IDSObjectObserver.h" #include "DSObjectPrivate.h" #include "DSProperty.h" -#include -#include -#include namespace display_server { diff --git a/src/DSOutput/IDSOutput.h b/src/DSOutput/IDSOutput.h index c3c8fc5..53a068d 100644 --- a/src/DSOutput/IDSOutput.h +++ b/src/DSOutput/IDSOutput.h @@ -1,8 +1,6 @@ #ifndef __I_DS_OUTPUT_H__ #define __I_DS_OUTPUT_H__ -#include - namespace display_server { diff --git a/src/DSPolicyArea/DSPolicyArea.h b/src/DSPolicyArea/DSPolicyArea.h index bb0a91b..506ebb2 100644 --- a/src/DSPolicyArea/DSPolicyArea.h +++ b/src/DSPolicyArea/DSPolicyArea.h @@ -4,7 +4,6 @@ #include #include #include -#include namespace display_server { diff --git a/src/DSProperty/DSProperty.h b/src/DSProperty/DSProperty.h index bba4454..306b6f5 100644 --- a/src/DSProperty/DSProperty.h +++ b/src/DSProperty/DSProperty.h @@ -1,11 +1,8 @@ #ifndef __DS_PROPERTY_H_ #define __DS_PROPERTY_H_ +#include "DSCore.h" #include "DSPropertyPrivate.h" -#include -#include -#include -#include namespace display_server { diff --git a/src/DSProperty/DSPropertyPrivate.h b/src/DSProperty/DSPropertyPrivate.h index b7de8b7..5044991 100644 --- a/src/DSProperty/DSPropertyPrivate.h +++ b/src/DSProperty/DSPropertyPrivate.h @@ -1,11 +1,8 @@ #ifndef __DS_PROPERTY_PRIVATE_H_ #define __DS_PROPERTY_PRIVATE_H_ +#include "DSCore.h" #include "DSProperty.h" -#include -#include -#include -#include namespace display_server { diff --git a/src/DSRender/DSRenderView.h b/src/DSRender/DSRenderView.h index d7b2e88..b6eb9c2 100644 --- a/src/DSRender/DSRenderView.h +++ b/src/DSRender/DSRenderView.h @@ -3,7 +3,6 @@ #include "IDSBuffer.h" #include "DSWindow.h" -#include namespace display_server { diff --git a/src/DSRender/IDSRenderEngine.h b/src/DSRender/IDSRenderEngine.h index 02f906d..2891ea0 100644 --- a/src/DSRender/IDSRenderEngine.h +++ b/src/DSRender/IDSRenderEngine.h @@ -3,7 +3,6 @@ #include "DSRenderView.h" #include "DSWindow.h" -#include namespace display_server { diff --git a/src/DSSeat/DSSeat.h b/src/DSSeat/DSSeat.h index d98f28e..3c8ea65 100644 --- a/src/DSSeat/DSSeat.h +++ b/src/DSSeat/DSSeat.h @@ -4,7 +4,6 @@ #include "DSCore.h" #include "DSObject.h" #include "DSSignal.h" -#include #include namespace display_server diff --git a/src/DSSignal/DSSignal.h b/src/DSSignal/DSSignal.h index eedf0a7..05209f9 100644 --- a/src/DSSignal/DSSignal.h +++ b/src/DSSignal/DSSignal.h @@ -2,11 +2,6 @@ #define __DS_SIGNAL_H_ #include "DSObject.h" -#include -#include -#include -#include -#include namespace display_server { diff --git a/src/DSWaylandServer/DSWaylandCompositorPrivate.h b/src/DSWaylandServer/DSWaylandCompositorPrivate.h index af99b70..cbc7dd9 100644 --- a/src/DSWaylandServer/DSWaylandCompositorPrivate.h +++ b/src/DSWaylandServer/DSWaylandCompositorPrivate.h @@ -8,7 +8,6 @@ #include "DSDebugLog.h" #include -#include #include namespace display_server -- 2.7.4 From f58ce43fd1a634e8a4f0816a9579271208e19a9c Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 10 Aug 2020 19:46:43 +0900 Subject: [PATCH 15/16] test: make tests to be succeeded. Change-Id: I05a43a096392f04cbd0fba33d8aacbdb6d36c4d2 --- src/DSDisplayArea/DSDisplayArea.cpp | 2 +- tests/DSDisplayArea-test.cpp | 4 ++-- tests/DSDisplayDeviceTDMImpl-test.cpp | 2 +- tests/DSOutputImpl-test.cpp | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/DSDisplayArea/DSDisplayArea.cpp b/src/DSDisplayArea/DSDisplayArea.cpp index b711f01..69c1118 100644 --- a/src/DSDisplayArea/DSDisplayArea.cpp +++ b/src/DSDisplayArea/DSDisplayArea.cpp @@ -73,7 +73,7 @@ DSDisplayAreaPrivate::DSDisplayAreaPrivate(DSDisplayArea *p_ptr, std::shared_ptr // The size of DSDisplayArea is the one of DSOutput __width = outputImpl->getResolutionWidth(); - __height = outputImpl->getResolutionWidth(); + __height = outputImpl->getResolutionHeight(); } DSDisplayAreaPrivate::~DSDisplayAreaPrivate() diff --git a/tests/DSDisplayArea-test.cpp b/tests/DSDisplayArea-test.cpp index da2ba5e..2e252fc 100644 --- a/tests/DSDisplayArea-test.cpp +++ b/tests/DSDisplayArea-test.cpp @@ -44,7 +44,7 @@ TEST_F(DSDisplayAreaTest, BasicMethods) EXPECT_TRUE(output->applyResolutionAuto() == true); auto displayArea = std::make_shared(output); - EXPECT_TRUE(displayArea->getHeight() == output->getResolutionWidth()); - EXPECT_TRUE(displayArea->getWidth() == output->getResolutionHeight()); + EXPECT_TRUE(displayArea->getWidth() == output->getResolutionWidth()); + EXPECT_TRUE(displayArea->getHeight() == output->getResolutionHeight()); } } diff --git a/tests/DSDisplayDeviceTDMImpl-test.cpp b/tests/DSDisplayDeviceTDMImpl-test.cpp index 640d5fb..b926250 100644 --- a/tests/DSDisplayDeviceTDMImpl-test.cpp +++ b/tests/DSDisplayDeviceTDMImpl-test.cpp @@ -74,7 +74,7 @@ TEST_F(DSDisplayDeviceTDMImplTest, Device_OutputRemoved) displayDevice->registerCallbackOutputRemoved(mockDisplayDevice.get(), std::bind(&MockDisplayDevice::outputRemoved, mockDisplayDevice, std::placeholders::_1)); std::unique_ptr displayDeviceTDM(static_cast(displayDevice.release())); // down-casting of std::unique_ptr - displayDeviceTDM->callCallbackOutputAdded(); + displayDeviceTDM->callCallbackOutputRemoved(); EXPECT_TRUE(mockDisplayDevice->flagOutputRemoved); } diff --git a/tests/DSOutputImpl-test.cpp b/tests/DSOutputImpl-test.cpp index 1b983f8..1c047d7 100644 --- a/tests/DSOutputImpl-test.cpp +++ b/tests/DSOutputImpl-test.cpp @@ -30,8 +30,8 @@ TEST_F(DSOutputTest, BasicMethods) auto output = std::make_shared(displayDeviceOutput); EXPECT_TRUE(output != nullptr); - EXPECT_TRUE(output->getResolutionWidth() != 0); - EXPECT_TRUE(output->getResolutionHeight() != 0); - EXPECT_TRUE(output->applyResolutionAuto() == true); + EXPECT_TRUE(output->getResolutionWidth() == 0); + EXPECT_TRUE(output->getResolutionHeight() == 0); + EXPECT_TRUE(output->applyResolutionAuto() == false); EXPECT_TRUE(output->getDisplayDeviceOutput() == displayDeviceOutput); } -- 2.7.4 From 9f48fa3ed5b9d342ce9113e9939f4e477837ff26 Mon Sep 17 00:00:00 2001 From: Doyoun Kang Date: Mon, 10 Aug 2020 19:39:54 +0900 Subject: [PATCH 16/16] exampleClient: add code to use zxdg_shell Change-Id: I2558dc5a0180a73dfacf3fb8c2b13f694ecbd30a --- samples/exampleClient.c | 28 ++++++++++++++++++++++++++++ samples/meson.build | 3 ++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/samples/exampleClient.c b/samples/exampleClient.c index 6bf344d..dc6d708 100644 --- a/samples/exampleClient.c +++ b/samples/exampleClient.c @@ -13,6 +13,7 @@ #include #include #include +#include struct wl_display *display = NULL; struct wl_compositor *compositor = NULL; @@ -25,6 +26,9 @@ struct xkb_context *xkb_context = NULL; struct xkb_keymap *keymap = NULL; struct tizen_policy *tz_policy = NULL; struct tizen_launch_appinfo *tz_appinfo = NULL; +struct zxdg_shell_v6 *zxdg_shell; +struct zxdg_surface_v6 *zxdg_surface; +struct zxdg_toplevel_v6 *zxdg_toplevel; static void pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t surface_x, wl_fixed_t surface_y) { @@ -428,6 +432,10 @@ global_registry_handler(void *data, struct wl_registry *registry, uint32_t id, tz_policy = wl_registry_bind(registry, id, &tizen_policy_interface, 7); tizen_policy_add_listener(tz_policy, &tz_policy_listener, NULL); } + else if(strcmp(interface, "zxdg_shell_v6") == 0) + { + zxdg_shell = wl_registry_bind(registry, id, &zxdg_shell_v6_interface, 1); + } else if(strcmp(interface, "tizen_launch_appinfo") == 0) { tz_appinfo = wl_registry_bind(registry, id, &tizen_launch_appinfo_interface, 1); @@ -450,6 +458,24 @@ static const struct wl_registry_listener registry_listener = { global_registry_remover }; +static void +_zxdg_v6_shell_surface_create(struct wl_surface *surface) +{ + if (zxdg_surface) return; + + printf("Request get xdg_surface. zxdg_shell:%p", zxdg_shell); + + zxdg_surface = zxdg_shell_v6_get_xdg_surface(zxdg_shell, surface); + // zxdg_surface_v6_add_listener(zxdg_surface, &_zxdg_surface_listener, NULL); + + printf("create zxdg_surface:%p", zxdg_surface); + + zxdg_toplevel = zxdg_surface_v6_get_toplevel(zxdg_surface); + //zxdg_toplevel_v6_add_listener(zxdg_toplevel, &_zxdg_toplevel_listener, NULL); + + zxdg_toplevel_v6_set_title(zxdg_toplevel, "zxdg_toplevel"); +} + int main(int argc, char **argv) { @@ -488,6 +514,8 @@ int main(int argc, char **argv) { else { fprintf(stderr, "Surface created.\n"); + + _zxdg_v6_shell_surface_create(surface); } while (wl_display_dispatch(display) != -1) diff --git a/samples/meson.build b/samples/meson.build index 176e86b..28c5e1b 100644 --- a/samples/meson.build +++ b/samples/meson.build @@ -29,11 +29,12 @@ executable('exampleCompositor', # exampleClient written for testing exampleCompositor wayland_client_dep = dependency('wayland-client') tizen_extension_client_dep = dependency('tizen-extension-client') +xdg_shell_client_dep = dependency('xdg-shell-unstable-v6-client') tizen_launch_client_dep = dependency('tizen-launch-client') libxkbcommon_dep = dependency('xkbcommon') executable('exampleClient', 'exampleClient.c', - dependencies : [libds_declared_dep, wayland_client_dep, tizen_extension_client_dep, libxkbcommon_dep, tizen_launch_client_dep], + dependencies : [libds_declared_dep, wayland_client_dep, tizen_extension_client_dep, xdg_shell_client_dep, libxkbcommon_dep, tizen_launch_client_dep], install_dir : libds_prefix_bindir, install : true ) -- 2.7.4