From 7d793fc6a8d7aa07a7636df2e96054c4a8e2c6a8 Mon Sep 17 00:00:00 2001 From: rathnor Date: Sat, 11 Sep 2004 12:33:14 +0000 Subject: fix issues that resulted in unnecessary X errors --- ChangeLog | 3 +++ src/FbTk/FbPixmap.cc | 22 ++++++++++------------ src/FbTk/FbWindow.cc | 7 ++++--- src/FbTk/FbWindow.hh | 4 ++-- src/FbTk/Menu.cc | 14 +++++++++----- src/Window.cc | 4 ++-- src/fluxbox.cc | 28 ++++++++++++++++------------ 7 files changed, 46 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index 93a6395..3b508a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 0.9.11 +*04/09/11: + * Fix issues that caused unnecessary X errors (Simon) + fluxbox.cc Window.cc FbTk/Menu.cc FbTk/FbPixmap.cc FbTk/FbWindow.hh/cc *04/09/10: * Cosmetic and cleanup changes to FbTk/* (Mathias) - tabs -> spaces, wrong indention etc in all mentioned diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc index 43e74d8..66eee21 100644 --- a/src/FbTk/FbPixmap.cc +++ b/src/FbTk/FbPixmap.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbPixmap.cc,v 1.14 2004/09/10 15:46:08 akir Exp $ +// $Id: FbPixmap.cc,v 1.15 2004/09/11 12:33:14 rathnor Exp $ #include "FbPixmap.hh" #include "App.hh" @@ -305,28 +305,26 @@ Pixmap FbPixmap::getRootPixmap(int screen_num) { }; Pixmap root_pm = None; - for (prop = 0; prop_ids[prop]; prop++) { if (XGetWindowProperty(s_display, RootWindow(s_display, screen_num), XInternAtom(s_display, prop_ids[prop], False), - 0L, 4, + 0l, 4l, False, XA_PIXMAP, &real_type, &real_format, &items_read, &items_left, - (unsigned char **) &data) == Success && - real_format == 32 && items_read == 1) { + (unsigned char **) &data) == Success) { + if (real_format == 32 && items_read == 1) { - if (strcmp(prop_ids[prop], "_XSETROOT_ID") == 0) { - if (print_error) { + if (print_error && strcmp(prop_ids[prop], "_XSETROOT_ID") == 0) { fprintf(stderr, "%s", error_message); print_error = false; - } - } else - root_pm = (Pixmap) (*data); - + } else + root_pm = (Pixmap) (*data); + } XFree(data); - break; + if (root_pm != None) + break; } } diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc index ea84701..2a4aafa 100644 --- a/src/FbTk/FbWindow.cc +++ b/src/FbTk/FbWindow.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWindow.cc,v 1.39 2004/09/10 15:46:08 akir Exp $ +// $Id: FbWindow.cc,v 1.40 2004/09/11 12:33:14 rathnor Exp $ #include "FbWindow.hh" #include "FbPixmap.hh" @@ -315,10 +315,11 @@ void FbWindow::unsetCursor() { XUndefineCursor(s_display, window()); } -void FbWindow::reparent(const FbWindow &parent, int x, int y) { +void FbWindow::reparent(const FbWindow &parent, int x, int y, bool continuing) { XReparentWindow(s_display, window(), parent.window(), x, y); m_parent = &parent; - updateGeometry(); + if (continuing) // we will continue managing this window after reparent + updateGeometry(); } std::string FbWindow::textProperty(Atom property) const { diff --git a/src/FbTk/FbWindow.hh b/src/FbTk/FbWindow.hh index 36b39be..c39b8c1 100644 --- a/src/FbTk/FbWindow.hh +++ b/src/FbTk/FbWindow.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWindow.hh,v 1.33 2004/09/10 15:46:08 akir Exp $ +// $Id: FbWindow.hh,v 1.34 2004/09/11 12:33:14 rathnor Exp $ #ifndef FBTK_FBWINDOW_HH #define FBTK_FBWINDOW_HH @@ -119,7 +119,7 @@ public: void setCursor(Cursor cur); /// uses the parents cursor instead void unsetCursor(); - void reparent(const FbWindow &parent, int x, int y); + void reparent(const FbWindow &parent, int x, int y, bool continuing = true); bool property(Atom property, long long_offset, long long_length, diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index a1fdf8c..c784498 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Menu.cc,v 1.80 2004/09/09 14:29:10 akir Exp $ +// $Id: Menu.cc,v 1.81 2004/09/11 12:33:14 rathnor Exp $ //use GNU extensions #ifndef _GNU_SOURCE @@ -433,7 +433,7 @@ void Menu::update(int active_index) { } int itmp = (theme().itemHeight() * menu.persub); - menu.frame_h = itmp < 0 ? 0 : itmp; + menu.frame_h = itmp < 1 ? 1 : itmp; int new_width = (menu.sublevels * menu.item_w); int new_height = menu.frame_h; @@ -442,8 +442,12 @@ void Menu::update(int active_index) { new_height += theme().titleHeight() + ((menu.frame_h > 0)?menu.title.borderWidth():0); - if (new_width < 1) - new_width = menu.item_w; + if (new_width < 1) { + if (menu.item_w > 0) + new_width = menu.item_w; + else + new_width = 1; + } if (new_height < 1) new_height = 1; @@ -548,7 +552,7 @@ void Menu::update(int active_index) { } menu.frame.moveResize(0, ((title_vis) ? menu.title.y() + menu.title.height() + - menu.title.borderWidth()*2 : 0), + menu.title.borderWidth()*2 : 1), width(), menu.frame_h); diff --git a/src/Window.cc b/src/Window.cc index 8187c15..a110686 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Window.cc,v 1.298 2004/08/31 15:26:38 rathnor Exp $ +// $Id: Window.cc,v 1.299 2004/09/11 12:33:14 rathnor Exp $ #include "Window.hh" @@ -3232,7 +3232,7 @@ void FluxboxWindow::restore(WinClient *client, bool remap) { #endif // DEBUG // reparent to root window - client->reparent(screen().rootWindow(), frame().x(), frame().y()); + client->reparent(screen().rootWindow(), frame().x(), frame().y(), false); if (!remap) client->hide(); diff --git a/src/fluxbox.cc b/src/fluxbox.cc index f242f8c..324fb05 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.cc,v 1.252 2004/09/08 16:50:42 akir Exp $ +// $Id: fluxbox.cc,v 1.253 2004/09/11 12:33:14 rathnor Exp $ #include "fluxbox.hh" @@ -386,18 +386,20 @@ void copyFile(const std::string &from, const std::string &to) { } // end anonymous static int handleXErrors(Display *d, XErrorEvent *e) { + if (e->error_code == BadWindow) + last_bad_window = e->resourceid; #ifdef DEBUG - /* - char errtxt[128]; - - XGetErrorText(d, e->error_code, errtxt, 128); - cerr<<"Fluxbox: X Error: "<error_code<<") opcodes "<< - (int)e->request_code<<"/"<<(int)e->minor_code<<" resource 0x"<resourceid<error_code, errtxt, 128); + cerr<<"Fluxbox: X Error: "<error_code<<") opcodes "<< + (int)e->request_code<<"/"<<(int)e->minor_code<<" resource 0x"<resourceid<error_code == BadWindow) - last_bad_window = e->resourceid; return False; } @@ -501,6 +503,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile m_reconfig_timer.setTimeout(to); m_reconfig_timer.setCommand(reconfig_cmd); m_reconfig_timer.fireOnce(true); + //XSynchronize(disp, True); s_singleton = this; m_have_shape = false; @@ -633,10 +636,11 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile FbTk::ThemeManager::instance().load(FbTk::StringUtil::expandFilename(getStyleFilename())); XSynchronize(disp, False); + //XSynchronize(disp, True); sync(false); m_reconfigure_wait = m_reread_menu_wait = false; - + // Create keybindings handler and load keys file m_key.reset(new Keys(StringUtil::expandFilename(*m_rc_keyfile).c_str())); @@ -1813,7 +1817,7 @@ void Fluxbox::load_rc(BScreen &screen) { for (unsigned int i=0; i