This file is indexed.

/usr/share/kde4/apps/kcm_kscreen/qml/OutputView.qml is in kscreen 1.0.2.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
/*
    Copyright (C) 2012  Dan Vratil <dvratil@redhat.com>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 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
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser 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
*/

import QtQuick 1.0
import KScreen 1.0
import "OutputView.js" as JS;

Flickable {

    id: root;

    signal outputsChanged();
    signal outputChanged();
    signal moveMouse(int x, int y);
    signal outputMousePressed();
    signal outputMouseReleased();

    property int maxContentWidth;
    property int maxContentHeight;

    property Item activeOutput;
    property bool snappingEnabled: true;

    contentWidth: width;
    contentHeight: height;
    focus: true;

    onWidthChanged: reorderOutputs();
    onHeightChanged: reorderOutputs();

    Timer {
        id: autoScrollTimer;

        interval: 50;
        running: false;
        repeat: true;
        onTriggered: JS.doAutoScroll(root);
    }

    Timer {
        id: autoResizeTimer;

        interval: 50;
        running: (activeOutput && activeOutput.isDragged) ? true : false;
        repeat: true;
        onTriggered: JS.doAutoResize(root);
    }

    Keys.onPressed: {
        if (event.modifiers & Qt.ControlModifier) {
            snappingEnabled = false;
        }
    }

    Keys.onReleased: {
        if (!snappingEnabled) {
            snappingEnabled = true;
        }
    }

    /**
     * Adds a new \p output to the OutputView
     *
     * @param KScreen::Output output A new KScreen::Output to wrap into QMLOutput
     *          and add to the scene
     */
    function addOutput(output) {
        var component = Qt.createComponent("Output.qml");
        if (component.status == Component.Error) {
            console.log("Error creating output '" + output.name + "': " + component.errorString());
            return;
        }
        var qmlOutput = component.createObject(root.contentItem, { "output": output, "outputView": root });
        qmlOutput.z = root.children.length;

        qmlOutput.clicked.connect(outputClicked);
        qmlOutput.changed.connect(outputChanged);
        qmlOutput.moved.connect(outputMoved);
        qmlOutput.enabledToggled.connect(outputEnabledToggled);
        qmlOutput.primaryTriggered.connect(primaryTriggered);
        qmlOutput.output.isConnectedChanged.connect(outputConnected);
        qmlOutput.mousePressed.connect(outputMousePressed);
        qmlOutput.mouseReleased.connect(outputMouseReleased);

        if (!output.connected) {
            return;
        }

        qmlOutput.updateRootProperties();

        /* Maybe enable dragging of outputs? */
        root.outputConnected();

        /* Notify outter world */
        root.outputsChanged();
    }

    /**
     * Reorders all visible outputs to be in the middle of current view
     */
    function reorderOutputs() {
        var disabledOffset = root.width;

        var rectX = 0, rectY = 0, rectWidth = 0, rectHeight = 0;
        var positionedOutputs = [];
        for (var i = 0; i < root.contentItem.children.length; i++) {
            var qmlOutput = root.contentItem.children[i];

            if (!qmlOutput.output.connected) {
                qmlOutput.x = 0;
                qmlOutput.y = 0;
                continue;
            }

            /* Don't reposition outputs that user has moved from their default
             * position */
            if (qmlOutput.hasMoved) {
                continue;
            }

            if (!qmlOutput.output.enabled) {
                disabledOffset -= qmlOutput.width;
                qmlOutput.x = disabledOffset;
                qmlOutput.y = 0;
                continue;
            }

            qmlOutput.x = qmlOutput.output.pos.x * qmlOutput.displayScale;
            qmlOutput.y = qmlOutput.output.pos.y * qmlOutput.displayScale;

            if (qmlOutput.x < rectX) {
                rectX = qmlOutput.x;
            }

            var visualWidth;
            var visualHeight;
            if (qmlOutput.output.isHorizontal()) {
                visualWidth = qmlOutput.width;
                visualHeight = qmlOutput.height;
            } else {
                visualWidth = qmlOutput.height;
                visualHeight = qmlOutput.width;
            }
            if (qmlOutput.x + visualWidth > rectWidth) {
                rectWidth = qmlOutput.x + visualWidth;
            }

            if (qmlOutput.y < rectY) {
                rectY = qmlOutput.y;
            }

            if (qmlOutput.y + visualHeight > rectHeight) {
                rectHeight = qmlOutput.y + visualHeight;
            }

            positionedOutputs.push(qmlOutput);
        }

        var offsetX = rectX + ((root.contentWidth - rectWidth) / 2);
        var offsetY = rectY + ((root.contentHeight - rectHeight) / 2);
        for (var i = 0; i < positionedOutputs.length; i++) {
            var positionedOutput = positionedOutputs[i];
            positionedOutput.x = offsetX + (positionedOutput.output.pos.x * positionedOutput.displayScale);
            positionedOutput.y = offsetY + (positionedOutput.output.pos.y * positionedOutput.displayScale);
        }
    }

    /**
     * @return: Returns current primary QMLOutput or null when there's no
     *          output with 'primary' flag set.
     */
    function getPrimaryOutput() {
        for (var i = 0; i < root.contentItem.children.length; i++) {
            var qmlOutput = root.contentItem.children[i];
            if (qmlOutput.output.primary) {
                return qmlOutput;
            }
        }

        return null;
    }

    /**
     * Slot to be called when an output is clicked
     *
     * @param string outputName Name of the clicked QMLOutput
     */
    function outputClicked(outputName) {
        var output = JS.findOutputByName(root, outputName);

        for (var i = 0; i < root.contentItem.children.length; i++) {
            var qmlOutput = root.contentItem.children[i];

            if (qmlOutput == output) {
                var z = qmlOutput.z;

                for (var j = 0; j < root.contentItem.children.length; j++) {
                    var otherZ = root.contentItem.children[j].z;
                    if (otherZ > z) {
                        root.contentItem.children[j].z = otherZ - 1;
                    }
                }

                qmlOutput.z = root.contentItem.children.length;
                qmlOutput.focus = true;
                root.activeOutput = qmlOutput;

                break;
            }
        }
    }

    /**
     * Slot to be called when a primary flag is triggered on an output
     *
     * @param string outputName Name of the QMLOutput that has been triggered
     */
    function primaryTriggered(outputName) {
            /* Unset primary flag on all other outputs */
        var output = JS.findOutputByName(root, outputName);
        for (var i = 0; i < root.contentItem.children.length; i++) {
            var otherOutput = root.contentItem.children[i];

            if (otherOutput != output) {
                otherOutput.output.primary = false;
            }
        }
    }

    /**
     * Slot to be called when an output is moved (dragged) within the scene
     *
     * @param string outputName Name of the QMLOutput that is being dragged
     */
    function outputMoved(outputName) {
        var output = JS.findOutputByName(root, outputName);
        var x = output.x;
        var y = output.y;
        var width = output.width;
        var height = output.height;

        if (root.snappingEnabled) {
            JS.snapOutput(outputView, output);
        }

        if (output.cloneOf != null) {
            /* Reset position of the cloned screen and current screen and
             * don't care about any further positioning */
            output.outputX = 0;
            output.outputY = 0;
            output.cloneOf.outputX = 0;
            output.cloneOf.outputY = 0;

            return;
        }

        /* Left-most and top-most outputs. Other outputs are positioned
         * relatively to these */
        var cornerOutputs = JS.findCornerOutputs(outputView);
        if (cornerOutputs["left"] != null) {
            cornerOutputs["left"].outputX = 0
        }
        if (cornerOutputs["top"] != null) {
            cornerOutputs["top"].outputY = 0;
        }

        /* Only run autoscroll timer if there's anywhere to scroll */
        if ((root.contentX > 0) ||
            (root.contentY > 0) ||
            (root.contentWidth > root.width) ||
            (root.contentHeight > root.height)) {

            if ((output.x < root.contentX + 50) || /* left */
                (output.x > root.contentX + root.width - 50) || /* right */
                (output.y < root.contentY + 50) || /* top */
                (output.y > root.contentY + root.height - 50)) { /* bottom */

                if (!autoScrollTimer.running) {
                    JS._autoScrollStep = 0;
                    autoScrollTimer.start();
                }
            }
        }

        JS.updateVirtualPosition(outputView, output, cornerOutputs);
    }

    /**
     * Slot to be called when an output is enabled or disabled
     *
     * @param string outputName NAme of the QMLOutput that has been enabled or disabled
     */
    function outputEnabledToggled(outputName)
    {
        // Simulate a 'move'. This will recalculate virutal positions of all
        // outputs. See https://bugs.kde.org/show_bug.cgi?id=313027#c16
        outputMoved(outputName);


        var enabledCount = 0;
        for (var i = 0; i < root.contentItem.children.length; i++) {
            var output = root.contentItem.children[i];

            if (output.output.enabled) {
                enabledCount++;
                if (enabledCount > 0) {
                    break;
                }
            }
        }

        noActiveOutputsWarning.opacity = (enabledCount > 0) ? 0.0 : 1.0;
    }

    /**
     * Slot to be called whenever an output is (dis)connected.
     */
    function outputConnected()
    {
        var connectedCount = 0;

        for (var i = 0; i < root.contentItem.children.length; i++) {
            var output = root.contentItem.children[i];

            if (output.output.connected) {
                connectedCount++;
                if (connectedCount > 1) {
                    break;
                }
            }
        }

        for (var i = 0; i < root.contentItem.children.length; i++) {
            var output = root.contentItem.children[i];

            output.isDragEnabled = (connectedCount > 1);
            output.isToggleButtonVisible = (connectedCount > 1);
        }
    }
}