Debian Codegraph @

Source/Core/Common/GL/GLX11Window.cpp

raw symbols SCIP
1 // Copyright 2012 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #include "Common/GL/GLX11Window.h"
5
6 GLX11Window::GLX11Window(Display* display, Window parent_window, Colormap color_map, Window window,
7 int width, int height)
8 : m_display(display), m_parent_window(parent_window), m_color_map(color_map), m_window(window),
9 m_width(width), m_height(height)
10 {
11 }
12
13 GLX11Window::~GLX11Window()
14 {
15 XUnmapWindow(m_display, m_window);
16 XDestroyWindow(m_display, m_window);
17 XFreeColormap(m_display, m_color_map);
18 }
19
20 void GLX11Window::UpdateDimensions()
21 {
22 XWindowAttributes attribs;
23 XGetWindowAttributes(m_display, m_parent_window, &attribs);
24 XResizeWindow(m_display, m_window, attribs.width, attribs.height);
25 m_width = attribs.width;
26 m_height = attribs.height;
27 }
28
29 std::unique_ptr<GLX11Window> GLX11Window::Create(Display* display, Window parent_window,
30 XVisualInfo* vi)
31 {
32 // Set color map for the new window based on the visual.
33 Colormap color_map = XCreateColormap(display, parent_window, vi->visual, AllocNone);
34 XSetWindowAttributes attribs = {};
35 attribs.colormap = color_map;
36
37 // Get the dimensions from the parent window.
38 XWindowAttributes parent_attribs = {};
39 XGetWindowAttributes(display, parent_window, &parent_attribs);
40
41 // Create the window
42 Window window =
43 XCreateWindow(display, parent_window, 0, 0, parent_attribs.width, parent_attribs.height, 0,
44 vi->depth, InputOutput, vi->visual, CWColormap, &attribs);
45 XSelectInput(display, parent_window, StructureNotifyMask);
46 XMapWindow(display, window);
47 XSync(display, True);
48
49 return std::make_unique<GLX11Window>(display, parent_window, color_map, window,
50 parent_attribs.width, parent_attribs.height);
51 }