GCC Code Coverage Report


Directory: ./
File: backends/xrandr/xrandrscreen.cpp
Date: 2023-04-20 22:59:23
Exec Total Coverage
Lines: 0 25 0.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /*************************************************************************************
2 * Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
3 * Copyright (C) 2012, 2013 by Daniel Vrátil <dvratil@redhat.com> *
4 * *
5 * This library is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU Lesser General Public *
7 * License as published by the Free Software Foundation; either *
8 * version 2.1 of the License, or (at your option) any later version. *
9 * *
10 * This library is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13 * Lesser General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU Lesser General Public *
16 * License along with this library; if not, write to the Free Software *
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
18 *************************************************************************************/
19 #include "xrandrscreen.h"
20
21 #include "config.h"
22 #include "screen.h"
23 #include "xcbwrapper.h"
24 #include "xrandrconfig.h"
25
26 #include <QtGui/private/qtx11extras_p.h>
27
28 XRandRScreen::XRandRScreen(XRandRConfig* config)
29 : QObject(config)
30 {
31 XCB::ScreenSize size(XRandR::rootWindow());
32 m_maxSize = QSize(size->max_width, size->max_height);
33 m_minSize = QSize(size->min_width, size->min_height);
34 update();
35 }
36
37 XRandRScreen::~XRandRScreen()
38 {
39 }
40
41 void XRandRScreen::update()
42 {
43 xcb_screen_t* screen = XCB::screenOfDisplay(XCB::connection(), QX11Info::appScreen());
44 m_currentSize = QSize(screen->width_in_pixels, screen->height_in_pixels);
45 }
46
47 void XRandRScreen::update(const QSize& size)
48 {
49 m_currentSize = size;
50 }
51
52 QSize XRandRScreen::currentSize()
53 {
54 return m_currentSize;
55 }
56
57 Disman::ScreenPtr XRandRScreen::toDismanScreen() const
58 {
59 Disman::ScreenPtr dismanScreen(new Disman::Screen);
60 dismanScreen->set_id(m_id);
61 dismanScreen->set_max_size(m_maxSize);
62 dismanScreen->set_min_size(m_minSize);
63 dismanScreen->set_current_size(m_currentSize);
64
65 XCB::ScopedPointer<xcb_randr_get_screen_resources_reply_t> screenResources(
66 XRandR::screenResources());
67 dismanScreen->set_max_outputs_count(screenResources->num_crtcs);
68
69 return dismanScreen;
70 }
71
72 void XRandRScreen::updateDismanScreen(Disman::ScreenPtr& screen) const
73 {
74 screen->set_current_size(m_currentSize);
75 }
76