Skip to content

Commit

Permalink
Rewrite events processing (fix mouse related bugs)
Browse files Browse the repository at this point in the history
Merge pull request #285 from netxs-group/dev/sdn
  • Loading branch information
o-sdn-o authored Dec 1, 2022
2 parents c5c364b + 0acfbda commit 99442c7
Show file tree
Hide file tree
Showing 26 changed files with 948 additions and 1,237 deletions.
4 changes: 2 additions & 2 deletions .resources/status/freebsd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions .resources/status/linux.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions .resources/status/macos.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions .resources/status/netbsd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions .resources/status/openbsd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions .resources/status/windows.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions src/netxs/abstract/macrogen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#define MAKE_ATTR(type, name, ...) type name{};
#define MAKE_SIGN(type, name, ...) type name
#define MAKE_TYPE(type, name, ...) type
#define MAKE_TEMP(type, name, ...) this->name = source. name;
#define MAKE_LOGS(type, name, ...) s << "\n\t " << #name << ": " << o.name;
#define MAKE_WIPE(type, name, ...) this->name = {};

#define SEQ_ATTR__odd(...) MAKE_ATTR __VA_ARGS__ SEQ_ATTR_even
#define SEQ_ATTR_even(...) MAKE_ATTR __VA_ARGS__ SEQ_ATTR__odd
Expand All @@ -35,6 +38,24 @@
#define SEQ_INIT__odd_last
#define SEQ_INIT(args) EVAL(CAT(SEQ_INIT__odd args, _last))

#define SEQ_TEMP__odd(...) MAKE_TEMP __VA_ARGS__ SEQ_TEMP_even
#define SEQ_TEMP_even(...) MAKE_TEMP __VA_ARGS__ SEQ_TEMP__odd
#define SEQ_TEMP_even_last
#define SEQ_TEMP__odd_last
#define SEQ_TEMP(args) EVAL(CAT(SEQ_TEMP__odd args, _last))

#define SEQ_WIPE__odd(...) MAKE_WIPE __VA_ARGS__ SEQ_WIPE_even
#define SEQ_WIPE_even(...) MAKE_WIPE __VA_ARGS__ SEQ_WIPE__odd
#define SEQ_WIPE_even_last
#define SEQ_WIPE__odd_last
#define SEQ_WIPE(args) EVAL(CAT(SEQ_WIPE__odd args, _last))

#define SEQ_LOGS__odd(...) MAKE_LOGS __VA_ARGS__ SEQ_LOGS_even
#define SEQ_LOGS_even(...) MAKE_LOGS __VA_ARGS__ SEQ_LOGS__odd
#define SEQ_LOGS_even_last
#define SEQ_LOGS__odd_last
#define SEQ_LOGS(args) EVAL(CAT(SEQ_LOGS__odd args, _last))

#define SEQ_SIGN__odd(...) MAKE_SIGN __VA_ARGS__, SEQ_SIGN_even
#define SEQ_SIGN_even(...) MAKE_SIGN __VA_ARGS__, SEQ_SIGN__odd
#define SEQ_SIGN_even_last
Expand Down
14 changes: 11 additions & 3 deletions src/netxs/abstract/ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,29 @@ namespace netxs
T last = {};
bool test = faux;

bool operator () (T newvalue)
bool test_and_set(T newvalue)
{
prev = last;
test = last != newvalue;
if (test) last = newvalue;
return test;
}
operator T& () { return last; }
bool operator () (T newvalue)
{
return test_and_set(newvalue);
}
operator auto& () { return last; }
operator auto& () const { return last; }
auto reset()
{
auto temp = test;
test = faux;
return temp;
}
testy() = default;
testy() = default;
testy(testy&&) = default;
testy(testy const&) = default;
testy& operator = (testy const&) = default;
testy(T const& value)
: prev{ value },
last{ value },
Expand Down
11 changes: 4 additions & 7 deletions src/netxs/apps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ R"==(
<preview enabled=true size=80x25 />
</clipboard>
<viewport coor=0,0 />
<mouse dblclick=500ms />
<tooltip timeout=500ms enabled=true />
<glowfx=true /> <!-- Show glow effect around selected item. -->
<debug overlay=faux toggle="🐞" /> <!-- Display console debug info. -->
Expand Down Expand Up @@ -1391,6 +1392,7 @@ namespace netxs::app::shared
m.title = name; // Use the same title as the menu label.
m.param = args;
m.hidden = true;
m.settings = config; //todo it is dangerous
menu_list[name];

auto current_default = e2::data::changed.param();
Expand All @@ -1409,21 +1411,16 @@ namespace netxs::app::shared
};
auto build_DirectVT = [](text cwd, text param, xml::settings& config)
{
auto window = ui::cake::ctor()
return ui::dtvt::ctor(cwd, param, config.utf8()) //todo pass subconfig
->plugin<pro::limit>(dot_11)
->plugin<pro::focus>();

//todo pass subconfig
auto direct = ui::dtvt::ctor(cwd, param, config.utf8())
->plugin<pro::focus>()
->invoke([](auto& boss)
{
boss.SUBMIT(tier::anycast, e2::form::upon::started, root)
{
boss.start();
};
});
window->attach(direct);
return window;
};
auto build_ANSIVT = [](text cwd, text param, xml::settings& config)
{
Expand Down
2 changes: 1 addition & 1 deletion src/netxs/apps/calc.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) NetXS Group.
// Licensed under the MIT license.

#define DESKTOPIO_VER "v0.9.6j"
#define DESKTOPIO_VER "v0.9.6k"
#define DESKTOPIO_MYNAME "Desktopio Calc " DESKTOPIO_VER
#define DESKTOPIO_MYPATH "vtm/calc"
#define DESKTOPIO_DEFAPP "Calc"
Expand Down
14 changes: 7 additions & 7 deletions src/netxs/apps/calc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ namespace netxs::console
else items.del(gear);
recalc();
};
engage<sysmouse::left>();
engage<hids::buttons::left>();
}
void recalc()
{
Expand Down Expand Up @@ -194,36 +194,36 @@ namespace netxs::console
boss.SIGNAL(tier::release, e2::data::text, data);
}
// pro::cell_highlight: Configuring the mouse button to operate.
template<sysmouse::bttns BUTTON>
template<hids::buttons Button>
void engage()
{
boss.SIGNAL(tier::release, e2::form::draggable::_<BUTTON>, true);
boss.SIGNAL(tier::release, e2::form::draggable::_<Button>, true);
boss.SUBMIT_T(tier::release, hids::events::mouse::move, memo, gear)
{
items.take(gear).calc(boss, gear.coord);
boss.base::deface();
};
boss.SUBMIT_T(tier::release, e2::form::drag::start::_<BUTTON>, memo, gear)
boss.SUBMIT_T(tier::release, e2::form::drag::start::_<Button>, memo, gear)
{
if (items.take(gear).grab(gear.coord, gear.meta(hids::anyCtrl)))
{
gear.dismiss();
}
};
boss.SUBMIT_T(tier::release, e2::form::drag::pull::_<BUTTON>, memo, gear)
boss.SUBMIT_T(tier::release, e2::form::drag::pull::_<Button>, memo, gear)
{
if (items.take(gear).drag(gear.coord))
{
recalc();
gear.dismiss();
}
};
boss.SUBMIT_T(tier::release, e2::form::drag::cancel::_<BUTTON>, memo, gear)
boss.SUBMIT_T(tier::release, e2::form::drag::cancel::_<Button>, memo, gear)
{
items.take(gear).drop();
recalc();
};
boss.SUBMIT_T(tier::release, e2::form::drag::stop::_<BUTTON>, memo, gear)
boss.SUBMIT_T(tier::release, e2::form::drag::stop::_<Button>, memo, gear)
{
items.take(gear).drop();
recalc();
Expand Down
4 changes: 2 additions & 2 deletions src/netxs/apps/desk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,10 @@ namespace netxs::app::desk
->plugin<pro::cache>()
->invoke([&](auto& boss)
{
boss.mouse.template draggable<sysmouse::left>(true);
boss.mouse.template draggable<hids::buttons::left>(true);
auto boss_shadow = ptr::shadow(boss.This());
auto size_config = std::make_shared<std::pair<si32, si32>>(uibar_max_size, uibar_min_size);
boss.SUBMIT_BYVAL(tier::release, e2::form::drag::pull::_<sysmouse::left>, gear)
boss.SUBMIT_BYVAL(tier::release, e2::form::drag::pull::_<hids::buttons::left>, gear)
{
if (auto boss_ptr = boss_shadow.lock())
{
Expand Down
2 changes: 1 addition & 1 deletion src/netxs/apps/term.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) NetXS Group.
// Licensed under the MIT license.

#define DESKTOPIO_VER "v0.9.6j"
#define DESKTOPIO_VER "v0.9.6k"
#define DESKTOPIO_MYNAME "Desktopio Terminal " DESKTOPIO_VER
#define DESKTOPIO_MYPATH "vtm/term"
#define DESKTOPIO_DEFAPP "Term"
Expand Down
Loading

0 comments on commit 99442c7

Please sign in to comment.