Merge branch 'master' of fluxbox@git.fluxbox.org:fluxbox

Conflicts:

	ChangeLog
This commit is contained in:
Henrik Kinnunen 2008-09-28 10:53:16 +02:00
commit f2c8868724
15 changed files with 187 additions and 154 deletions

View file

@ -4,6 +4,9 @@ Changes for 1.1.2
* Change focused window signal to use the new signal system (Henrik)
FbTk/Signal.hh, FocusControl.cc, FocusableList.hh/cc, Screen.hh/cc
Window.hh/cc, fluxbox.hh/cc
*08/09/25:
* Fixed issues with round corners on restart, #2110455 (Mark)
FbTk/Shape.cc
*08/09/21:
* Changed icon list signal in BScreen to use the new signal system
(Henrik)
@ -22,6 +25,9 @@ Changes for 1.1.2
system (Henrik)
FocusableList.hh/cc, Screen.hh/cc, SendToMenu.hh/cc,
WorkspaceMenu.hh/cc, WorkspaceNameTool.hh/cc, fluxbox.hh/cc
*08/09/23:
* Fix crashes when analyzing bad constructed _NET_WM_ICON data (Mathias)
(Ewmh.cc)
*08/09/18:
* Changed workspace count signal in BScreen to use the new signal
system. (Henrik)

View file

@ -7,20 +7,26 @@ OnDesktop Mouse3 :RootMenu
OnDesktop Mouse4 :PrevWorkspace
OnDesktop Mouse5 :NextWorkspace
# scroll on the toolbar to change workspaces
OnToolbar Mouse4 :PrevWorkspace
OnToolbar Mouse5 :NextWorkspace
# scroll on the toolbar to change current window
OnToolbar Mouse4 :PrevWindow {static groups} (iconhidden=no)
OnToolbar Mouse5 :NextWindow {static groups} (iconhidden=no)
# alt + left/right click to move/resize a window
OnWindow Mod1 Mouse1 :MacroCmd {Raise} {Focus} {StartMoving}
OnWindow Mod1 Mouse3 :MacroCmd {Raise} {Focus} {StartResizing NearestCorner}
# middle click a window's titlebar and drag to attach windows
OnTitlebar Mouse2 :StartTabbing
# alt + middle click to lower the window
OnWindow Mod1 Mouse2 :Lower
# control-click a window's titlebar and drag to attach windows
OnTitlebar Control Mouse1 :StartTabbing
# double click on the titlebar to shade
OnTitlebar Double Mouse1 :Shade
# middle click on the titlebar to lower
OnTitlebar Mouse2 :Lower
# right click on the titlebar for a menu of options
OnTitlebar Mouse3 :WindowMenu
@ -57,6 +63,7 @@ Mod1 F2 :Exec fbrun
# current window commands
Mod1 F4 :Close
Mod1 F5 :Kill
Mod1 F9 :Minimize
Mod1 F10 :Maximize
Mod1 F11 :Fullscreen
@ -67,6 +74,18 @@ Mod1 space :WindowMenu
# exit fluxbox
Control Mod1 Delete :Exit
# change to previous/next workspace
Control Mod1 Left :PrevWorkspace
Control Mod1 Right :NextWorkspace
# send the current window to previous/next workspace
Mod4 Left :SendToPrevWorkspace
Mod4 Right :SendToNextWorkspace
# send the current window and follow it to previous/next workspace
Control Mod4 Left :TakeToPrevWorkspace
Control Mod4 Right :TakeToNextWorkspace
# change to a specific workspace
Control F1 :Workspace 1
Control F2 :Workspace 2

View file

@ -76,16 +76,30 @@ namespace {
* byte being B. The first two cardinals are width, height. Data is in rows,
* left to right and top to bottom.
*
***
*
* NOTE: the returned data for XA_CARDINAL is long if the rfmt equals
* 32. sizeof(long) on 64bit machines is 8. to quote from
* "man XGetWindowProperty":
*
* If the returned format is 32, the property data will be stored as
* an array of longs (which in a 64-bit application will be 64-bit
* values that are padded in the upper 4 bytes).
*
* this is especially true on 64bit machines when some of the clients
* (eg: tvtime, konqueror3) have problems to feed in the right data
* into the _NET_WM_ICON property. we faced some segfaults because
* width and height were not quite right because of ignoring 64bit
* behaviour on client side.
*
* TODO: maybe move the pixmap-creation code to FbTk? */
void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) {
typedef std::pair<int, int> Size;
typedef std::map<Size, const unsigned long*> IconContainer;
// attention: the returned data for XA_CARDINAL is long if the rfmt equals
// 32. sizeof(long) on 64bit machines is 8.
unsigned long* raw_data = 0;
long nr_icon_data = 0;
unsigned long nr_icon_data = 0;
{
Atom rtype;
@ -106,7 +120,10 @@ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) {
// actually there is some data in _NET_WM_ICON
nr_icon_data = nr_bytes_left / sizeof(CARD32);
#ifdef DEBUG
std::cerr << "extractNetWmIcon: " << winclient.title() << "\n";
std::cerr << "nr_icon_data: " << nr_icon_data << "\n";
#endif
// read all the icons stored in _NET_WM_ICON
if (raw_data)
XFree(raw_data);
@ -118,30 +135,57 @@ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) {
return;
}
#ifdef DEBUG
std::cerr << "nr_read: " << nr_read << "|" << nr_bytes_left << "\n";
#endif
}
IconContainer icon_data; // stores all available data, sorted by size (width x height)
int width;
int height;
unsigned long width;
unsigned long height;
// analyze the available icons
long i;
//
// check also for invalid values coming in from "bad" applications
unsigned long i;
for (i = 0; i + 2 < nr_icon_data; i += width * height ) {
width = raw_data[i++];
if (width >= nr_icon_data) {
#ifdef DEBUG
std::cerr << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON width ("
<< width << ") for " << winclient.title() << "\n";
#endif
break;
}
height = raw_data[i++];
if (height >= nr_icon_data) {
#ifdef DEBUG
std::cerr << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON height ("
<< height << ") for " << winclient.title() << "\n";
#endif
break;
}
// strange values stored in the NETWM_ICON
if (width <= 0 || height <= 0 || i + width * height > nr_icon_data) {
std::cerr << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON dimensions for " << winclient.title() << "\n";
XFree(raw_data);
return;
if (i + width * height > nr_icon_data) {
#ifdef DEBUG
std::cerr << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON dimensions ("
<< width << "x" << height << ")for " << winclient.title() << "\n";
#endif
break;
}
icon_data[Size(width, height)] = &raw_data[i];
}
// no valid icons found at all
if (icon_data.empty()) {
XFree(raw_data);
return;
}
Display* dpy = FbTk::App::instance()->display();
int scrn = winclient.screen().screenNumber();
@ -178,8 +222,8 @@ void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) {
const unsigned long* src = icon_data.begin()->second;
unsigned int rgba;
unsigned long pixel;
int x;
int y;
unsigned long x;
unsigned long y;
unsigned char r, g, b, a;
for (y = 0; y < height; y++) {

View file

@ -56,7 +56,6 @@ public:
virtual void leaveNotifyEvent(XCrossingEvent &) { }
virtual void enterNotifyEvent(XCrossingEvent &) { }
virtual void notifyUngrabKeyboard() { }
virtual void grabButtons() { }
};

View file

@ -65,25 +65,14 @@ EventHandler *EventManager::find(Window win) {
return m_eventhandlers[win];
}
bool EventManager::grabKeyboard(EventHandler &ev, Window win) {
if (m_grabbing_keyboard)
ungrabKeyboard();
bool EventManager::grabKeyboard(Window win) {
int ret = XGrabKeyboard(App::instance()->display(), win, False,
GrabModeAsync, GrabModeAsync, CurrentTime);
if (ret == Success) {
m_grabbing_keyboard = &ev;
return true;
}
return false;
return (ret == Success);
}
void EventManager::ungrabKeyboard() {
XUngrabKeyboard(App::instance()->display(), CurrentTime);
if (m_grabbing_keyboard)
m_grabbing_keyboard->notifyUngrabKeyboard();
m_grabbing_keyboard = 0;
}
Window EventManager::getEventWindow(XEvent &ev) {
@ -190,10 +179,14 @@ void EventManager::dispatch(Window win, XEvent &ev, bool parent) {
evhand->exposeEvent(ev.xexpose);
break;
case EnterNotify:
evhand->enterNotifyEvent(ev.xcrossing);
if (ev.xcrossing.mode != NotifyGrab &&
ev.xcrossing.mode != NotifyUngrab)
evhand->enterNotifyEvent(ev.xcrossing);
break;
case LeaveNotify:
evhand->leaveNotifyEvent(ev.xcrossing);
if (ev.xcrossing.mode != NotifyGrab &&
ev.xcrossing.mode != NotifyUngrab)
evhand->leaveNotifyEvent(ev.xcrossing);
break;
default:
evhand->handleEvent(ev);

View file

@ -42,9 +42,8 @@ public:
void add(EventHandler &ev, Window win) { registerEventHandler(ev, win); }
void remove(Window win) { unregisterEventHandler(win); }
bool grabKeyboard(EventHandler &ev, Window win);
bool grabKeyboard(Window win);
void ungrabKeyboard();
EventHandler *grabbingKeyboard() { return m_grabbing_keyboard; }
EventHandler *find(Window win);

View file

@ -219,6 +219,8 @@ int Menu::insert(MenuItem *item, int pos) {
} else {
menuitems.insert(menuitems.begin() + pos, item);
fixMenuItemIndices();
if (m_active_index >= pos)
m_active_index++;
}
m_need_update = true; // we need to redraw the menu
return menuitems.size();
@ -233,7 +235,7 @@ int Menu::remove(unsigned int index) {
if (index >= menuitems.size()) {
#ifdef DEBUG
cout << "Bad index (" << index << ") given to Menu::remove()"
<< " -- should be between 0 and " << menuitems.size()
<< " -- should be between 0 and " << menuitems.size()-1
<< " inclusive." << endl;
#endif // DEBUG
return -1;
@ -271,6 +273,9 @@ int Menu::remove(unsigned int index) {
else if (static_cast<unsigned int>(m_which_sub) > index)
m_which_sub--;
if (static_cast<unsigned int>(m_active_index) > index)
m_active_index--;
m_need_update = true; // we need to redraw the menu
return menuitems.size();
@ -366,7 +371,7 @@ void Menu::enableTitle() {
setTitleVisibility(true);
}
void Menu::updateMenu(int active_index) {
void Menu::updateMenu() {
if (m_title_vis) {
menu.item_w = theme()->titleFont().textWidth(menu.label,
menu.label.size());

View file

@ -109,7 +109,7 @@ public:
void setLabel(const FbString &labelstr);
/// move menu to x,y
virtual void move(int x, int y);
virtual void updateMenu(int active_index = -1);
virtual void updateMenu();
void setItemSelected(unsigned int index, bool val);
void setItemEnabled(unsigned int index, bool val);
void setMinimumSublevels(int m) { menu.minsub = m; }

View file

@ -56,9 +56,9 @@ Pixmap makePixmap(FbWindow &drawable, const unsigned char rows[]) {
Display *disp = App::instance()->display();
const size_t data_size = 8 * 8;
// we use calloc here so we get consistent C alloc/free with XDestroyImage
// we use malloc here so we get consistent C alloc/free with XDestroyImage
// and no warnings in valgrind :)
char *data = (char *)calloc(data_size, sizeof (char));
char *data = (char *)malloc(data_size * sizeof (char));
if (data == 0)
return 0;
@ -141,6 +141,9 @@ Shape::~Shape() {
}
void Shape::initCorners(int screen_num) {
if (!m_win->window())
return;
if (s_corners.size() == 0)
s_corners.resize(ScreenCount(App::instance()->display()));

View file

@ -230,31 +230,6 @@ void TextBox::keyPressEvent(XKeyEvent &event) {
if ((event.state & ControlMask) == ControlMask) {
switch (ks) {
case XK_b:
cursorBackward();
break;
case XK_f:
cursorForward();
break;
case XK_a:
cursorHome();
break;
case XK_e:
cursorEnd();
break;
case XK_d:
deleteForward();
break;
case XK_k:
killToEnd();
break;
case XK_c:
cursorHome();
m_text = "";
m_start_pos = 0;
m_cursor_pos = 0;
m_end_pos = 0;
break;
case XK_Left: {
unsigned int pos = findEmptySpaceLeft();
if (pos < m_start_pos){
@ -311,13 +286,6 @@ void TextBox::keyPressEvent(XKeyEvent &event) {
}
break;
}
} else if ((event.state & ShiftMask)== ShiftMask ||
(event.state & 0x80) == 0x80) { // shif and altgr
if (isprint(keychar[0])) {
std::string val;
val += keychar[0];
insertText(val);
}
}
} else { // no state
@ -341,49 +309,46 @@ void TextBox::keyPressEvent(XKeyEvent &event) {
case XK_Delete:
deleteForward();
break;
default:
switch (ks) {
case XK_KP_Insert:
keychar[0] = '0';
break;
case XK_KP_End:
keychar[0] = '1';
break;
case XK_KP_Down:
keychar[0] = '2';
break;
case XK_KP_Page_Down:
keychar[0] = '3';
break;
case XK_KP_Left:
keychar[0] = '4';
break;
case XK_KP_Begin:
keychar[0] = '5';
break;
case XK_KP_Right:
keychar[0] = '6';
break;
case XK_KP_Home:
keychar[0] = '7';
break;
case XK_KP_Up:
keychar[0] = '8';
break;
case XK_KP_Page_Up:
keychar[0] = '9';
break;
case XK_KP_Delete:
keychar[0] = ',';
break;
};
if (isprint(keychar[0])) {
std::string val;
val += keychar[0];
insertText(val);
}
case XK_KP_Insert:
keychar[0] = '0';
break;
case XK_KP_End:
keychar[0] = '1';
break;
case XK_KP_Down:
keychar[0] = '2';
break;
case XK_KP_Page_Down:
keychar[0] = '3';
break;
case XK_KP_Left:
keychar[0] = '4';
break;
case XK_KP_Begin:
keychar[0] = '5';
break;
case XK_KP_Right:
keychar[0] = '6';
break;
case XK_KP_Home:
keychar[0] = '7';
break;
case XK_KP_Up:
keychar[0] = '8';
break;
case XK_KP_Page_Up:
keychar[0] = '9';
break;
case XK_KP_Delete:
keychar[0] = ',';
break;
}
}
if (isprint(keychar[0])) {
std::string val;
val += keychar[0];
insertText(val);
}
clear();
}

View file

@ -91,7 +91,7 @@ void FocusControl::cycleFocus(const FocusableList &window_list,
const ClientPattern *pat, bool cycle_reverse) {
if (!m_cycling_list) {
if (&m_screen == FbTk::EventManager::instance()->grabbingKeyboard())
if (m_screen.isCycling())
// only set this when we're waiting for modifiers
m_cycling_list = &window_list;
m_was_iconic = 0;

View file

@ -510,12 +510,6 @@ bool Keys::doAction(int type, unsigned int mods, unsigned int key,
// grab "None Escape" to exit keychain in the middle
unsigned int esc = FbTk::KeyUtil::getKey("Escape");
// if focus changes, windows will get NotifyWhileGrabbed,
// which they tend to ignore
if (temp_key && type == KeyPress &&
!FbTk::EventManager::instance()->grabbingKeyboard())
XUngrabKeyboard(Fluxbox::instance()->display(), CurrentTime);
if (temp_key && !temp_key->keylist.empty()) { // emacs-style
if (!saved_keymode)
saved_keymode = m_keylist;
@ -536,6 +530,11 @@ bool Keys::doAction(int type, unsigned int mods, unsigned int key,
return false;
}
// if focus changes, windows will get NotifyWhileGrabbed,
// which they tend to ignore
if (type == KeyPress)
XUngrabKeyboard(Fluxbox::instance()->display(), CurrentTime);
WinClient *old = WindowCmd<void>::client();
WindowCmd<void>::setClient(current);
temp_key->m_command->execute();

View file

@ -292,7 +292,7 @@ BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager &rm,
max_disable_move(rm, false, scrname+".maxDisableMove", altscrname+".MaxDisableMove"),
max_disable_resize(rm, false, scrname+".maxDisableResize", altscrname+".MaxDisableResize"),
workspace_warping(rm, true, scrname+".workspacewarping", altscrname+".WorkspaceWarping"),
show_window_pos(rm, true, scrname+".showwindowposition", altscrname+".ShowWindowPosition"),
show_window_pos(rm, false, scrname+".showwindowposition", altscrname+".ShowWindowPosition"),
auto_raise(rm, true, scrname+".autoRaise", altscrname+".AutoRaise"),
click_raises(rm, true, scrname+".clickRaises", altscrname+".ClickRaises"),
default_deco(rm, "NORMAL", scrname+".defaultDeco", altscrname+".DefaultDeco"),
@ -855,19 +855,26 @@ void BScreen::propertyNotify(Atom atom) {
}
void BScreen::keyPressEvent(XKeyEvent &ke) {
Fluxbox::instance()->keys()->doAction(ke.type, ke.state, ke.keycode,
Keys::GLOBAL|Keys::ON_DESKTOP);
if (Fluxbox::instance()->keys()->doAction(ke.type, ke.state, ke.keycode,
Keys::GLOBAL|Keys::ON_DESKTOP))
// re-grab keyboard, so we don't pass KeyRelease to clients
FbTk::EventManager::instance()->grabKeyboard(rootWindow().window());
}
void BScreen::keyReleaseEvent(XKeyEvent &ke) {
if (!m_cycling)
return;
if (m_cycling) {
unsigned int state = FbTk::KeyUtil::instance().cleanMods(ke.state);
state &= ~FbTk::KeyUtil::instance().keycodeToModmask(ke.keycode);
unsigned int state = FbTk::KeyUtil::instance().cleanMods(ke.state);
state &= ~FbTk::KeyUtil::instance().keycodeToModmask(ke.keycode);
if (state) // still cycling
return;
if (!state) // all modifiers were released
FbTk::EventManager::instance()->ungrabKeyboard();
m_cycling = false;
focusControl().stopCyclingFocus();
}
FbTk::EventManager::instance()->ungrabKeyboard();
}
void BScreen::buttonPressEvent(XButtonEvent &be) {
@ -879,11 +886,6 @@ void BScreen::buttonPressEvent(XButtonEvent &be) {
0, be.time);
}
void BScreen::notifyUngrabKeyboard() {
m_cycling = false;
focusControl().stopCyclingFocus();
}
void BScreen::cycleFocus(int options, const ClientPattern *pat, bool reverse) {
// get modifiers from event that causes this for focus order cycling
XEvent ev = Fluxbox::instance()->lastEvent();
@ -895,7 +897,7 @@ void BScreen::cycleFocus(int options, const ClientPattern *pat, bool reverse) {
if (!m_cycling && mods) {
m_cycling = true;
FbTk::EventManager::instance()->grabKeyboard(*this, rootWindow().window());
FbTk::EventManager::instance()->grabKeyboard(rootWindow().window());
}
if (mods == 0) // can't stacked cycle unless there is a mod to grab
@ -1029,10 +1031,10 @@ void BScreen::addIcon(FluxboxWindow *w) {
if (find(iconList().begin(), iconList().end(), w) != iconList().end())
return;
m_icon_list.push_back(w);
iconList().push_back(w);
// notify listeners
m_iconlist_sig.emit(*this);
iconListSig().emit(*this);
}
@ -1047,7 +1049,7 @@ void BScreen::removeIcon(FluxboxWindow *w) {
// change the iconlist
if (erase_it != m_icon_list.end()) {
iconList().erase(erase_it);
m_iconlist_sig.emit(*this);
iconListSig().emit(*this);
}
}
@ -1556,7 +1558,8 @@ void BScreen::removeConfigMenu(FbTk::Menu &menu) {
if (erase_it != m_configmenu_list.end())
m_configmenu_list.erase(erase_it);
setupConfigmenu(*m_configmenu.get());
if (!isShuttingdown())
setupConfigmenu(*m_configmenu.get());
}
@ -1627,12 +1630,12 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
cerr<<e.what()<<endl;
}
focus_menu->insert(new FbTk::BoolMenuItem(_FB_XTEXT(Configmenu,
AutoRaise,
"Auto Raise",
"Auto Raise windows on sloppy"),
resource.auto_raise,
save_and_reconfigure));
_BOOLITEM(*focus_menu, Configmenu, AutoRaise,
"Auto Raise", "Auto Raise windows on sloppy",
resource.auto_raise, saverc_cmd);
_BOOLITEM(*focus_menu, Configmenu, ClickRaises,
"Click Raises", "Click Raises",
resource.click_raises, saverc_cmd);
focus_menu->updateMenu();
@ -1799,9 +1802,6 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
"Workspace Warping",
"Workspace Warping - dragging windows to the edge and onto the next workspace",
resource.workspace_warping, saverc_cmd);
_BOOLITEM(menu, Configmenu, ClickRaises,
"Click Raises", "Click Raises",
resource.click_raises, saverc_cmd);
#undef _BOOLITEM

View file

@ -237,7 +237,6 @@ public:
void keyPressEvent(XKeyEvent &ke);
void keyReleaseEvent(XKeyEvent &ke);
void buttonPressEvent(XButtonEvent &be);
void notifyUngrabKeyboard();
/**
* Cycles focus of windows
@ -247,6 +246,8 @@ public:
*/
void cycleFocus(int opts = 0, const ClientPattern *pat = 0, bool reverse = false);
bool isCycling() const { return m_cycling; }
/**
* Creates an empty menu with specified label
* @param label for the menu

View file

@ -80,7 +80,7 @@ void WorkspaceMenu::workspaceInfoChanged( BScreen& screen ) {
insert(mb_menu, workspace + IDX_AFTER_ICONS);
}
updateMenu(-1);
updateMenu();
}
void WorkspaceMenu::workspaceChanged(BScreen& screen) {
@ -89,12 +89,12 @@ void WorkspaceMenu::workspaceChanged(BScreen& screen) {
item = find(i + IDX_AFTER_ICONS);
if (item && item->isSelected()) {
setItemSelected(i + IDX_AFTER_ICONS, false);
updateMenu(i + IDX_AFTER_ICONS);
updateMenu();
break;
}
}
setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true);
updateMenu(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS);
updateMenu();
}
void WorkspaceMenu::init(BScreen &screen) {