File indexing completed on 2022-11-29 15:04:29

0001 /*
0002     SPDX-FileCopyrightText: 2016 Smith AR <audoban@openmailbox.org>
0003     SPDX-FileCopyrightText: 2016 Michail Vourlakos <mvourlakos@gmail.com>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #include "windowinfowrap.h"
0009 
0010 
0011 namespace Latte {
0012 namespace WindowSystem {
0013 
0014 WindowInfoWrap::WindowInfoWrap()
0015 {
0016 }
0017 
0018 WindowInfoWrap::WindowInfoWrap(const WindowInfoWrap &o)
0019     : m_wid(o.m_wid)
0020     , m_parentId(o.m_parentId)
0021     , m_geometry(o.m_geometry)
0022     , m_isValid(o.m_isValid)
0023     , m_isActive(o.m_isActive)
0024     , m_isMinimized(o.m_isMinimized)
0025     , m_isMaxVert(o.m_isMaxVert)
0026     , m_isMaxHoriz(o.m_isMaxHoriz)
0027     , m_isFullscreen(o.m_isFullscreen)
0028     , m_isShaded(o.m_isShaded)
0029     , m_isKeepAbove(o.m_isKeepAbove)
0030     , m_isKeepBelow(o.m_isKeepBelow)
0031     , m_hasSkipPager(o.m_hasSkipPager)
0032     , m_hasSkipSwitcher(o.m_hasSkipSwitcher)
0033     , m_hasSkipTaskbar(o.m_hasSkipTaskbar)
0034     , m_isOnAllDesktops(o.m_isOnAllDesktops)
0035     , m_isOnAllActivities(o.m_isOnAllActivities)
0036     , m_isClosable(o.m_isClosable)
0037     , m_isFullScreenable(o.m_isFullScreenable)
0038     , m_isGroupable(o.m_isGroupable)
0039     , m_isMaximizable(o.m_isMaximizable)
0040     , m_isMinimizable(o.m_isMinimizable)
0041     , m_isMovable(o.m_isMovable)
0042     , m_isResizable(o.m_isResizable)
0043     , m_isShadeable(o.m_isShadeable)
0044     , m_isVirtualDesktopsChangeable(o.m_isVirtualDesktopsChangeable)
0045     , m_desktops(o.m_desktops)
0046     , m_activities(o.m_activities)
0047     , m_display(o.m_display)
0048 {
0049 }
0050 
0051 WindowInfoWrap::WindowInfoWrap(WindowInfoWrap &&o)
0052     : m_wid(o.m_wid)
0053     , m_parentId(o.m_parentId)
0054     , m_geometry(o.m_geometry)
0055     , m_isValid(o.m_isValid)
0056     , m_isActive(o.m_isActive)
0057     , m_isMinimized(o.m_isMinimized)
0058     , m_isMaxVert(o.m_isMaxVert)
0059     , m_isMaxHoriz(o.m_isMaxHoriz)
0060     , m_isFullscreen(o.m_isFullscreen)
0061     , m_isShaded(o.m_isShaded)
0062     , m_isKeepAbove(o.m_isKeepAbove)
0063     , m_isKeepBelow(o.m_isKeepBelow)
0064     , m_hasSkipPager(o.m_hasSkipPager)
0065     , m_hasSkipSwitcher(o.m_hasSkipSwitcher)
0066     , m_hasSkipTaskbar(o.m_hasSkipTaskbar)
0067     , m_isOnAllDesktops(o.m_isOnAllDesktops)
0068     , m_isOnAllActivities(o.m_isOnAllActivities)
0069     , m_isClosable(o.m_isClosable)
0070     , m_isFullScreenable(o.m_isFullScreenable)
0071     , m_isGroupable(o.m_isGroupable)
0072     , m_isMaximizable(o.m_isMaximizable)
0073     , m_isMinimizable(o.m_isMinimizable)
0074     , m_isMovable(o.m_isMovable)
0075     , m_isResizable(o.m_isResizable)
0076     , m_isShadeable(o.m_isShadeable)
0077     , m_isVirtualDesktopsChangeable(o.m_isVirtualDesktopsChangeable)
0078     , m_desktops(o.m_desktops)
0079     , m_activities(o.m_activities)
0080     , m_display(o.m_display)
0081 {
0082 }
0083 
0084 //! Operators
0085 // BEGIN: definitions
0086 WindowInfoWrap &WindowInfoWrap::operator=(WindowInfoWrap &&rhs)
0087 {
0088     m_wid = rhs.m_wid;
0089     m_parentId = rhs.m_parentId;
0090     m_geometry = rhs.m_geometry;
0091     m_isValid = rhs.m_isValid;
0092     m_isActive = rhs.m_isActive;
0093     m_isMinimized = rhs.m_isMinimized;
0094     m_isMaxVert = rhs.m_isMaxVert;
0095     m_isMaxHoriz = rhs.m_isMaxHoriz;
0096     m_isFullscreen = rhs.m_isFullscreen;
0097     m_isShaded = rhs.m_isShaded;
0098     m_isKeepAbove = rhs.m_isKeepAbove;
0099     m_isKeepBelow = rhs.m_isKeepBelow;
0100     m_hasSkipPager = rhs.m_hasSkipPager;
0101     m_hasSkipSwitcher = rhs.m_hasSkipSwitcher;
0102     m_hasSkipTaskbar = rhs.m_hasSkipTaskbar;
0103     m_isOnAllDesktops = rhs.m_isOnAllDesktops;
0104     m_isOnAllActivities = rhs.m_isOnAllActivities;
0105     m_isClosable = rhs.m_isClosable;
0106     m_isFullScreenable = rhs.m_isFullScreenable;
0107     m_isGroupable = rhs.m_isGroupable;
0108     m_isMaximizable = rhs.m_isMaximizable;
0109     m_isMinimizable = rhs.m_isMinimizable;
0110     m_isMovable = rhs.m_isMovable;
0111     m_isResizable = rhs.m_isResizable;
0112     m_isShadeable = rhs.m_isShadeable;
0113     m_isVirtualDesktopsChangeable = rhs.m_isVirtualDesktopsChangeable;
0114 
0115     m_display = rhs.m_display;
0116     m_desktops = rhs.m_desktops;
0117     m_activities = rhs.m_activities;
0118     return *this;
0119 }
0120 
0121 WindowInfoWrap &WindowInfoWrap::operator=(const WindowInfoWrap &rhs)
0122 {
0123     m_wid = rhs.m_wid;
0124     m_parentId = rhs.m_parentId;
0125     m_geometry = rhs.m_geometry;
0126     m_isValid = rhs.m_isValid;
0127     m_isActive = rhs.m_isActive;
0128     m_isMinimized = rhs.m_isMinimized;
0129     m_isMaxVert = rhs.m_isMaxVert;
0130     m_isMaxHoriz = rhs.m_isMaxHoriz;
0131     m_isFullscreen = rhs.m_isFullscreen;
0132     m_isShaded = rhs.m_isShaded;
0133     m_isKeepAbove = rhs.m_isKeepAbove;
0134     m_isKeepBelow = rhs.m_isKeepBelow;
0135     m_hasSkipPager = rhs.m_hasSkipPager;
0136     m_hasSkipSwitcher = rhs.m_hasSkipSwitcher;
0137     m_hasSkipTaskbar = rhs.m_hasSkipTaskbar;
0138     m_isOnAllDesktops = rhs.m_isOnAllDesktops;
0139     m_isOnAllActivities = rhs.m_isOnAllActivities;
0140     m_isClosable = rhs.m_isClosable;
0141     m_isFullScreenable = rhs.m_isFullScreenable;
0142     m_isGroupable = rhs.m_isGroupable;
0143     m_isMaximizable = rhs.m_isMaximizable;
0144     m_isMinimizable = rhs.m_isMinimizable;
0145     m_isMovable = rhs.m_isMovable;
0146     m_isResizable = rhs.m_isResizable;
0147     m_isShadeable = rhs.m_isShadeable;
0148     m_isVirtualDesktopsChangeable = rhs.m_isVirtualDesktopsChangeable;
0149 
0150     m_display = rhs.m_display;
0151     m_desktops = rhs.m_desktops;
0152     m_activities = rhs.m_activities;
0153     return *this;
0154 }
0155 
0156 //! Access properties
0157 bool WindowInfoWrap::isValid() const
0158 {
0159     return m_isValid;
0160 }
0161 
0162 void WindowInfoWrap::setIsValid(bool isValid)
0163 {
0164     m_isValid = isValid;
0165 }
0166 
0167 bool WindowInfoWrap::isActive() const
0168 {
0169     return m_isActive;
0170 }
0171 
0172 void WindowInfoWrap::setIsActive(bool isActive)
0173 {
0174     m_isActive = isActive;
0175 }
0176 
0177 bool WindowInfoWrap::isMinimized() const
0178 {
0179     return m_isMinimized;
0180 }
0181 
0182 void WindowInfoWrap::setIsMinimized(bool isMinimized)
0183 {
0184     m_isMinimized = isMinimized;
0185 }
0186 
0187 bool WindowInfoWrap::isMaximized() const
0188 {
0189     return m_isMaxVert && m_isMaxHoriz;
0190 }
0191 
0192 bool WindowInfoWrap::isMaxVert() const
0193 {
0194     return m_isMaxVert;
0195 }
0196 
0197 void WindowInfoWrap::setIsMaxVert(bool isMaxVert)
0198 {
0199     m_isMaxVert = isMaxVert;
0200 }
0201 
0202 bool WindowInfoWrap::isMaxHoriz() const
0203 {
0204     return m_isMaxHoriz;
0205 }
0206 
0207 void WindowInfoWrap::setIsMaxHoriz(bool isMaxHoriz)
0208 {
0209     m_isMaxHoriz = isMaxHoriz;
0210 }
0211 
0212 bool WindowInfoWrap::isFullscreen() const
0213 {
0214     return m_isFullscreen;
0215 }
0216 
0217 void WindowInfoWrap::setIsFullscreen(bool isFullscreen)
0218 {
0219     m_isFullscreen = isFullscreen;
0220 }
0221 
0222 bool WindowInfoWrap::isShaded() const
0223 {
0224     return m_isShaded;
0225 }
0226 
0227 void WindowInfoWrap::setIsShaded(bool isShaded)
0228 {
0229     m_isShaded = isShaded;
0230 }
0231 
0232 bool WindowInfoWrap::isKeepAbove() const
0233 {
0234     return m_isKeepAbove;
0235 }
0236 
0237 void WindowInfoWrap::setIsKeepAbove(bool isKeepAbove)
0238 {
0239     m_isKeepAbove = isKeepAbove;
0240 }
0241 
0242 bool WindowInfoWrap::isKeepBelow() const
0243 {
0244     return m_isKeepBelow;
0245 }
0246 
0247 void WindowInfoWrap::setIsKeepBelow(bool isKeepBelow)
0248 {
0249     m_isKeepBelow = isKeepBelow;
0250 }
0251 
0252 bool WindowInfoWrap::hasSkipPager() const
0253 {
0254     return m_hasSkipPager;
0255 }
0256 
0257 void WindowInfoWrap::setHasSkipPager(bool skipPager)
0258 {
0259     m_hasSkipPager = skipPager;
0260 }
0261 
0262 bool WindowInfoWrap::hasSkipSwitcher() const
0263 {
0264     return m_hasSkipSwitcher;
0265 }
0266 
0267 void WindowInfoWrap::setHasSkipSwitcher(bool skipSwitcher)
0268 {
0269     m_hasSkipSwitcher = skipSwitcher;
0270 }
0271 
0272 bool WindowInfoWrap::hasSkipTaskbar() const
0273 {
0274     return m_hasSkipTaskbar;
0275 }
0276 
0277 void WindowInfoWrap::setHasSkipTaskbar(bool skipTaskbar)
0278 {
0279     m_hasSkipTaskbar = skipTaskbar;
0280 }
0281 
0282 bool WindowInfoWrap::isOnAllDesktops() const
0283 {
0284     return m_isOnAllDesktops;
0285 }
0286 
0287 void WindowInfoWrap::setIsOnAllDesktops(bool alldesktops)
0288 {
0289     m_isOnAllDesktops = alldesktops;
0290 }
0291 
0292 bool WindowInfoWrap::isOnAllActivities() const
0293 {
0294     return m_isOnAllActivities;
0295 }
0296 
0297 void WindowInfoWrap::setIsOnAllActivities(bool allactivities)
0298 {
0299     m_isOnAllActivities = allactivities;
0300 }
0301 
0302 //!BEGIN: Window Abilities
0303 bool WindowInfoWrap::isCloseable() const
0304 {
0305     return m_isClosable;
0306 }
0307 void WindowInfoWrap::setIsClosable(bool closable)
0308 {
0309     m_isClosable = closable;
0310 }
0311 
0312 bool WindowInfoWrap::isFullScreenable() const
0313 {
0314     return m_isFullScreenable;
0315 }
0316 void WindowInfoWrap::setIsFullScreenable(bool fullscreenable)
0317 {
0318     m_isFullScreenable = fullscreenable;
0319 }
0320 
0321 bool WindowInfoWrap::isGroupable() const
0322 {
0323     return m_isGroupable;
0324 }
0325 void WindowInfoWrap::setIsGroupable(bool groupable)
0326 {
0327     m_isGroupable = groupable;
0328 }
0329 
0330 bool WindowInfoWrap::isMaximizable() const
0331 {
0332     return m_isMaximizable;
0333 }
0334 void WindowInfoWrap::setIsMaximizable(bool maximizable)
0335 {
0336     m_isMaximizable = maximizable;
0337 }
0338 
0339 bool WindowInfoWrap::isMinimizable() const
0340 {
0341     return m_isMinimizable;
0342 }
0343 void WindowInfoWrap::setIsMinimizable(bool minimizable)
0344 {
0345     m_isMinimizable = minimizable;
0346 }
0347 
0348 bool WindowInfoWrap::isMovable() const
0349 {
0350     return m_isMovable;
0351 }
0352 void WindowInfoWrap::setIsMovable(bool movable)
0353 {
0354     m_isMovable = movable;
0355 }
0356 
0357 bool WindowInfoWrap::isResizable() const
0358 {
0359     return m_isResizable;
0360 }
0361 void WindowInfoWrap::setIsResizable(bool resizable)
0362 {
0363     m_isResizable = resizable;
0364 }
0365 
0366 bool WindowInfoWrap::isShadeable() const
0367 {
0368     return m_isShadeable;
0369 }
0370 void WindowInfoWrap::setIsShadeable(bool shadeble)
0371 {
0372     m_isShadeable = shadeble;
0373 }
0374 
0375 bool WindowInfoWrap::isVirtualDesktopsChangeable() const
0376 {
0377     return m_isVirtualDesktopsChangeable;
0378 }
0379 void WindowInfoWrap::setIsVirtualDesktopsChangeable(bool virtualdesktopchangeable)
0380 {
0381     m_isVirtualDesktopsChangeable = virtualdesktopchangeable;
0382 }
0383 //!END: Window Abilities
0384 
0385 
0386 
0387 bool WindowInfoWrap::isMainWindow() const
0388 {
0389     return (m_parentId.toInt() <= 0);
0390 }
0391 
0392 bool WindowInfoWrap::isChildWindow() const
0393 {
0394     return (m_parentId.toInt() > 0);
0395 }
0396 
0397 
0398 QString WindowInfoWrap::appName() const
0399 {
0400     return m_appName;
0401 }
0402 
0403 void WindowInfoWrap::setAppName(const QString &appName)
0404 {
0405     m_appName = appName;
0406 }
0407 
0408 QString WindowInfoWrap::display() const
0409 {
0410     return m_display;
0411 }
0412 
0413 void WindowInfoWrap::setDisplay(const QString &display)
0414 {
0415     m_display = display;
0416 }
0417 
0418 QIcon WindowInfoWrap::icon() const
0419 {
0420     return m_icon;
0421 }
0422 
0423 void WindowInfoWrap::setIcon(const QIcon &icon)
0424 {
0425     m_icon = icon;
0426 }
0427 
0428 QRect WindowInfoWrap::geometry() const
0429 {
0430     return m_geometry;
0431 }
0432 
0433 void WindowInfoWrap::setGeometry(const QRect &geometry)
0434 {
0435     m_geometry = geometry;
0436 }
0437 
0438 WindowId WindowInfoWrap::wid() const
0439 {
0440     return m_wid;
0441 }
0442 
0443 void WindowInfoWrap::setWid(const WindowId &wid)
0444 {
0445     m_wid = wid;
0446 }
0447 
0448 WindowId WindowInfoWrap::parentId() const
0449 {
0450     return m_parentId;
0451 }
0452 
0453 void WindowInfoWrap::setParentId(const WindowId &parentId)
0454 {
0455     if (m_wid == parentId) {
0456         return;
0457     }
0458 
0459     m_parentId = parentId;
0460 }
0461 
0462 QStringList WindowInfoWrap::desktops() const
0463 {
0464     return m_desktops;
0465 }
0466 
0467 void WindowInfoWrap::setDesktops(const QStringList &desktops)
0468 {
0469     m_desktops = desktops;
0470 }
0471 
0472 QStringList WindowInfoWrap::activities() const
0473 {
0474     return m_activities;
0475 }
0476 
0477 void WindowInfoWrap::setActivities(const QStringList &activities)
0478 {
0479     m_activities = activities;
0480 }
0481 
0482 bool WindowInfoWrap::isOnDesktop(const QString &desktop) const
0483 {
0484     return m_isOnAllDesktops || m_desktops.contains(desktop);
0485 }
0486 
0487 bool WindowInfoWrap::isOnActivity(const QString &activity) const
0488 {
0489     return m_isOnAllActivities || m_activities.contains(activity);
0490 }
0491 
0492 }
0493 }