Changeset View
Changeset View
Standalone View
Standalone View
workspace.cpp
Show First 20 Lines • Show All 1824 Lines • ▼ Show 20 Line(s) | 1823 | { | |||
---|---|---|---|---|---|
1825 | 1825 | | |||
1826 | markXStackingOrderAsDirty(); | 1826 | markXStackingOrderAsDirty(); | ||
1827 | updateStackingOrder(true); | 1827 | updateStackingOrder(true); | ||
1828 | updateClientArea(); | 1828 | updateClientArea(); | ||
1829 | 1829 | | |||
1830 | emit internalClientRemoved(client); | 1830 | emit internalClientRemoved(client); | ||
1831 | } | 1831 | } | ||
1832 | 1832 | | |||
1833 | Group* Workspace::findGroup(xcb_window_t leader) const | ||||
1834 | { | ||||
1835 | Q_ASSERT(leader != XCB_WINDOW_NONE); | ||||
1836 | for (auto it = groups.constBegin(); | ||||
1837 | it != groups.constEnd(); | ||||
1838 | ++it) | ||||
1839 | if ((*it)->leader() == leader) | ||||
1840 | return *it; | ||||
1841 | return nullptr; | ||||
1842 | } | ||||
1843 | | ||||
1844 | // Client is group transient, but has no group set. Try to find | ||||
1845 | // group with windows with the same client leader. | ||||
1846 | Group* Workspace::findClientLeaderGroup(const X11Client *c) const | ||||
1847 | { | ||||
1848 | Group* ret = nullptr; | ||||
1849 | for (auto it = clients.constBegin(); | ||||
1850 | it != clients.constEnd(); | ||||
1851 | ++it) { | ||||
1852 | if (*it == c) | ||||
1853 | continue; | ||||
1854 | if ((*it)->wmClientLeader() == c->wmClientLeader()) { | ||||
1855 | if (ret == nullptr || ret == (*it)->group()) | ||||
1856 | ret = (*it)->group(); | ||||
1857 | else { | ||||
1858 | // There are already two groups with the same client leader. | ||||
1859 | // This most probably means the app uses group transients without | ||||
1860 | // setting group for its windows. Merging the two groups is a bad | ||||
1861 | // hack, but there's no really good solution for this case. | ||||
1862 | QList<X11Client *> old_group = (*it)->group()->members(); | ||||
1863 | // old_group autodeletes when being empty | ||||
1864 | for (int pos = 0; | ||||
1865 | pos < old_group.count(); | ||||
1866 | ++pos) { | ||||
1867 | X11Client *tmp = old_group[ pos ]; | ||||
1868 | if (tmp != c) | ||||
1869 | tmp->changeClientLeaderGroup(ret); | ||||
1870 | } | ||||
1871 | } | ||||
1872 | } | ||||
1873 | } | ||||
1874 | return ret; | ||||
1875 | } | ||||
1876 | | ||||
1877 | void Workspace::updateMinimizedOfTransients(AbstractClient* c) | ||||
1878 | { | ||||
1879 | // if mainwindow is minimized or shaded, minimize transients too | ||||
1880 | if (c->isMinimized()) { | ||||
1881 | for (auto it = c->transients().constBegin(); | ||||
1882 | it != c->transients().constEnd(); | ||||
1883 | ++it) { | ||||
1884 | if ((*it)->isModal()) | ||||
1885 | continue; // there's no reason to hide modal dialogs with the main client | ||||
1886 | // but to keep them to eg. watch progress or whatever | ||||
1887 | if (!(*it)->isMinimized()) { | ||||
1888 | (*it)->minimize(); | ||||
1889 | updateMinimizedOfTransients((*it)); | ||||
1890 | } | ||||
1891 | } | ||||
1892 | if (c->isModal()) { // if a modal dialog is minimized, minimize its mainwindow too | ||||
1893 | foreach (AbstractClient * c2, c->mainClients()) | ||||
1894 | c2->minimize(); | ||||
1895 | } | ||||
1896 | } else { | ||||
1897 | // else unmiminize the transients | ||||
1898 | for (auto it = c->transients().constBegin(); | ||||
1899 | it != c->transients().constEnd(); | ||||
1900 | ++it) { | ||||
1901 | if ((*it)->isMinimized()) { | ||||
1902 | (*it)->unminimize(); | ||||
1903 | updateMinimizedOfTransients((*it)); | ||||
1904 | } | ||||
1905 | } | ||||
1906 | if (c->isModal()) { | ||||
1907 | foreach (AbstractClient * c2, c->mainClients()) | ||||
1908 | c2->unminimize(); | ||||
1909 | } | ||||
1910 | } | ||||
1911 | } | ||||
1912 | | ||||
1913 | | ||||
1914 | /** | ||||
1915 | * Sets the client \a c's transient windows' on_all_desktops property to \a on_all_desktops. | ||||
1916 | */ | ||||
1917 | void Workspace::updateOnAllDesktopsOfTransients(AbstractClient* c) | ||||
1918 | { | ||||
1919 | for (auto it = c->transients().constBegin(); | ||||
1920 | it != c->transients().constEnd(); | ||||
1921 | ++it) { | ||||
1922 | if ((*it)->isOnAllDesktops() != c->isOnAllDesktops()) | ||||
1923 | (*it)->setOnAllDesktops(c->isOnAllDesktops()); | ||||
1924 | } | ||||
1925 | } | ||||
1926 | | ||||
1927 | // A new window has been mapped. Check if it's not a mainwindow for some already existing transient window. | ||||
1928 | void Workspace::checkTransients(xcb_window_t w) | ||||
1929 | { | ||||
1930 | for (auto it = clients.constBegin(); | ||||
1931 | it != clients.constEnd(); | ||||
1932 | ++it) | ||||
1933 | (*it)->checkTransient(w); | ||||
1934 | } | ||||
1935 | | ||||
1833 | } // namespace | 1936 | } // namespace |