Skip to content

Instantly share code, notes, and snippets.

@LaurentGomila
Created July 5, 2013 13:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save LaurentGomila/5934572 to your computer and use it in GitHub Desktop.
WindowImplX11::WindowImplX11(WindowHandle handle, const ContextSettings& settings) :
m_window (0),
m_inputMethod (NULL),
m_inputContext(NULL),
m_isExternal (true),
m_atomClose (0),
m_oldVideoMode(-1),
m_hiddenCursor(0),
m_keyRepeat (true),
m_previousSize(-1, -1)
{
// Instead of hooking the given window directly, we create a child window that covers it;
// this gives more flexibility (especially about event handling)
// Open a connection with the X server
m_display = OpenDisplay();
m_screen = DefaultScreen(m_display);
// Get the size of the parent window
XWindowAttributes parentAttributes;
XGetWindowAttributes(m_display, handle, &parentAttributes);
// Choose the visual according to the context settings
XVisualInfo visualInfo = GlxContext::selectBestVisual(m_display, parentAttributes.depth, settings);
// Define the window attributes
XSetWindowAttributes attributes;
attributes.override_redirect = false;
attributes.event_mask = eventMask;
attributes.colormap = XCreateColormap(m_display, handle, visualInfo.visual, AllocNone);
// Create the window
m_window = XCreateWindow(m_display,
handle,
0, 0,
parentAttributes.width, parentAttributes.height,
0,
visualInfo.depth,
InputOutput,
visualInfo.visual,
CWEventMask | CWOverrideRedirect | CWColormap, &attributes);
if (!m_window)
{
err() << "Failed to create window" << std::endl;
return;
}
// Do some common initializations
initialize();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment