Changeset View
Changeset View
Standalone View
Standalone View
geometry.cpp
Show First 20 Lines • Show All 1833 Lines • ▼ Show 20 Line(s) | 1833 | case SouthGravity: // middle of bottom border doesn't move | |||
---|---|---|---|---|---|
1834 | newx = (newx + width() / 2) - (w / 2); | 1834 | newx = (newx + width() / 2) - (w / 2); | ||
1835 | newy = newy + height() - h; | 1835 | newy = newy + height() - h; | ||
1836 | break; | 1836 | break; | ||
1837 | case SouthEastGravity: // bottom right corner doesn't move | 1837 | case SouthEastGravity: // bottom right corner doesn't move | ||
1838 | newx = newx + width() - w; | 1838 | newx = newx + width() - w; | ||
1839 | newy = newy + height() - h; | 1839 | newy = newy + height() - h; | ||
1840 | break; | 1840 | break; | ||
1841 | } | 1841 | } | ||
1842 | setGeometry(newx, newy, w, h, force); | 1842 | setGeometry(QRect(newx, newy, w, h), force); | ||
1843 | } | 1843 | } | ||
1844 | 1844 | | |||
1845 | // _NET_MOVERESIZE_WINDOW | 1845 | // _NET_MOVERESIZE_WINDOW | ||
1846 | void Client::NETMoveResizeWindow(int flags, int x, int y, int width, int height) | 1846 | void Client::NETMoveResizeWindow(int flags, int x, int y, int width, int height) | ||
1847 | { | 1847 | { | ||
1848 | int gravity = flags & 0xff; | 1848 | int gravity = flags & 0xff; | ||
1849 | int value_mask = 0; | 1849 | int value_mask = 0; | ||
1850 | if (flags & (1 << 8)) | 1850 | if (flags & (1 << 8)) | ||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 1912 | if (rules()->checkMaximize(MaximizeRestore) == MaximizeRestore && rules()->checkMaximize(MaximizeFull) != MaximizeRestore) | |||
1913 | return true; | 1913 | return true; | ||
1914 | return false; | 1914 | return false; | ||
1915 | } | 1915 | } | ||
1916 | 1916 | | |||
1917 | 1917 | | |||
1918 | /** | 1918 | /** | ||
1919 | * Reimplemented to inform the client about the new window position. | 1919 | * Reimplemented to inform the client about the new window position. | ||
1920 | */ | 1920 | */ | ||
1921 | void Client::setGeometry(int x, int y, int w, int h, ForceGeometry_t force) | 1921 | void Client::setGeometry(const QRect &rect, ForceGeometry_t force) | ||
1922 | { | 1922 | { | ||
1923 | // this code is also duplicated in Client::plainResize() | 1923 | // this code is also duplicated in Client::plainResize() | ||
1924 | // Ok, the shading geometry stuff. Generally, code doesn't care about shaded geometry, | 1924 | // Ok, the shading geometry stuff. Generally, code doesn't care about shaded geometry, | ||
1925 | // simply because there are too many places dealing with geometry. Those places | 1925 | // simply because there are too many places dealing with geometry. Those places | ||
1926 | // ignore shaded state and use normal geometry, which they usually should get | 1926 | // ignore shaded state and use normal geometry, which they usually should get | ||
1927 | // from adjustedSize(). Such geometry comes here, and if the window is shaded, | 1927 | // from adjustedSize(). Such geometry comes here, and if the window is shaded, | ||
1928 | // the geometry is used only for client_size, since that one is not used when | 1928 | // the geometry is used only for client_size, since that one is not used when | ||
1929 | // shading. Then the frame geometry is adjusted for the shaded geometry. | 1929 | // shading. Then the frame geometry is adjusted for the shaded geometry. | ||
1930 | // This gets more complicated in the case the code does only something like | 1930 | // This gets more complicated in the case the code does only something like | ||
1931 | // setGeometry( geometry()) - geometry() will return the shaded frame geometry. | 1931 | // setGeometry( geometry()) - geometry() will return the shaded frame geometry. | ||
1932 | // Such code is wrong and should be changed to handle the case when the window is shaded, | 1932 | // Such code is wrong and should be changed to handle the case when the window is shaded, | ||
1933 | // for example using Client::clientSize() | 1933 | // for example using Client::clientSize() | ||
1934 | 1934 | | |||
1935 | const QMargins frameMargins(borderLeft(), borderTop(), borderRight(), borderBottom()); | ||||
1936 | | ||||
1937 | QRect geometry = rect; | ||||
1938 | | ||||
1935 | if (shade_geometry_change) | 1939 | if (shade_geometry_change) | ||
1936 | ; // nothing | 1940 | ; // nothing | ||
1937 | else if (isShade()) { | 1941 | else if (isShade()) { | ||
1938 | if (h == borderTop() + borderBottom()) { | 1942 | if (geometry.height() == borderTop() + borderBottom()) { | ||
1939 | qCDebug(KWIN_CORE) << "Shaded geometry passed for size:"; | 1943 | qCDebug(KWIN_CORE) << "Shaded geometry passed for size:"; | ||
1940 | } else { | 1944 | } else { | ||
1941 | client_size = QSize(w - borderLeft() - borderRight(), h - borderTop() - borderBottom()); | 1945 | client_size = rect.marginsRemoved(frameMargins).size(); | ||
1942 | h = borderTop() + borderBottom(); | 1946 | geometry.setHeight(borderTop() + borderBottom()); | ||
1943 | } | 1947 | } | ||
1944 | } else { | 1948 | } else { | ||
1945 | client_size = QSize(w - borderLeft() - borderRight(), h - borderTop() - borderBottom()); | 1949 | client_size = rect.marginsRemoved(frameMargins).size(); | ||
1946 | } | 1950 | } | ||
1947 | QRect g(x, y, w, h); | 1951 | if (!areGeometryUpdatesBlocked() && geometry != rules()->checkGeometry(geometry)) { | ||
1948 | if (!areGeometryUpdatesBlocked() && g != rules()->checkGeometry(g)) { | 1952 | qCDebug(KWIN_CORE) << "forced geometry fail:" << geometry << ":" << rules()->checkGeometry(geometry); | ||
1949 | qCDebug(KWIN_CORE) << "forced geometry fail:" << g << ":" << rules()->checkGeometry(g); | | |||
1950 | } | 1953 | } | ||
1951 | if (force == NormalGeometrySet && geom == g && pendingGeometryUpdate() == PendingGeometryNone) | 1954 | if (force == NormalGeometrySet && geom == geometry && pendingGeometryUpdate() == PendingGeometryNone) | ||
1952 | return; | 1955 | return; | ||
1953 | geom = g; | 1956 | geom = geometry; | ||
1954 | if (areGeometryUpdatesBlocked()) { | 1957 | if (areGeometryUpdatesBlocked()) { | ||
1955 | if (pendingGeometryUpdate() == PendingGeometryForced) | 1958 | if (pendingGeometryUpdate() == PendingGeometryForced) | ||
1956 | {} // maximum, nothing needed | 1959 | {} // maximum, nothing needed | ||
1957 | else if (force == ForceGeometrySet) | 1960 | else if (force == ForceGeometrySet) | ||
1958 | setPendingGeometryUpdate(PendingGeometryForced); | 1961 | setPendingGeometryUpdate(PendingGeometryForced); | ||
1959 | else | 1962 | else | ||
1960 | setPendingGeometryUpdate(PendingGeometryNormal); | 1963 | setPendingGeometryUpdate(PendingGeometryNormal); | ||
1961 | return; | 1964 | return; | ||
1962 | } | 1965 | } | ||
1963 | QSize oldClientSize = m_frame.geometry().size(); | 1966 | QSize oldClientSize = m_frame.geometry().size(); | ||
1964 | bool resized = (geometryBeforeUpdateBlocking().size() != geom.size() || pendingGeometryUpdate() == PendingGeometryForced); | 1967 | bool resized = (geometryBeforeUpdateBlocking().size() != geom.size() || pendingGeometryUpdate() == PendingGeometryForced); | ||
1965 | if (resized) { | 1968 | if (resized) { | ||
1966 | resizeDecoration(); | 1969 | resizeDecoration(); | ||
1967 | m_frame.setGeometry(x, y, w, h); | 1970 | m_frame.setGeometry(geometry); | ||
1968 | if (!isShade()) { | 1971 | if (!isShade()) { | ||
1969 | QSize cs = clientSize(); | 1972 | QSize cs = clientSize(); | ||
1970 | m_wrapper.setGeometry(QRect(clientPos(), cs)); | 1973 | m_wrapper.setGeometry(QRect(clientPos(), cs)); | ||
1971 | if (!isResize() || syncRequest.counter == XCB_NONE) | 1974 | if (!isResize() || syncRequest.counter == XCB_NONE) | ||
1972 | m_client.setGeometry(0, 0, cs.width(), cs.height()); | 1975 | m_client.setGeometry(0, 0, cs.width(), cs.height()); | ||
1973 | // SELI - won't this be too expensive? | 1976 | // SELI - won't this be too expensive? | ||
1974 | // THOMAS - yes, but gtk+ clients will not resize without ... | 1977 | // THOMAS - yes, but gtk+ clients will not resize without ... | ||
1975 | sendSyntheticConfigureNotify(); | 1978 | sendSyntheticConfigureNotify(); | ||
1976 | } | 1979 | } | ||
1977 | updateShape(); | 1980 | updateShape(); | ||
1978 | } else { | 1981 | } else { | ||
1979 | if (isMoveResize()) { | 1982 | if (isMoveResize()) { | ||
1980 | if (compositing()) // Defer the X update until we leave this mode | 1983 | if (compositing()) // Defer the X update until we leave this mode | ||
1981 | needsXWindowMove = true; | 1984 | needsXWindowMove = true; | ||
1982 | else | 1985 | else | ||
1983 | m_frame.move(x, y); // sendSyntheticConfigureNotify() on finish shall be sufficient | 1986 | m_frame.move(geometry.topLeft()); // sendSyntheticConfigureNotify() on finish shall be sufficient | ||
1984 | } else { | 1987 | } else { | ||
1985 | m_frame.move(x, y); | 1988 | m_frame.move(geometry.topLeft()); | ||
1986 | sendSyntheticConfigureNotify(); | 1989 | sendSyntheticConfigureNotify(); | ||
1987 | } | 1990 | } | ||
1988 | 1991 | | |||
1989 | // Unconditionally move the input window: it won't affect rendering | 1992 | // Unconditionally move the input window: it won't affect rendering | ||
1990 | m_decoInputExtent.move(QPoint(x, y) + inputPos()); | 1993 | m_decoInputExtent.move(geometry.topLeft() + inputPos()); | ||
1991 | } | 1994 | } | ||
1992 | updateWindowRules(Rules::Position|Rules::Size); | 1995 | updateWindowRules(Rules::Position|Rules::Size); | ||
1993 | 1996 | | |||
1994 | // keep track of old maximize mode | 1997 | // keep track of old maximize mode | ||
1995 | // to detect changes | 1998 | // to detect changes | ||
1996 | screens()->setCurrent(this); | 1999 | screens()->setCurrent(this); | ||
1997 | workspace()->updateStackingOrder(); | 2000 | workspace()->updateStackingOrder(); | ||
1998 | 2001 | | |||
1999 | // need to regenerate decoration pixmaps when either | 2002 | // need to regenerate decoration pixmaps when either | ||
2000 | // - size is changed | 2003 | // - size is changed | ||
2001 | // - maximize mode is changed to MaximizeRestore, when size unchanged | 2004 | // - maximize mode is changed to MaximizeRestore, when size unchanged | ||
2002 | // which can happen when untabbing maximized windows | 2005 | // which can happen when untabbing maximized windows | ||
2003 | if (resized) { | 2006 | if (resized) { | ||
2004 | if (oldClientSize != QSize(w,h)) | 2007 | if (oldClientSize != geometry.size()) | ||
2005 | discardWindowPixmap(); | 2008 | discardWindowPixmap(); | ||
2006 | } | 2009 | } | ||
2007 | emit geometryShapeChanged(this, geometryBeforeUpdateBlocking()); | 2010 | emit geometryShapeChanged(this, geometryBeforeUpdateBlocking()); | ||
2008 | addRepaintDuringGeometryUpdates(); | 2011 | addRepaintDuringGeometryUpdates(); | ||
2009 | updateGeometryBeforeUpdateBlocking(); | 2012 | updateGeometryBeforeUpdateBlocking(); | ||
2010 | 2013 | | |||
2011 | // Update states of all other windows in this group | 2014 | // Update states of all other windows in this group | ||
2012 | if (tabGroup()) | 2015 | if (tabGroup()) | ||
▲ Show 20 Lines • Show All 1430 Lines • Show Last 20 Lines |