File: save-screen.h

package info (click to toggle)
ukui-settings-daemon 4.0.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,412 kB
  • sloc: cpp: 39,120; ansic: 3,240; xml: 1,570; sh: 88; makefile: 4
file content (155 lines) | stat: -rw-r--r-- 4,043 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
 * -*- coding: utf-8 -*-
 *
 * Copyright (C) 2023 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


#ifndef KDSWIDGET_H
#define KDSWIDGET_H

#include <QObject>
#include <KF6/KScreen/kscreen/output.h>
#include <KF6/KScreen/kscreen/edid.h>
#include <KF6/KScreen/kscreen/mode.h>
#include <KF6/KScreen/kscreen/config.h>
#include <KF6/KScreen/kscreen/getconfigoperation.h>
#include <KF6/KScreen/kscreen/setconfigoperation.h>
#include "xrandr-config.h"
#include "xrandroutput.h"

extern "C"{
//#include <glib.h>
#include <X11/extensions/Xrandr.h>
#include <X11/Xatom.h>
}

typedef struct tag_OutputHashDictionary{
    QString name;
    QString hash;
}OutputHashDictionary;

typedef struct tag_X11OutputInfo{
    XID outputId;
    XRROutputInfo *outputInfo;
    XRRModeInfo	*modes;
}X11OutputInfo;

class SaveScreenParam :  public QObject
{
    Q_OBJECT

//    Q_PROPERTY(bool isSet READ isSet WRITE setIsSet )
//    Q_PROPERTY(bool isGet READ isGet WRITE setIsGet )

public:

    explicit SaveScreenParam(QObject *parent = nullptr) ;
    ~SaveScreenParam();
    void setIsSet(bool value)
    {
        m_isSet = value;
    }

    void setIsGet(bool value)
    {
        m_isGet = value;
    }

    bool isSet() const
    {
        return m_isSet;
    }

    bool isGet() const
    {
        return m_isGet;
    }

    OutputsConfig getOutputConfig(){
        return m_kscreenConfigParam;
    }

#ifdef MODULE_NAME
    void getConfig();
#endif
    void setWithoutConfig(OutputsConfig *outputsConfig);

    void setUserConfigParam();

    void setUserName(QString str);

    void setScreenSize();

    void readKscreenConfigAndSetItWithX(QString kscreenConfigName = "");

    void disableCrtc();
    //kscreen 接口目前废弃
    void readConfigAndSetBak();

    QString printUserConfigParam();
    void query();

    OutputsConfig readOutputConfig();

    QSize getMaxSize();
Q_SIGNALS:
    void applyFinish();
    void getConfigFinished();
private:
    bool m_isSet;
    bool m_isGet;
    bool m_isSameHash;
    int	m_screen;
    QString m_KscreenConfigFile;
    char   *m_pDisplayName = NULL;

    Display	*m_pDpy = nullptr;
    Window	m_rootWindow;
    XRRScreenResources  *m_pScreenRes = nullptr;

    QString m_userName;
    QList<OutputHashDictionary> m_outputHashDic;
    std::unique_ptr<xrandrConfig> m_MonitoredConfig = nullptr;
private:
    OutputsConfig m_kscreenConfigParam;
    int initXparam();

    bool checkTransformat(RRCrtc crtc, double scale);
    bool clearCrtc(RRCrtc crtc);
    bool clearAllCrtc();
    bool readKscreenConfig(OutputsConfig *outputsConfig, QString configFullPath);

    void getRootWindows();
    void getScreen();
    void debugAllOutput(OutputsConfig *outputsConfig);
    void clearAndGetCrtcs(OutputsConfig *outputsConfig);
    void setCrtcWith(OutputsConfig *outputsConfig);
    void setCrtcConfig(OutputsConfig *outputsConfig);
    QString showAllOutputInJson(OutputsConfig *outputsConfig);
    double getScaleWithSize(int heightmm, int widthmm, int height, int width);
    double getScale(double scaling);
    double getScoreScale(double scaling);


    RRMode getModeId(XRROutputInfo	*outputInfo, UsdOuputProperty *kscreenOutputParam);
    QString getKscreenConfigFullPathInLightDM();
    bool isUsdScale();
    bool getScaleStatus(QString str);
    double getDefautScaleFactor(OutputsConfig *outputsConfig);
};

#endif // KDSWIDGET_H