From 29beda2d6be3eb6ccf849d7454a804fb966e7ccb Mon Sep 17 00:00:00 2001
From: fluxgen <fluxgen>
Date: Thu, 4 Dec 2003 21:31:02 +0000
Subject: sync function

---
 src/FbTk/App.cc  |  4 ++++
 src/FbTk/App.hh  |  1 +
 src/Keys.cc      |  4 ++--
 src/Screen.cc    | 15 +++++++--------
 src/WinClient.cc |  4 ++--
 src/Window.cc    | 25 +++++++++++--------------
 src/fluxbox.cc   |  6 +++---
 7 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/src/FbTk/App.cc b/src/FbTk/App.cc
index 18c6e56..309bc41 100644
--- a/src/FbTk/App.cc
+++ b/src/FbTk/App.cc
@@ -55,6 +55,10 @@ App::~App() {
     s_app = 0;
 }
 
+void App::sync(bool discard) {
+    XSync(display(), discard);
+}
+
 void App::eventLoop() {
     XEvent ev;
     while (!m_done) {
diff --git a/src/FbTk/App.hh b/src/FbTk/App.hh
index f5eb091..4bcffed 100644
--- a/src/FbTk/App.hh
+++ b/src/FbTk/App.hh
@@ -47,6 +47,7 @@ public:
     virtual ~App();
     /// display connection
     Display *display() const { return m_display; }
+    void sync(bool discard);
     /// starts event loop
     virtual void eventLoop();
     /// forces an end to event loop
diff --git a/src/Keys.cc b/src/Keys.cc
index fb677aa..d5bf786 100644
--- a/src/Keys.cc
+++ b/src/Keys.cc
@@ -19,7 +19,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-//$Id: Keys.cc,v 1.38 2003/10/05 07:19:30 rathnor Exp $
+//$Id: Keys.cc,v 1.39 2003/12/04 21:31:02 fluxgen Exp $
 
 
 #include "Keys.hh"
@@ -111,7 +111,7 @@ bool Keys::load(const char *filename) {
     //free memory of previous grabs
     deleteTree();
 
-    XSync(m_display, False);
+    FbTk::App::instance()->sync(false);
 						
     //open the file
     ifstream infile(filename);
diff --git a/src/Screen.cc b/src/Screen.cc
index 2b18447..4a4141e 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -22,7 +22,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: Screen.cc,v 1.243 2003/12/04 00:08:05 fluxgen Exp $
+// $Id: Screen.cc,v 1.244 2003/12/04 21:31:02 fluxgen Exp $
 
 
 #include "Screen.hh"
@@ -279,7 +279,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm,
                               SubstructureRedirectMask | KeyPressMask | KeyReleaseMask |
                               ButtonPressMask | ButtonReleaseMask| SubstructureNotifyMask);
 
-    XSync(disp, False);
+    FbTk::App::instance()->sync(false);
 
     XSetErrorHandler((XErrorHandler) old);
 
@@ -810,7 +810,7 @@ void BScreen::changeWorkspaceID(unsigned int id) {
         id == m_current_workspace->workspaceID())
         return;
 
-    XSync(FbTk::App::instance()->display(), true);
+    FbTk::App::instance()->sync(true);
 
     WinClient *focused_client = Fluxbox::instance()->getFocusedWindow();
     FluxboxWindow *focused = 0;
@@ -877,7 +877,7 @@ void BScreen::sendToWorkspace(unsigned int id, FluxboxWindow *win, bool changeWS
     }
 
 
-    XSync(FbTk::App::instance()->display(), True);
+    FbTk::App::instance()->sync(true);
 
     if (win && &win->screen() == this &&
         (! win->isStuck())) {
@@ -1012,7 +1012,7 @@ void BScreen::updateNetizenConfigNotify(XEvent &e) {
 }
 
 FluxboxWindow *BScreen::createWindow(Window client) {
-    XSync(FbTk::App::instance()->display(), false);
+    FbTk::App::instance()->sync(false);
 
 #ifdef SLIT
 #ifdef KDE
@@ -1121,7 +1121,7 @@ FluxboxWindow *BScreen::createWindow(Window client) {
         win->show();
     }
 
-    XSync(FbTk::App::instance()->display(), False);
+    FbTk::App::instance()->sync(false);
     return win;
 }
 
@@ -2005,9 +2005,8 @@ void BScreen::createStyleMenu(FbTk::Menu &menu,
 }
 
 void BScreen::shutdown() {
-    Display *disp = FbTk::App::instance()->display();
     rootWindow().setEventMask(NoEventMask);
-    XSync(disp, False);
+    FbTk::App::instance()->sync(false);
     m_shutdown = true;
     for_each(m_workspaces_list.begin(),
              m_workspaces_list.end(),
diff --git a/src/WinClient.cc b/src/WinClient.cc
index 0e5e2e9..8e378bf 100644
--- a/src/WinClient.cc
+++ b/src/WinClient.cc
@@ -19,7 +19,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: WinClient.cc,v 1.30 2003/10/06 06:22:43 rathnor Exp $
+// $Id: WinClient.cc,v 1.31 2003/12/04 21:31:02 fluxgen Exp $
 
 #include "WinClient.hh"
 
@@ -555,7 +555,7 @@ void WinClient::removeModal() {
 
 bool WinClient::validateClient() const {
     Display *display = FbTk::App::instance()->display();
-    XSync(display, false);
+    FbTk::App::instance()->sync(false);
 
     XEvent e;
     if (( XCheckTypedWindowEvent(display, window(), DestroyNotify, &e) ||
diff --git a/src/Window.cc b/src/Window.cc
index d6283e4..9dcbf28 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.246 2003/11/27 22:02:28 fluxgen Exp $
+// $Id: Window.cc,v 1.247 2003/12/04 21:31:02 fluxgen Exp $
 
 #include "Window.hh"
 
@@ -262,7 +262,7 @@ FluxboxWindow::FluxboxWindow(WinClient &client, BScreen &scr, FbWinFrameTheme &t
     stuck(false), m_managed(false),
     maximized(MAX_NONE),
     m_screen(scr),
-    display(0),
+    display(FbTk::App::instance()->display()),
     m_windowmenu(*scr.menuTheme(), scr.screenNumber(), scr.imageControl(),
                  *scr.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())),
     m_old_decoration(DECOR_NORMAL),
@@ -394,9 +394,6 @@ void FluxboxWindow::init() {
 
     m_last_focus_time.tv_sec = m_last_focus_time.tv_usec = 0;
 
-    // display connection
-    display = FbTk::App::instance()->display();
-
     m_blackbox_attrib.workspace = m_workspace_number = ~0;
 
     m_blackbox_attrib.flags = m_blackbox_attrib.attrib = m_blackbox_attrib.stack = 0;
@@ -558,20 +555,20 @@ void FluxboxWindow::init() {
     if (m_shaped)
         shape();
 
-    XSync(display, false);
+    FbTk::App::instance()->sync(false);
+
 }
 
 /// apply shape to this window
 void FluxboxWindow::shape() {
 #ifdef SHAPE
     if (m_shaped) {
-        Display *disp = FbTk::App::instance()->display();
-        XShapeCombineShape(disp,
+        XShapeCombineShape(display,
                            frame().window().window(), ShapeBounding,
                            0, frame().clientArea().y(), // xOff, yOff
                            m_client->window(),
                            ShapeBounding, ShapeSet);
-        XFlush(disp);
+        XFlush(display);
     }
 #endif // SHAPE
 
@@ -1971,14 +1968,13 @@ void FluxboxWindow::handleEvent(XEvent &event) {
             } else {
                 m_shaped = false;
                 // set no shape
-                Display *disp = FbTk::App::instance()->display();
-                XShapeCombineMask(disp,
+                XShapeCombineMask(display,
                                   frame().window().window(), ShapeBounding,
                                   0, 0,
                                   None, ShapeSet);
             }
 
-            XSync(FbTk::App::instance()->display(), False);
+            FbTk::App::instance()->sync(false);
             break;
         }
 #endif // SHAPE
@@ -2813,7 +2809,7 @@ void FluxboxWindow::stopMoving() {
     screen().hideGeometry();
     XUngrabPointer(display, CurrentTime);
 	
-    XSync(display, False); //make sure the redraw is made before we continue
+    FbTk::App::instance()->sync(false); //make sure the redraw is made before we continue
 }
 
 void FluxboxWindow::pauseMoving() {
@@ -2837,7 +2833,8 @@ void FluxboxWindow::resumeMoving() {
     if (m_workspace_number == screen().currentWorkspaceID()) {
         frame().show();
     }
-    XSync(display,false);
+
+    FbTk::App::instance()->sync(false);
 
     parent().drawRectangle(screen().rootTheme().opGC(),
                            m_last_move_x, m_last_move_y, 
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 6d560e6..1de7edd 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.203 2003/12/03 00:49:20 fluxgen Exp $
+// $Id: fluxbox.cc,v 1.204 2003/12/04 21:31:02 fluxgen Exp $
 
 #include "fluxbox.hh"
 
@@ -585,7 +585,7 @@ Fluxbox::Fluxbox(int argc, char **argv, const char *dpy_name, const char *rcfile
     FbTk::ThemeManager::instance().load(getStyleFilename());
 
     XSynchronize(disp, False);
-    XSync(disp, False);
+    sync(false);
 
     m_reconfigure_wait = m_reread_menu_wait = false;
 	
@@ -1516,7 +1516,7 @@ void Fluxbox::shutdown() {
     for_each(m_screen_list.begin(), m_screen_list.end(), mem_fun(&BScreen::shutdown));
 
     m_shutdown = true;
-    XSync(FbTk::App::instance()->display(), False);
+    sync(false);
 
 }
 
-- 
cgit v0.11.2