Fix for #1240248, Segfaults for :MoveTabLeft/Right
wrong code in Container.cc
This commit is contained in:
parent
460dffdcc1
commit
7b21abc421
4 changed files with 32 additions and 35 deletions
|
@ -1,5 +1,8 @@
|
||||||
(Format: Year/Month/Day)
|
(Format: Year/Month/Day)
|
||||||
Changes for 0.9.14:
|
Changes for 0.9.14:
|
||||||
|
*05/07/25:
|
||||||
|
Fix for #1240248, Segfaults for :MoveTabLeft/Right (Mathias)
|
||||||
|
Container.cc FbWinFrame.cc Window.cc
|
||||||
*05/07/20:
|
*05/07/20:
|
||||||
Changed some *Focus options (Mathias)
|
Changed some *Focus options (Mathias)
|
||||||
removed SloppyFocus, SemiSloppyFocus and ClickToFocus options
|
removed SloppyFocus, SemiSloppyFocus and ClickToFocus options
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include "FbTk/EventManager.hh"
|
#include "FbTk/EventManager.hh"
|
||||||
#include "CompareWindow.hh"
|
#include "CompareWindow.hh"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
Container::Container(const FbTk::FbWindow &parent):
|
Container::Container(const FbTk::FbWindow &parent):
|
||||||
FbTk::FbWindow(parent, 0, 0, 1, 1, ExposureMask),
|
FbTk::FbWindow(parent, 0, 0, 1, 1, ExposureMask),
|
||||||
m_align(RELATIVE),
|
m_align(RELATIVE),
|
||||||
|
@ -113,35 +115,31 @@ void Container::insertItem(Item item, int pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Container::moveItem(Item item, int movement) {
|
void Container::moveItem(Item item, int movement) {
|
||||||
int index = find(item);
|
|
||||||
if (index < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
int size = m_item_list.size();
|
int index = find(item);
|
||||||
|
const int size = m_item_list.size();
|
||||||
|
|
||||||
|
if (index < 0 || (movement % size) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int newindex = (index + movement) % size;
|
int newindex = (index + movement) % size;
|
||||||
if (newindex < 0) // neg wrap
|
if (newindex < 0) // neg wrap
|
||||||
newindex += size;
|
newindex += size;
|
||||||
|
|
||||||
if (newindex > index) // one smaller now
|
ItemList::iterator it = std::find(m_item_list.begin(),
|
||||||
--newindex;
|
m_item_list.end(),
|
||||||
|
item);
|
||||||
ItemList::iterator it = m_item_list.begin();
|
m_item_list.erase(it);
|
||||||
for (; newindex > 0 && index > 0; ++it, --newindex, --index) {
|
|
||||||
|
for (it = m_item_list.begin(); newindex >= 0; ++it, --newindex) {
|
||||||
if (newindex == 0) {
|
if (newindex == 0) {
|
||||||
m_item_list.insert(it, item);
|
break;
|
||||||
++newindex;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (index == 0) {
|
|
||||||
m_item_list.erase(it);
|
|
||||||
--index;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_item_list.insert(it, item);
|
m_item_list.insert(it, item);
|
||||||
insertItem(item, newindex);
|
|
||||||
repositionItems();
|
repositionItems();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns true if something was done
|
// returns true if something was done
|
||||||
|
|
|
@ -372,7 +372,7 @@ void FbWinFrame::moveLabelButtonLeft(FbTk::TextButton &btn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FbWinFrame::moveLabelButtonRight(FbTk::TextButton &btn) {
|
void FbWinFrame::moveLabelButtonRight(FbTk::TextButton &btn) {
|
||||||
m_tab_container.moveItem(&btn, -1);
|
m_tab_container.moveItem(&btn, +1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FbWinFrame::moveLabelButtonTo(FbTk::TextButton &btn, int x, int y) {
|
void FbWinFrame::moveLabelButtonTo(FbTk::TextButton &btn, int x, int y) {
|
||||||
|
@ -394,7 +394,7 @@ void FbWinFrame::moveLabelButtonRightOf(FbTk::TextButton &btn, const FbTk::TextB
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_tab_container.moveItem(&btn, pos-1);
|
m_tab_container.moveItem(&btn, pos+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn) {
|
void FbWinFrame::setLabelButtonFocus(FbTk::TextButton &btn) {
|
||||||
|
|
|
@ -864,14 +864,12 @@ void FluxboxWindow::moveClientLeft() {
|
||||||
if (m_clientlist.size() == 1 ||
|
if (m_clientlist.size() == 1 ||
|
||||||
*m_clientlist.begin() == &winClient())
|
*m_clientlist.begin() == &winClient())
|
||||||
return;
|
return;
|
||||||
// move label button to the left
|
|
||||||
frame().moveLabelButtonLeft(*m_labelbuttons[&winClient()]);
|
|
||||||
// move client in clientlist to the left
|
// move client in clientlist to the left
|
||||||
ClientList::iterator it = find(m_clientlist.begin(), m_clientlist.end(), &winClient());
|
ClientList::iterator oldpos = find(m_clientlist.begin(), m_clientlist.end(), &winClient());
|
||||||
ClientList::iterator new_pos = it;
|
ClientList::iterator newpos = oldpos; newpos--;
|
||||||
new_pos--;
|
std::swap(*newpos, *oldpos);
|
||||||
m_clientlist.erase(it);
|
frame().moveLabelButtonLeft(*m_labelbuttons[&winClient()]);
|
||||||
m_clientlist.insert(new_pos, &winClient());
|
|
||||||
|
|
||||||
updateClientLeftWindow();
|
updateClientLeftWindow();
|
||||||
|
|
||||||
|
@ -879,15 +877,13 @@ void FluxboxWindow::moveClientLeft() {
|
||||||
|
|
||||||
void FluxboxWindow::moveClientRight() {
|
void FluxboxWindow::moveClientRight() {
|
||||||
if (m_clientlist.size() == 1 ||
|
if (m_clientlist.size() == 1 ||
|
||||||
*m_clientlist.rbegin() == &winClient())
|
*m_clientlist.rbegin() == &winClient())
|
||||||
return;
|
return;
|
||||||
// move label button to the right
|
|
||||||
|
ClientList::iterator oldpos = find(m_clientlist.begin(), m_clientlist.end(), &winClient());
|
||||||
|
ClientList::iterator newpos = oldpos; newpos++;
|
||||||
|
std::swap(*newpos, *oldpos);
|
||||||
frame().moveLabelButtonRight(*m_labelbuttons[&winClient()]);
|
frame().moveLabelButtonRight(*m_labelbuttons[&winClient()]);
|
||||||
// move client in clientlist to the right
|
|
||||||
ClientList::iterator it = find(m_clientlist.begin(), m_clientlist.end(), &winClient());
|
|
||||||
ClientList::iterator new_pos = m_clientlist.erase(it);
|
|
||||||
new_pos++;
|
|
||||||
m_clientlist.insert(new_pos, &winClient());
|
|
||||||
|
|
||||||
updateClientLeftWindow();
|
updateClientLeftWindow();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue