|
| 1 | +// Licensed to the Software Freedom Conservancy (SFC) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The SFC licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +const WindowState = Object.freeze({ |
| 19 | + FULLSCREEN: 'fullscreen', |
| 20 | + MAXIMIZED: 'maximized', |
| 21 | + MINIMIZED: 'minimized', |
| 22 | + NORMAL: 'normal', |
| 23 | +}) |
| 24 | + |
| 25 | +class ClientWindowInfo { |
| 26 | + /** |
| 27 | + * @param {Object} params Window information parameters |
| 28 | + * @param {string} params.clientWindow Window identifier |
| 29 | + * @param {string} params.state Window state from WindowState |
| 30 | + * @param {number} params.width Window width |
| 31 | + * @param {number} params.height Window height |
| 32 | + * @param {number} params.x Window x coordinate |
| 33 | + * @param {number} params.y Window y coordinate |
| 34 | + * @param {boolean} params.active Whether window is active and can receive keyboard input |
| 35 | + */ |
| 36 | + constructor({ clientWindow, state, width, height, x, y, active }) { |
| 37 | + this.clientWindow = clientWindow |
| 38 | + this.state = state |
| 39 | + this.width = width |
| 40 | + this.height = height |
| 41 | + this.x = x |
| 42 | + this.y = y |
| 43 | + this.active = active |
| 44 | + } |
| 45 | + |
| 46 | + static fromJson(json) { |
| 47 | + return new ClientWindowInfo({ |
| 48 | + ...json, |
| 49 | + state: json.state.toLowerCase(), |
| 50 | + }) |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +module.exports = { WindowState, ClientWindowInfo } |
0 commit comments