Skip to content

Commit

Permalink
Solving issue #12.
Browse files Browse the repository at this point in the history
  • Loading branch information
manutalcual committed Dec 21, 2018
1 parent f4767f9 commit 56a7f33
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 1 deletion.
Binary file modified bin/bin.zip
Binary file not shown.
Binary file modified bin/bin_logging.zip
Binary file not shown.
4 changes: 3 additions & 1 deletion src/common.hh
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ public:
bool _deserialized;
std::string _title;
std::string _class_name;
bool _erase;

win_t ()
: _hwnd{},
_deserialized{}
_deserialized{},
_erase{}
{}
~win_t ()
{
Expand Down
33 changes: 33 additions & 0 deletions src/poshandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,39 @@ namespace mcm {
}
}

bool poshandler::window_exist (HWND & hwnd)
{
return _windows.find(hwnd) != _windows.end();
}

void poshandler::remove_window (HWND & hwnd)
{
}

void poshandler::uniform_windows (poshandler & pos)
{
if (_clearing)
return;
_clearing = true;
for (auto & item : _windows) {
if (! pos.window_exist(item.second._hwnd)) {
item.second._erase = true;
}
}
mapwin_t::iterator b = _windows.begin();
mapwin_t::iterator e = _windows.end();

for ( ; b != e; ) {
if (b->second._erase) {
logp (sys::e_debug, "Deleting windows '"
<< b->second._class_name
<< "', because deleted in other config.");
_windows.erase (b++);
} else {
++b;
}
}
}
void poshandler::uniform_windows ()
{
if (_clearing)
Expand Down
3 changes: 3 additions & 0 deletions src/poshandler.hh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ namespace mcm {
void get_windows ();
void save_configuration (std::string file_name);
void load_configuration (std::string file_name);
bool window_exist (HWND & hwnd);
void remove_window (HWND & hwnd);
void uniform_windows (poshandler & pos);
void uniform_windows ();

static bool get_class_name (HWND hwnd, LPSTR buf, INT buf_size);
Expand Down
7 changes: 7 additions & 0 deletions src/window.hh
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@ namespace mcm {
config_name += "_";
config_name += sys::itoa(d.monitors());
if (_repos.find(config_name) != _repos.end()) {
poshandler & repo = _repos[config_name];
logp (sys::e_debug, "Uniforming windows: '"
<< config_name << "'.");
for (auto & r : _repos) {
if (r.first != config_name)
r.second.uniform_windows (repo);
}
logp (sys::e_debug, "Repositioning windows: '"
<< config_name << "'.");
_repos[config_name].reposition ();
Expand Down

0 comments on commit 56a7f33

Please sign in to comment.