all repos — fluxbox @ f2c8868724ebcaa6afaac4a71093f77b7eeaa23f

custom fork of the fluxbox windowmanager

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

Conflicts:

	ChangeLog
Henrik Kinnunen fluxgen@fluxbox.org
commit

f2c8868724ebcaa6afaac4a71093f77b7eeaa23f

parent

bcf37890b617730cfded161b9a3d18f7c377e724

M ChangeLogChangeLog

@@ -4,6 +4,9 @@ *08/09/28:

* 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 @@ * Changed current workspace signal in Bscreen to use the new signal

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)
M data/keysdata/keys

@@ -7,20 +7,26 @@ # scroll on the desktop to change workspaces

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 @@ 160 :Exec amixer sset Master,0 toggle

# current window commands Mod1 F4 :Close +Mod1 F5 :Kill Mod1 F9 :Minimize Mod1 F10 :Maximize Mod1 F11 :Fullscreen

@@ -66,6 +73,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
M src/Ewmh.ccsrc/Ewmh.cc

@@ -76,16 +76,30 @@ * This is an array of 32bit packed CARDINAL ARGB with high byte being A, low

* 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 @@ }

// 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,28 +135,55 @@ reinterpret_cast<unsigned char**>(&raw_data))) {

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();

@@ -178,8 +222,8 @@

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++) {
M src/FbTk/EventHandler.hhsrc/FbTk/EventHandler.hh

@@ -56,7 +56,6 @@ virtual void keyReleaseEvent(XKeyEvent &) { }

virtual void leaveNotifyEvent(XCrossingEvent &) { } virtual void enterNotifyEvent(XCrossingEvent &) { } - virtual void notifyUngrabKeyboard() { } virtual void grabButtons() { } };
M src/FbTk/EventManager.ccsrc/FbTk/EventManager.cc

@@ -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 @@ case Expose:

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);
M src/FbTk/EventManager.hhsrc/FbTk/EventManager.hh

@@ -42,9 +42,8 @@ void remove(const FbWindow &win);

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);
M src/FbTk/Menu.ccsrc/FbTk/Menu.cc

@@ -219,6 +219,8 @@ menuitems.push_back(item);

} 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;

@@ -270,6 +272,9 @@ if (static_cast<unsigned int>(m_which_sub) == index)

m_which_sub = -1; 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

@@ -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());
M src/FbTk/Menu.hhsrc/FbTk/Menu.hh

@@ -109,7 +109,7 @@ /// set label string

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; }
M src/FbTk/Shape.ccsrc/FbTk/Shape.cc

@@ -56,9 +56,9 @@

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 @@ #endif // SHAPE

} void Shape::initCorners(int screen_num) { + if (!m_win->window()) + return; + if (s_corners.size() == 0) s_corners.resize(ScreenCount(App::instance()->display()));
M src/FbTk/TextBox.ccsrc/FbTk/TextBox.cc

@@ -230,31 +230,6 @@ if (FbTk::KeyUtil::instance().isolateModifierMask(event.state)) { // handle keybindings with state

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 @@ adjustPos();

} 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,48 +309,45 @@ break;

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(); }
M src/FocusControl.ccsrc/FocusControl.cc

@@ -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;
M src/Keys.ccsrc/Keys.cc

@@ -510,12 +510,6 @@

// 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;

@@ -535,6 +529,11 @@ }

} 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);
M src/Screen.ccsrc/Screen.cc

@@ -292,7 +292,7 @@ max_ignore_inc(rm, true, scrname+".maxIgnoreIncrement", altscrname+".MaxIgnoreIncrement"),

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 @@ m_bg_change_sig.emit(*this);

} 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 @@ keys->doAction(be.type, be.state, be.button, Keys::GLOBAL|Keys::ON_DESKTOP,

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 @@ mods = FbTk::KeyUtil::instance().cleanMods(ev.xbutton.state);

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 @@ // make sure we have a unique list

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 @@ // no need to send iconlist signal if we didn't

// 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 @@ FbTk::Select2nd<Configmenus::value_type>()));

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 @@ } catch (FbTk::ResourceException e) {

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 @@ _BOOLITEM(menu, Configmenu, WorkspaceWarping,

"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
M src/Screen.hhsrc/Screen.hh

@@ -237,7 +237,6 @@ void propertyNotify(Atom atom);

void keyPressEvent(XKeyEvent &ke); void keyReleaseEvent(XKeyEvent &ke); void buttonPressEvent(XButtonEvent &be); - void notifyUngrabKeyboard(); /** * Cycles focus of windows

@@ -246,6 +245,8 @@ * @param pat specific pattern to match windows with

* @param reverse the order of cycling */ 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
M src/WorkspaceMenu.ccsrc/WorkspaceMenu.cc

@@ -80,7 +80,7 @@ mb_menu->setCommand(3, jump_cmd);

insert(mb_menu, workspace + IDX_AFTER_ICONS); } - updateMenu(-1); + updateMenu(); } void WorkspaceMenu::workspaceChanged(BScreen& screen) {

@@ -89,12 +89,12 @@ for (unsigned int i = 0; i < screen.numberOfWorkspaces(); ++i) {

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) {