Skip to content

Commit

Permalink
Prevent clicking on HUD widgets from acting on the map
Browse files Browse the repository at this point in the history
Clicking on a widget displayed on top of the map was sometimes triggering
actions as if the map had been clicked underneath. Prevent this by disabling
the propagation of mouse events to the parent widget.

Closes longturn#687.
  • Loading branch information
lmoureaux authored and psampathkumar committed Nov 14, 2021
1 parent 6302220 commit 0d0b809
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions client/gui-qt/citydlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,11 @@ city_dialog::city_dialog(QWidget *parent) : QWidget(parent)
small_font = fcFont::instance()->getFont(fonts::notify_label);
ui.setupUi(this);

// Prevent mouse events from going through the panels to the main map
for (auto child : findChildren<QWidget *>()) {
child->setAttribute(Qt::WA_NoMousePropagation);
}

setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
setMouseTracking(true);
selected_row_p = -1;
Expand Down
7 changes: 7 additions & 0 deletions client/gui-qt/page_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,27 @@ pageGame::pageGame(QWidget *parent)
sidebar_wdg->addWidget(sw_endturn);

civ_status = new civstatus(mapview_wdg);
civ_status->setAttribute(Qt::WA_NoMousePropagation);
civ_status->show();

city_overlay = new city_dialog(mapview_wdg);
city_overlay->hide();
minimapview_wdg = new minimap_view(mapview_wdg);
minimapview_wdg->setAttribute(Qt::WA_NoMousePropagation);
minimapview_wdg->show();
unitinfo_wdg = new hud_units(mapview_wdg);
unitinfo_wdg->setAttribute(Qt::WA_NoMousePropagation);
battlelog_wdg = new hud_battle_log(mapview_wdg);
battlelog_wdg->setAttribute(Qt::WA_NoMousePropagation);
battlelog_wdg->hide();
infotab = new info_tab(mapview_wdg);
infotab->setAttribute(Qt::WA_NoMousePropagation);
infotab->show();
x_vote = new xvote(mapview_wdg);
x_vote->setAttribute(Qt::WA_NoMousePropagation);
x_vote->hide();
gtd = new goto_dialog(mapview_wdg);
gtd->setAttribute(Qt::WA_NoMousePropagation);
gtd->hide();

game_layout->addWidget(mapview_wdg, 1, 0);
Expand Down

0 comments on commit 0d0b809

Please sign in to comment.