class DisplayAction : public PluginAction {
public:
DisplayAction(const std::string &name);
- virtual ~DisplayAction() = default;
+ ~DisplayAction() = default;
virtual int set(int val);
virtual int set(bool val);
+++ /dev/null
-/*
- * Copyright (c) 2019-2020 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "DisplayAllowPalmTouch.h"
-#include <sstream>
-#include <string>
-#include <Ecore_Wl2.h>
-#include <efl_util.h>
-#include <Ecore.h>
-#include <modes_errors.h>
-#include "plugin-log.h"
-
-MODES_NAMESPACE_USE;
-
-const std::string DisplayAllowPalmTouch::NAME = "allowPalmTouch";
-
-DisplayAllowPalmTouch::DisplayAllowPalmTouch()
- :DisplayAction(NAME)
-{
-}
-
-DisplayAllowPalmTouch::~DisplayAllowPalmTouch()
-{
-}
-
-int DisplayAllowPalmTouch::set(bool val)
-{
- int ret = EFL_UTIL_ERROR_NONE;
- int modesRet;
- Ecore_Wl2_Display *displayHandle;
- efl_util_gesture_h gestureHandle = NULL;
-
- char *envString = getenv("XDG_RUNTIME_DIR");
- if (NULL == envString)
- setenv("XDG_RUNTIME_DIR", "/run", 1);
-
- ecore_wl2_init();
- displayHandle = ecore_wl2_display_connect(NULL);
- if (!displayHandle) {
- ret = get_last_result();
- ERR("ecore_wl2_display_connect() Fail(%d)", ret);
- return MODES_ERROR_SYSTEM;
- }
-
- gestureHandle = efl_util_gesture_initialize();
- if (NULL == gestureHandle) {
- ret = get_last_result();
- ERR("efl_util_gesture_initialize() Fail(%d)", ret);
- return MODES_ERROR_SYSTEM;
- }
-
- ret = efl_util_gesture_activate_set(gestureHandle,
- EFL_UTIL_GESTURE_TYPE_PALM_COVER, val);
-
-
- if (EFL_UTIL_ERROR_NONE == ret) {
- modesRet = MODES_ERROR_NONE;
- } else {
- ERR("efl_util_gesture_activate_set() Fail(%d)", ret);
- modesRet = MODES_ERROR_SYSTEM;
- }
-
- ecore_wl2_display_disconnect(displayHandle);
- ecore_wl2_shutdown();
- return modesRet;
-}
-
-void DisplayAllowPalmTouch::undo()
-{
- set(true);
-}
-
-std::string DisplayAllowPalmTouch::serialize()
-{
- std::ostringstream ostr;
-
- ostr << 1;
- return ostr.str();
-}
-
-int DisplayAllowPalmTouch::parse(const std::string &archive)
-{
- DBG("parse() Called()");
-
- return MODES_ERROR_NONE;
-}
+++ /dev/null
-/*
- * Copyright (c) 2019-2020 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <string>
-#include "plugin-def.h"
-#include "DisplayAction.h"
-
-MODES_NAMESPACE_BEGIN
-
-class DisplayAllowPalmTouch : public DisplayAction {
-public:
- DisplayAllowPalmTouch();
- ~DisplayAllowPalmTouch();
-
- int set(bool val) override;
- void undo() override;
- std::string serialize() override;
- int parse(const std::string &archive) override;
-
- static const std::string NAME;
-};
-
-MODES_NAMESPACE_END
#include <list>
#include <sstream>
#include <string>
-#include <stdlib.h>
+#include <vconf.h>
#include <device/display.h>
+#include <device/callback.h>
#include <modes_errors.h>
#include "plugin-log.h"
MODES_NAMESPACE_USE;
const std::string DisplayBrightness::NAME = "brightness";
+const char* const DisplayBrightness::KEY = VCONFKEY_SETAPPL_LCD_BRIGHTNESS;
DisplayBrightness::DisplayBrightness()
- :DisplayAction(NAME)
+ :DisplayAction(NAME), requestVal(0), cb(nullptr), cbData(nullptr)
{
device_display_get_numbers(&numDisplay);
}
-DisplayBrightness::~DisplayBrightness()
-{
-}
-
int DisplayBrightness::set(int val)
{
+ requestVal = val;
+
+ int ret = cbHandler.handleSubscription(KEY);
+ if (MODES_ERROR_NONE != ret) {
+ ERR("handleChange(%s) Fail(%d)", KEY, ret);
+ return ret;
+ }
+
for (int i = 0; i < numDisplay ; i++) {
int oldVal = 0;
- int ret = device_display_get_brightness(i, &oldVal);
+ ret = device_display_get_brightness(i, &oldVal);
if (DEVICE_ERROR_NONE != ret) {
ERR("device_display_get_brightness(%d) Fail(%s)", i, get_error_message(ret));
return MODES_ERROR_SYSTEM;
}
for (int i = 0; i < numDisplay ; i++) {
- int ret = device_display_set_brightness(i, val);
+ int realVal = val;
+ if (realVal < 0) {
+ int realVal = 100;
+ ret = device_display_get_max_brightness(i, &realVal);
+ if (DEVICE_ERROR_NONE != ret)
+ ERR("device_display_get_max_brightness() Fail(%d)", ret);
+ }
+
+ ret = device_display_set_brightness(i, realVal);
if (DEVICE_ERROR_NONE != ret) {
- ERR("device_display_set_brightness(%d, %d) Fail(%s)", i, val, get_error_message(ret));
+ ERR("device_display_set_brightness(%d, %d) Fail(%s)", i, realVal, get_error_message(ret));
return MODES_ERROR_SYSTEM;
}
}
return MODES_ERROR_NONE;
}
+
+int DisplayBrightness::setChangedCallback(valueChangedCB callback, void *userData)
+{
+ RETV_IF(nullptr == callback, MODES_ERROR_INVALID_PARAMETER);
+
+ int ret = cbHandler.setChangedCB(KEY, this);
+ if (MODES_ERROR_NONE != ret) {
+ ERR("setChangedCB(%s) Fail(%d)", KEY, ret);
+ return ret;
+ }
+
+ cb = callback;
+ cbData = userData;
+
+ return MODES_ERROR_NONE;
+}
+void DisplayBrightness::unSetChangedCallback(valueChangedCB callback, void *userData)
+{
+ RET_IF(nullptr == callback);
+
+ cbHandler.unSetChangedCB(KEY);
+
+ cbData = nullptr;
+ cb = nullptr;
+}
+
+void DisplayBrightness::vconfChangedCB()
+{
+ //The value will be changed by Modes. That's why the callback is always called.
+ if (cb)
+ cb(cbData);
+}
+
+void DisplayBrightness::vconfChangedCB(keynode_t *node)
+{
+ const char *vconfKey = vconf_keynode_get_name(node);
+ if (vconfKey != KEY) {
+ WARN("Unknown vconf(%s) notification", vconfKey);
+ return;
+ }
+
+ int realVal = requestVal;
+ if (realVal < 0) {
+ int ret = device_display_get_max_brightness(0, &realVal);
+ if (DEVICE_ERROR_NONE != ret)
+ ERR("device_display_get_max_brightness() Fail(%d)", ret);
+ }
+
+ int val = vconf_keynode_get_int(node);
+ if (cb && (val != realVal))
+ cb(cbData);
+}
*/
#pragma once
-#include <string>
#include <list>
+#include <string>
#include "plugin-def.h"
#include "DisplayAction.h"
+#include "VconfCbHandler.h"
MODES_NAMESPACE_BEGIN
-class DisplayBrightness : public DisplayAction {
+class DisplayBrightness : public DisplayAction, public VconfChangeAction {
public:
DisplayBrightness();
- ~DisplayBrightness();
+ ~DisplayBrightness() = default;
int set(int val) override;
void undo() override;
std::string serialize() override;
int parse(const std::string &archive) override;
+ int setChangedCallback(valueChangedCB callback, void *userData) override;
+ void unSetChangedCallback(valueChangedCB callback, void *userData) override;
- static const std::string NAME;
+ void vconfChangedCB() override;
+ void vconfChangedCB(keynode_t *node) override;
+ static const std::string NAME;
+ static const char* const KEY;
private:
const char delimiter = '#';
int numDisplay;
+ int requestVal;
std::list<int> oldValList;
+ VconfCbHandler cbHandler;
+ valueChangedCB cb;
+ void *cbData;
};
MODES_NAMESPACE_END
--- /dev/null
+/*
+ * Copyright (c) 2019-2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "DisplayDenyPalmTouch.h"
+
+#include <sstream>
+#include <string>
+#include <Ecore_Wl2.h>
+#include <efl_util.h>
+#include <Ecore.h>
+#include <modes_errors.h>
+#include "plugin-log.h"
+
+MODES_NAMESPACE_USE;
+
+const std::string DisplayDenyPalmTouch::NAME = "denyPalmTouch";
+
+DisplayDenyPalmTouch::DisplayDenyPalmTouch()
+ :DisplayAction(NAME)
+{
+}
+
+int DisplayDenyPalmTouch::set(bool val)
+{
+ char *envString = getenv("XDG_RUNTIME_DIR");
+ if (nullptr == envString)
+ setenv("XDG_RUNTIME_DIR", "/run", 1);
+
+ ecore_wl2_init();
+ Ecore_Wl2_Display *displayHandle = ecore_wl2_display_connect(NULL);
+ if (nullptr == displayHandle) {
+ ERR("ecore_wl2_display_connect() Fail(%d)", get_last_result());
+ return MODES_ERROR_SYSTEM;
+ }
+
+ efl_util_gesture_h gestureHandle = efl_util_gesture_initialize();
+ if (nullptr == gestureHandle) {
+ ERR("efl_util_gesture_initialize() Fail(%d)", get_last_result());
+ return MODES_ERROR_SYSTEM;
+ }
+
+ int ret = efl_util_gesture_activate_set(gestureHandle, EFL_UTIL_GESTURE_TYPE_PALM_COVER, !val);
+ ecore_wl2_display_disconnect(displayHandle);
+ ecore_wl2_shutdown();
+
+ if (EFL_UTIL_ERROR_NONE != ret) {
+ ERR("efl_util_gesture_activate_set() Fail(%d)", ret);
+ return MODES_ERROR_SYSTEM;
+ }
+
+ return MODES_ERROR_NONE;
+}
+
+void DisplayDenyPalmTouch::undo()
+{
+ set(false);
+}
+
+std::string DisplayDenyPalmTouch::serialize()
+{
+ //Not Support
+ return std::string();
+}
+
+int DisplayDenyPalmTouch::parse(const std::string &archive)
+{
+ WARN("Palm Touch setting is volatile");
+ return MODES_ERROR_NOT_SUPPORTED;
+}
+
+int DisplayDenyPalmTouch::setChangedCallback(valueChangedCB callback, void *userData)
+{
+ ERR("Not Support Changed Callback");
+ return MODES_ERROR_NOT_SUPPORTED;
+}
+
+void DisplayDenyPalmTouch::unSetChangedCallback(valueChangedCB callback, void *userData)
+{
+ ERR("Not Support Changed Callback");
+}
--- /dev/null
+/*
+ * Copyright (c) 2019-2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <string>
+#include "plugin-def.h"
+#include "DisplayAction.h"
+
+MODES_NAMESPACE_BEGIN
+
+class DisplayDenyPalmTouch : public DisplayAction {
+public:
+ DisplayDenyPalmTouch();
+ ~DisplayDenyPalmTouch() = default;
+
+ int set(bool val) override;
+ void undo() override;
+ std::string serialize() override;
+ int parse(const std::string &archive) override;
+ int setChangedCallback(valueChangedCB callback, void *userData) override;
+ void unSetChangedCallback(valueChangedCB callback, void *userData) override;
+
+ static const std::string NAME;
+private:
+ bool oldVal;
+};
+
+MODES_NAMESPACE_END
* limitations under the License.
*/
#include "DisplayFactory.h"
+
#include <string>
#include <device/power.h>
#include "plugin-log.h"
#include "DisplayActVconf.h"
#include "DisplayBrightness.h"
-#include "DisplayAllowPalmTouch.h"
+#include "DisplayDenyPalmTouch.h"
MODES_NAMESPACE_USE;
actionMap[DisplayActVconf::NAME[AUTO_BRIGHTNESS_VCONF]] = AUTO_BRIGHTNESS_VCONF;
actionMap[DisplayActVconf::NAME[TIMEOUT_VCONF]] = TIMEOUT_VCONF;
actionMap[DisplayBrightness::NAME] = BRIGHTNESS;
- actionMap[DisplayAllowPalmTouch::NAME] = ALLOW_PALM_TOUCH;
+ actionMap[DisplayDenyPalmTouch::NAME] = DENY_PALM_TOUCH;
}
DisplayAction* DisplayFactory::createAction(const std::string &key)
{
auto search = actionMap.find(key);
- if (search == actionMap.end()) {
+ if (actionMap.end() == search) {
ERR("No DisplayAction(%s)", key.c_str());
return nullptr;
}
case BRIGHTNESS:
action = new DisplayBrightness();
break;
- case ALLOW_PALM_TOUCH:
- action = new DisplayAllowPalmTouch();
+ case DENY_PALM_TOUCH:
+ action = new DisplayDenyPalmTouch();
break;
default:
action = nullptr;
AUTO_BRIGHTNESS_VCONF,
TIMEOUT_VCONF,
BRIGHTNESS,
- ALLOW_PALM_TOUCH,
+ DENY_PALM_TOUCH,
};
std::map<std::string, enum actionKey> actionMap;
<desc>Display Timeout</desc>
<domain>System</domain>
</rule>
- <rule name="display.allowPalmTouch" type="bool" since="6.0" plugin="display">
+ <rule name="display.denyPalmTouch" type="bool" since="6.0" plugin="display">
<alias name="on">1</alias>
- <alias name="off">0</alias>
- <desc>Allow palm touch on display</desc>
+ <desc>Deny palm touch on display. False will be ignored</desc>
<domain>Graphics System</domain>
</rule>
</actionRule>
g_main_loop_unref(loop);
loop = NULL;
objectDelete(plugin);
- plugin = NULL;
+ plugin = nullptr;
}
static gboolean displayPluginBrightnessIdler(gpointer data)
};
int displayPluginTest::result = 0;
-Plugin *displayPluginTest::plugin = NULL;
+Plugin *displayPluginTest::plugin = nullptr;
GMainLoop *displayPluginTest::loop = NULL;
TEST_F(displayPluginTest, setBrightness)