Merge pull request #5133 from J0hannes101/master
feat(cursor): use cursor-shape-v1 cursor names instead of Gdk::CursorType
This commit is contained in:
+8
-8
@@ -78,12 +78,12 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::
|
||||
if (config_.isMember("cursor")) {
|
||||
if (config_["cursor"].isBool()) {
|
||||
if (config_["cursor"].asBool()) {
|
||||
setCursor(Gdk::HAND2);
|
||||
setCursor("pointer");
|
||||
} else {
|
||||
setCursor(Gdk::ARROW);
|
||||
setCursor("default");
|
||||
}
|
||||
} else if (config_["cursor"].isInt()) {
|
||||
setCursor(Gdk::CursorType(config_["cursor"].asInt()));
|
||||
} else if (config_["cursor"].isString()) {
|
||||
setCursor(config_["cursor"].asString());
|
||||
} else {
|
||||
spdlog::warn("unknown cursor option configured on module {}", name_);
|
||||
}
|
||||
@@ -121,10 +121,10 @@ auto AModule::doAction(const std::string& name) -> void {
|
||||
}
|
||||
}
|
||||
|
||||
void AModule::setCursor(Gdk::CursorType const& c) {
|
||||
void AModule::setCursor(std::string const& c) {
|
||||
auto gdk_window = event_box_.get_window();
|
||||
if (gdk_window) {
|
||||
auto cursor = Gdk::Cursor::create(c);
|
||||
auto cursor = Gdk::Cursor::create(gdk_window->get_display(), c);
|
||||
gdk_window->set_cursor(cursor);
|
||||
} else {
|
||||
// window may not be accessible yet, in this case,
|
||||
@@ -145,7 +145,7 @@ bool AModule::handleMouseEnter(GdkEventCrossing* const& e) {
|
||||
|
||||
// Default behavior indicating event availability
|
||||
if (hasUserEvents_ && !config_.isMember("cursor")) {
|
||||
setCursor(Gdk::HAND2);
|
||||
setCursor("pointer");
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -158,7 +158,7 @@ bool AModule::handleMouseLeave(GdkEventCrossing* const& e) {
|
||||
|
||||
// Default behavior indicating event availability
|
||||
if (hasUserEvents_ && !config_.isMember("cursor")) {
|
||||
setCursor(Gdk::ARROW);
|
||||
setCursor("default");
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
|
||||
#include "gdkmm/cursor.h"
|
||||
#include "gdkmm/event.h"
|
||||
#include "gdkmm/types.h"
|
||||
#include "glibmm/fileutils.h"
|
||||
|
||||
Reference in New Issue
Block a user