Micah Nordland avatar Micah Nordland committed 1de1237

vimWM is now more or less functional, Command and Interact modes work,
there still seems to be a bug in the tree, I'm thinking to remove
BSP layout and put a dwm style layout in its place.

Comments (0)

Files changed (20)

 program_C_OBJS := ${program_C_SRCS:.c=.o}
 program_CXX_OBJS := ${program_CXX_SRCS:.cpp=.o}
 program_OBJS := $(program_C_OBJS) $(program_CXX_OBJS)
-program_INCLUDE_DIRS := include
+program_INCLUDE_DIRS := include 
 program_LIBRARY_DIRS :=
 program_LIBRARIES := xcb xcb-util xcb-icccm xcb-ewmh xcb-keysyms
-
-CPPFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir)) -std=c++11 -g
-LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
+CPPFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))  $(shell pkg-config --cflags cairomm-1.0) -std=c++11 -g
+LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir)) $(shell pkg-config --libs cairomm-1.0)
 LDFLAGS += $(foreach library,$(program_LIBRARIES),-l$(library))
 
 .PHONY: all clean distclean

include/boxTree.h

         Box *nextLeaf(Box *box);
         Box *prevLeaf(Box *box);
         void setFocused(Box *box);
+        void killFocused();
         Box *getRoot();
         Box *findWindowBox(xcb_window_t winId);
         void layoutBoxes(Box *box, xcb_rectangle_t area);

include/cairomm/README

+I found these on the internet, they are not mine.
+They make it possible to use cairomm with XCB, which is not supported
+upstream. Here is where I got them: https://gitorious.org/realtimeplot
+xcb_surface.cpp in the src directory is also from there.

include/cairomm/private.h

+/* Copyright (C) 2005 The cairomm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef __CAIROMM_PRIVATE_H
+#define __CAIROMM_PRIVATE_H
+
+#include <cairomm/enums.h>
+#include <cairomm/exception.h>
+#include <string>
+
+#ifndef DOXYGEN_IGNORE_THIS
+namespace Cairo
+{
+
+/// Throws the appropriate exception, if exceptions are enabled.
+void throw_exception(ErrorStatus status);
+
+//We inline this because it is called so often.
+inline void check_status_and_throw_exception(ErrorStatus status)
+{
+  if(status != CAIRO_STATUS_SUCCESS)
+    throw_exception(status); //This part doesn't need to be inline because it would rarely be called.
+}
+
+template<class T>
+void check_object_status_and_throw_exception(const T& object)
+{
+  //get_status() is normally an inlined member method.
+  check_status_and_throw_exception(object.get_status());
+}
+
+} // namespace Cairo
+#endif //DOXYGEN_IGNORE_THIS
+
+#endif //__CAIROMM_PRIVATE_H
+
+// vim: ts=2 sw=2 et

include/cairomm/xcb_surface.h

+/* Copyright (C) 2005 The cairomm Development Team and 
+ * 2011 Edwin van Leeuwen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef XCB_SURFACE_H
+#define XCB_SURFACE_H
+
+#include <cairomm/surface.h>
+
+// This header is not included by cairomm.h because it requires X headers that 
+// tend to pollute the namespace with non-prefixed #defines and typedefs.
+// You may include it directly if you need to use this API.
+
+#ifdef CAIRO_HAS_XCB_SURFACE
+#include <cairo-xcb.h> 
+#endif 
+
+namespace Cairo
+{
+
+#ifdef CAIRO_HAS_XCB_SURFACE
+
+/** An XcbSurface provides a way to render to the X Window System using Xcb.
+ * If you want to draw to the screen within an application that uses the X
+ * Window system, you should use this Surface type.
+ *
+ * @note For this surface to be availabe, cairo must have been compiled with
+ * support for Xcb Surfaces
+ */
+class XcbSurface : public Surface
+{
+public:
+
+  /** Create a C++ wrapper for the C instance. This C++ instance should then be
+   * given to a RefPtr.
+  */
+  explicit XcbSurface(cairo_surface_t* cobject, bool has_reference = false);
+  virtual ~XcbSurface();
+
+  /** Creates an Xcb surface that draws to the given drawable. The way that
+   * colors are represented in the drawable is specified by the provided
+   * visual.
+   */
+  static RefPtr<XcbSurface> create(xcb_connection_t *c, xcb_drawable_t drawable, xcb_visualtype_t *visual, int width, int height);
+
+  /** Creates an Xcb surface that draws to the given bitmap. This will be
+   * drawn to as a CAIRO_FORMAT_A1 object.
+   *
+   */
+	static RefPtr<XcbSurface> create(xcb_connection_t *connection,
+				xcb_screen_t *screen,
+				xcb_pixmap_t  bitmap,
+				int     width,
+				int     height);
+
+  /** Informs cairo of the new size of the X Drawable underlying the surface.
+   * For a surface created for a Window (rather than a Pixmap), this function
+   * must be called each time the size of the window changes. (For a subwindow,
+   * you are normally resizing the window yourself, but for a toplevel window,
+   * it is necessary to listen for ConfigureNotify events.)
+   *
+   * A Pixmap can never change size, so it is never necessary to call this
+   * function on a surface created for a Pixmap.
+   *
+   * @param width	the new width of the surface
+   * @param height	the new height of the surface
+   */
+	void set_size(int width, int height);
+
+  /** Informs cairo of a new X Drawable underlying the surface. The drawable
+   * must match the display, screen and format of the existing drawable or the
+   * application will get X protocol errors and will probably terminate. No
+   * checks are done by this function to ensure this compatibility.
+   *
+   * @param drawable	the new drawable for the surface
+   * @param width	the width of the new drawable
+   * @param height	the height of the new drawable
+   */
+//  void set_drawable(Drawable drawable, int width, int height);
+
+  /** gets the Drawable object associated with this surface */
+//  Drawable get_drawable() const;
+
+  /** Get the X Display for the underlying X Drawable. */
+//  const Display* get_display() const;
+  /** Get the X Display for the underlying X Drawable. */
+//  Display* get_display();
+
+  /** Get the X Screen for the underlying X Drawable */
+//  Screen* get_screen();
+  /** Get the X Screen for the underlying X Drawable */
+//  const Screen* get_screen() const;
+
+  /** Get the X Visual for the underlying X Drawable */
+//  Visual* get_visual();
+  /** Get the X Visual for the underlying X Drawable */
+//  const Visual* get_visual() const;
+
+  /** Get the number of bits used to represent each pixel value. */
+//  int get_depth() const;
+
+  /** Get the height in pixels of the X Drawable underlying the surface */
+//  int get_height() const;
+
+  /** Get the width in pixels of the X Drawable underlying the surface */
+//  int get_width() const;
+
+};
+
+#endif // CAIRO_HAS_XCB_SURFACE
+
+} // namespace Cairo
+
+#endif //__CAIROMM_XLIB_SURFACE_H
+
+// vim: ts=2 sw=2 et

include/eventHandlers.h

         void handleDestroyNotify(EventPtr event);
         void handleUnmapNotify(EventPtr event);
         void handleEnterNotify(EventPtr event);
-        void handleKeyRelease(EventPtr event);
+        void handleError(EventPtr event);
 
     private:
         Setup *setup;

include/keyHandlers.h

 		void handleKeyPress(EventPtr event);
         void handleKeyRelease(EventPtr event);
         void grabKey(uint32_t mods, xcb_keysym_t, KeyEventType type, KeyCallback callback);
+        void ungrabKey(uint32_t mods, xcb_keysym_t, KeyEventType type);
         uint32_t getMod(xcb_keysym_t keysym);
-
+        
     private:
         void getLocks();
+        void addCallback(uint32_t mods, xcb_keysym_t keysym, KeyEventType type, KeyCallback);
         bool grab(uint32_t mods, xcb_keysym_t key);
 		void ungrab(xcb_keysym_t key);
 		void grabAll();
 #include <xcb/xcb.h>
 #include <xcb/xcb_ewmh.h>
 
+#include "ewmh.h"
+
+class StatusBar;
 class Monitor;
 struct OtherWindowManager: std::exception {
       const char* what() const noexcept {return "couldn't grab substructure notify on the root window\n";}
 
 };
+
+
+
 class Setup
 {
     public:
         xcb_connection_t* conn;
         xcb_ewmh_connection_t* ewmh;
         xcb_window_t root;
+        xcb_screen_t *screen;
         std::vector<Monitor> monitors;
+        int statusBarHeight;
+        StatusBar *statusBar;
 };
 
 #endif //SETUP_H

include/statusBar.h

+#ifndef STATUS_BAR_H
+#define STATUS_BAR_H
+#include <iostream>
+
+#include <xcb/xcb.h>
+#include <cairommconfig.h>
+#include <cairomm/context.h>
+#include <cairomm/surface.h>
+
+#include "window.h"
+#include "event.h"
+
+#include "cairomm/xcb_surface.h"
+
+typedef Cairo::RefPtr<Cairo::Context> CairoContext;
+typedef Cairo::RefPtr<Cairo::XcbSurface> CairoXcbSurface;
+
+class Setup;
+
+
+class StatusBar
+{
+    public:
+        StatusBar(Setup *setup);
+        ~StatusBar();
+        void setText(std::string newText);
+        void draw();
+        void handleExposeEvent(EventPtr event);
+
+    private:
+        Setup *setup;
+        Window *window;
+        xcb_pixmap_t pixmap;
+        CairoContext context;
+        CairoXcbSurface surface;
+        std::string text;
+        
+
+        
+
+};
+
+
+#endif //STATUS_BAR_H
         void close();
         void kill();
         void stackAbove();
+        void map();
+        void unmap();
         xcb_rectangle_t getGeometry();
         void setGeometry(xcb_rectangle_t rect);
 
+See include/cairomm/README for xcb_surface.cpp, it's not mine.
+
+I have mentioned in the two files where I borrowed from other people, and where their code can be found.
+The two files are boxTree.cpp and keyHandlers.cpp
     if (box and box->window)
     {   
         if (box == focused)
+        {
+            box->window->focus();
             return;
+        }
         std::cout << "box is not already focused" << std::endl;
         focusedLast = focused; 
         focused = box;
     
 }
 
-
+void BoxTree::killFocused()
+{
+    if (not focused or not focused->window)
+        return;
+    focused->window->kill();
+}
 {
     uint8_t responseType = event->response_type & ~0x80;
     std::string eventLabel = xcb_event_get_label(responseType);
-    std::cout << eventLabel << std::endl;
-    auto iter = callbackMap.find(eventLabel);
+        auto iter = callbackMap.find(eventLabel);
     if (iter != callbackMap.end())
     {
         auto handler = iter->second;
         handler(event);
     }
+    else
+        std::cout << eventLabel << std::endl;
+
 }
 
 void EventDispatcher::stop()

src/eventHandlers.cpp

 #include "eventHandlers.h"
 #include "monitor.h"
+#include "statusBar.h"
 
 EventHandler::EventHandler(Setup *setup):
     setup(setup),
 {
     auto ev = convertEvent<xcb_enter_notify_event_t>(event);
     BoxTree &tree = setup->monitors[0].tagList[0].boxTree;
+    tree.printTree(tree.getRoot());
     Box *winBox = tree.findWindowBox(ev->event);
-    if(winBox)
+    if(winBox) 
         tree.setFocused(winBox);
 }
 
-void EventHandler::handleKeyRelease(EventPtr event)
+void EventHandler::handleError(EventPtr event)
 {
-    
+    auto ev = convertEvent<xcb_generic_error_t>(event);
+    std::cout << "Got an error: " << xcb_event_get_error_label(ev->error_code) << std::endl;
 }

src/keyHandlers.cpp

 	auto ev = convertEvent<xcb_key_press_event_t>(event);
 	uint32_t mods = ev->state & ~(numLock|capsLock|shiftLock|scrollLock);
 	mods &= 0xFF;
+    //std::cout << ev->detail << std::endl;
 	auto key = std::make_pair(mods, xcb_key_symbols_get_keysym(symbols, ev->detail, 0));
 	auto iter = pressCallbackMap.find(key);
 	if (iter != pressCallbackMap.end())
 	auto ev = convertEvent<xcb_key_release_event_t>(event);
 	uint32_t mods = ev->state & ~(numLock|capsLock|shiftLock|scrollLock);
 	mods &= 0xFF;
+    std::cout << int(ev->detail) << std::endl; 
 	auto key = std::make_pair(mods, xcb_key_symbols_get_keysym(symbols, ev->detail, 0));
 	auto iter = releaseCallbackMap.find(key);
 	if (iter != releaseCallbackMap.end())
 	}	
 }
 
+void KeyHandler::addCallback(uint32_t mods, xcb_keysym_t keysym, KeyEventType type, KeyCallback callback)
+{
+	auto key = std::make_pair(mods, keysym);
+	if (type == Press)
+	{
+		auto iter = pressCallbackMap.find(key);
+		if (iter == pressCallbackMap.end())
+			pressCallbackMap[key] = callback;
+	}
+
+	else
+	{
+		auto iter = releaseCallbackMap.find(key);
+		if (iter == releaseCallbackMap.end())
+			releaseCallbackMap[key] = callback;
+
+	}
+
+}
+
 void KeyHandler::grabKey(uint32_t mods, xcb_keysym_t keysym, KeyEventType type, KeyCallback callback)
 {
 	if (grab(mods, keysym))
 	{
-		auto key = std::make_pair(mods, keysym);
-		if (type == Press)
-		{
-			auto iter = pressCallbackMap.find(key);
-			if (iter == pressCallbackMap.end())
-				pressCallbackMap[key] = callback;
-		}
+      addCallback(mods, keysym, type, callback);
+	}
+}
 
-		else
-		{
-			auto iter = releaseCallbackMap.find(key);
-			if (iter == releaseCallbackMap.end())
-				releaseCallbackMap[key] = callback;
-
-		}
-
-	}
+void KeyHandler::ungrabKey(uint32_t mods, xcb_keysym_t keysym, KeyEventType type)
+{
+    ungrab(keysym);
+    auto key = std::make_pair(mods, keysym);
+    if (type == Press)
+        {
+        auto iter = pressCallbackMap.find(key);
+        if (iter != pressCallbackMap.end())
+            pressCallbackMap.erase(key);
+        }
+    else
+    {
+        auto iter = releaseCallbackMap.find(key);
+        if ( iter != releaseCallbackMap.end() )
+            releaseCallbackMap.erase(key);
+    }
 }
 
 void KeyHandler::grabAll()
 {
 	for (auto &key : pressCallbackMap)
 	{
-		ungrab(key.first.first);
+		ungrab(key.first.second);
 	}
 	for (auto &key : releaseCallbackMap)
 	{
-		ungrab(key.first.first);
+		ungrab(key.first.second);
 	}
 
 }
 
 #include "event.h"
 #include "setup.h"
+#include "monitor.h"
 #include "eventHandlers.h"
 #include "keyHandlers.h"
+#include "statusBar.h"
 
 
 int main()
     try
     {
         Setup setup;
+        StatusBar statusBar(&setup);
+        setup.statusBar = &statusBar;
         EventDispatcher eventDispatch(setup.conn);
         EventHandler handler(&setup);
         KeyHandler keyHandler(&setup);
+        KeyCallback commandCallback;
+        KeyCallback interactCallback;
         eventDispatch.setHandler("ConfigureRequest", std::bind(&EventHandler::handleConfigureRequest, &handler, std::placeholders::_1));
         eventDispatch.setHandler("MapRequest", std::bind(&EventHandler::handleMapRequest, &handler, std::placeholders::_1));
         eventDispatch.setHandler("DestroyNotify", std::bind(&EventHandler::handleDestroyNotify, &handler, std::placeholders::_1));
         eventDispatch.setHandler("UnmapNotify", std::bind(&EventHandler::handleUnmapNotify, &handler, std::placeholders::_1));
         eventDispatch.setHandler("EnterNotify", std::bind(&EventHandler::handleEnterNotify, &handler, std::placeholders::_1));
+        eventDispatch.setHandler("error", std::bind(&EventHandler::handleError, &handler, std::placeholders::_1));
         eventDispatch.setHandler("MappingNotify", std::bind(&KeyHandler::handleMappingNotify, &keyHandler, std::placeholders::_1));
         eventDispatch.setHandler("KeyPress", std::bind(&KeyHandler::handleKeyPress, &keyHandler, std::placeholders::_1));
         eventDispatch.setHandler("KeyRelease", std::bind(&KeyHandler::handleKeyRelease, &keyHandler, std::placeholders::_1));
-        keyHandler.grabKey(XCB_MOD_MASK_4, XK_Escape, Press, [&]{ std::cout << "got a key press!!!"<< std::endl; });
+        
+        commandCallback = [&]{
+            statusBar.setText("Command"); 
+            keyHandler.ungrabKey(XCB_MOD_MASK_4, XK_Escape, Press);
+            keyHandler.grabKey(0, XK_i, Press, interactCallback);
+            keyHandler.grabKey(0, XK_x, Press, [&]{setup.monitors[0].tagList[0].boxTree.killFocused();});
+            keyHandler.grabKey(0, XK_q, Press, [&]{eventDispatch.stop();});
+            xcb_grab_keyboard(setup.conn, true, setup.root, XCB_CURRENT_TIME, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
+        };
+
+        interactCallback = [&]{
+            statusBar.setText("Interact");
+            keyHandler.ungrabKey(0, XK_i, Press);
+            keyHandler.ungrabKey(0, XK_q, Press);
+            keyHandler.ungrabKey(0, XK_x, Press);
+            keyHandler.grabKey(XCB_MOD_MASK_4, XK_Escape, Press, commandCallback);
+            xcb_ungrab_keyboard(setup.conn, XCB_CURRENT_TIME);
+        };
+
+        commandCallback();
         eventDispatch.eventLoop();
+
     }
     catch (OtherWindowManager &ex)
     {
         std::cout << "There is another window manager running; I can't do anything. Sorry!" << std::endl;
         return 0;
     }
-    
+   return 0;
 
 }
 #include "setup.h"
 #include "monitor.h"
+#include "statusBar.h"
 
 Setup::Setup()
 {
     conn = xcb_connect(nullptr, nullptr);
-    xcb_screen_t* screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;
+    screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;
     root = screen->root;
+
+    ewmh = ewmhInit(conn);
     
     uint32_t event_mask[] = {XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
                                 XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY |
 	{
         throw OtherWindowManager();                                                                                       
     }
-
+    statusBarHeight = 20;
     xcb_rectangle_t screenArea;
     screenArea.x = 0;
-    screenArea.y = 0;
+    screenArea.y = statusBarHeight;
     screenArea.width = screen->width_in_pixels;
-    screenArea.height = screen->height_in_pixels;
+    screenArea.height = screen->height_in_pixels - statusBarHeight;
     Monitor newMonitor(screenArea);
     Tag newTag;
     newTag.name = "default";

src/statusBar.cpp

+#include "statusBar.h"
+#include "setup.h"
+#include "monitor.h"
+
+StatusBar::StatusBar(Setup *setup):
+    setup(setup)
+{
+    xcb_window_t id = xcb_generate_id(setup->conn);
+    int width = setup->monitors[0].area.width;
+    uint32_t values[] = {setup->screen->white_pixel, XCB_EVENT_MASK_KEY_PRESS|XCB_EVENT_MASK_KEY_RELEASE|XCB_EVENT_MASK_EXPOSURE};
+    xcb_create_window( setup->conn, XCB_COPY_FROM_PARENT, id, setup->root, 
+                        0, 0, width, setup->statusBarHeight, 1, XCB_WINDOW_CLASS_INPUT_OUTPUT, 
+                        setup->screen->root_visual, XCB_CW_BACK_PIXEL|XCB_CW_EVENT_MASK, values );
+    window= new Window(setup, id);
+    
+    xcb_visualtype_t *visualType = nullptr;
+    auto depthIter = xcb_screen_allowed_depths_iterator(setup->screen);
+    for (; depthIter.rem; xcb_depth_next(&depthIter))
+    {
+        auto visualIter = xcb_depth_visuals_iterator(depthIter.data);
+        for (; visualIter.rem; xcb_visualtype_next(&visualIter))
+        {
+            if (setup->screen->root_visual == visualIter.data->visual_id)
+            {
+                visualType = visualIter.data;
+            }
+        }
+    }
+    surface =  Cairo::XcbSurface::create(setup->conn, id, visualType, width, setup->statusBarHeight);
+    context = Cairo::Context::create(surface);
+    
+    
+
+    window->map();
+    draw(); 
+
+    xcb_flush(setup->conn);
+}
+
+StatusBar::~StatusBar()
+{
+    delete window;
+}
+
+void StatusBar::setText(std::string newText)
+{
+    text = newText;
+    draw();
+}
+
+
+void StatusBar::draw()
+{
+    context->set_source_rgb(0,0,1);
+    context->paint();
+    context->move_to(5, 15);
+    context->set_source_rgb(1, 1, 1);
+    context->set_font_size(12);
+    context->show_text(text);
+    context->stroke();
+}
+
+void StatusBar::handleExposeEvent(EventPtr event)
+{
+    draw();
+}
     return geometry;
 }
 
+void Window::map()
+{
+    xcb_map_window(setup->conn, id);
+}
+
+void Window::unmap()
+{
+    xcb_unmap_window(setup->conn, id);
+}
+
 void Window::sendTakeFocus()
 {
     xcb_atom_t WM_TAKE_FOCUS;

src/xcb_surface.cpp

+/* Copyright (C) 2005 The cairomm Development Team
+ * 2011 Edwin van Leeuwen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include <cairomm/xcb_surface.h>
+#include <cairomm/private.h>
+
+
+namespace Cairo
+{
+
+#ifdef CAIRO_HAS_XLIB_SURFACE
+
+XcbSurface::XcbSurface(cairo_surface_t* cobject, bool has_reference) :
+    Surface(cobject, has_reference)
+{}
+
+XcbSurface::~XcbSurface()
+{
+  // surface is destroyed in base class
+}
+
+RefPtr<XcbSurface> XcbSurface::create(xcb_connection_t *dpy, xcb_drawable_t drawable, xcb_visualtype_t *visual, int width, int height)
+{
+  cairo_surface_t* cobject = cairo_xcb_surface_create(dpy, drawable, visual, width, height);
+  check_status_and_throw_exception(cairo_surface_status(cobject));
+  return RefPtr<XcbSurface>(new XcbSurface(cobject, true /* has reference */));
+}
+
+RefPtr<XcbSurface> XcbSurface::create(xcb_connection_t *dpy, xcb_screen_t *screen, xcb_pixmap_t  bitmap, int width, int height)
+{
+  cairo_surface_t* cobject = cairo_xcb_surface_create_for_bitmap(dpy, screen, bitmap, width, height);
+  check_status_and_throw_exception(cairo_surface_status(cobject));
+  return RefPtr<XcbSurface>(new XcbSurface(cobject, true /* has reference */));
+}
+
+void XcbSurface::set_size(int width, int height)
+{
+  cairo_xcb_surface_set_size(m_cobject, width, height);
+  check_object_status_and_throw_exception(*this);
+}
+
+/*void XcbSurface::set_drawable(Drawable drawable, int width, int height)
+{
+  cairo_xcb_surface_set_drawable(m_cobject, drawable, width, height);
+  check_object_status_and_throw_exception(*this);
+}
+
+Drawable XcbSurface::get_drawable() const
+{
+  Drawable drawable = cairo_xcb_surface_get_drawable(m_cobject);
+  check_object_status_and_throw_exception(*this);
+  return drawable;
+}
+
+const Display* XcbSurface::get_display() const
+{
+  const Display* dpy = cairo_xcb_surface_get_display(m_cobject);
+  check_object_status_and_throw_exception(*this);
+  return dpy;
+}
+
+Display* XcbSurface::get_display()
+{
+  Display* dpy = cairo_xcb_surface_get_display(m_cobject);
+  check_object_status_and_throw_exception(*this);
+  return dpy;
+}
+
+Screen* XcbSurface::get_screen()
+{
+  Screen* screen = cairo_xcb_surface_get_screen(m_cobject);
+  check_object_status_and_throw_exception(*this);
+  return screen;
+}
+
+const Screen* XcbSurface::get_screen() const
+{
+  const Screen* screen = cairo_xcb_surface_get_screen(m_cobject);
+  check_object_status_and_throw_exception(*this);
+  return screen;
+}
+
+Visual* XcbSurface::get_visual()
+{
+  Visual* visual = cairo_xcb_surface_get_visual(m_cobject);
+  check_object_status_and_throw_exception(*this);
+  return visual;
+}
+
+const Visual* XcbSurface::get_visual() const
+{
+  const Visual* visual = cairo_xcb_surface_get_visual(m_cobject);
+  check_object_status_and_throw_exception(*this);
+  return visual;
+}
+
+int XcbSurface::get_depth() const
+{
+  int depth = cairo_xcb_surface_get_depth(m_cobject);
+  check_object_status_and_throw_exception(*this);
+  return depth;
+}
+
+int XcbSurface::get_height() const
+{
+  int h = cairo_xcb_surface_get_height(m_cobject);
+  check_object_status_and_throw_exception(*this);
+  return h;
+}
+
+int XcbSurface::get_width() const
+{
+  int w = cairo_xcb_surface_get_width(m_cobject);
+  check_object_status_and_throw_exception(*this);
+  return w;
+}*/
+#endif 
+} //namespace Cairo
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.