LOGIN / SIGN UP
2 Author: Claes Nästén
Date: Sun Mar 07 23:16:16 +0100 2010
Subject: Split up handleClientMessage a bit before looking into #245

src/Frame.cc
 
2063 @@ -2063,79 +2063,14 @@
2063 }
2064 }
2065
2066 //! @brief
2067 /**
2068 * Handle client message.
2069 */
2070 void
2071 Frame::handleClientMessage(XClientMessageEvent *ev, Client *client)
2072 {
2073 StateAction sa;
2074
2075 if (ev->message_type == Atoms::getAtom(STATE)) {
2076 if (ev->data.l[0]== NET_WM_STATE_REMOVE) {
2077 sa = STATE_UNSET;
2078 } else if (ev->data.l[0]== NET_WM_STATE_ADD) {
2079 sa = STATE_SET;
2080 } else if (ev->data.l[0]== NET_WM_STATE_TOGGLE) {
2081 sa = STATE_TOGGLE;
2082 } else {
2083 #ifdef DEBUG
2084 cerr << __FILE__ << "@" << __LINE__ << ": "
2085 << "None of StateAdd, StateRemove or StateToggle." << endl;
2086 #endif // DEBUG
2087 return;
2088 }
2089
2090 #define IS_STATE(S) ((ev->data.l[1] == long(Atoms::getAtom(S))) || (ev->data.l[2] == long(Atoms::getAtom(S))))
2091
2092 // actions that only is going to be applied on the active client
2093 if (client == _client) {
2094 // there is no modal support in pekwm yet
2095 // if (IS_STATE(STATE_MODAL)) {
2096 // is_modal=true;
2097 // }
2098 if (IS_STATE(STATE_STICKY)) {
2099 setStateSticky(sa);
2100 }
2101 if (IS_STATE(STATE_MAXIMIZED_HORZ)
2102 && ! client->isCfgDeny(CFG_DENY_STATE_MAXIMIZED_HORZ)) {
2103 setStateMaximized(sa, true, false, false);
2104 }
2105 if (IS_STATE(STATE_MAXIMIZED_VERT)
2106 && ! client->isCfgDeny(CFG_DENY_STATE_MAXIMIZED_VERT)) {
2107 setStateMaximized(sa, false, true, false);
2108 }
2109 if (IS_STATE(STATE_SHADED)) {
2110 setShaded(sa);
2111 }
2112 if (IS_STATE(STATE_HIDDEN)
2113 && ! client->isCfgDeny(CFG_DENY_STATE_HIDDEN)) {
2114 setStateIconified(sa);
2115 }
2116 if (IS_STATE(STATE_FULLSCREEN)
2117 && ! client->isCfgDeny(CFG_DENY_STATE_FULLSCREEN)) {
2118 setStateFullscreen(sa);
2119 }
2120 if (IS_STATE(STATE_ABOVE)
2121 && ! client->isCfgDeny(CFG_DENY_STATE_ABOVE)) {
2122 setStateAlwaysOnTop(sa);
2123 }
2124 if (IS_STATE(STATE_BELOW)
2125 && ! client->isCfgDeny(CFG_DENY_STATE_BELOW)) {
2126 setStateAlwaysBelow(sa);
2127 }
2128 }
2129
2130 if (IS_STATE(STATE_SKIP_TASKBAR)) {
2131 client->setStateSkip(sa, SKIP_TASKBAR);
2132 }
2133 if (IS_STATE(STATE_SKIP_PAGER)) {
2134 client->setStateSkip(sa, SKIP_PAGER);
2135 }
2136 if (IS_STATE(STATE_DEMANDS_ATTENTION)) {
2137 client->setStateDemandsAttention(sa, true);
2138 }
2139
2140 client->updateEwmhStates();
2141
2142 handleClientStateMessage(ev, client);
2143 } else if (ev->message_type == Atoms::getAtom(NET_ACTIVE_WINDOW)) {
2144 if (! client->isCfgDeny(CFG_DENY_ACTIVE_WINDOW)) {
2145 // Active child if it's not the active child
...  
2102 @@ -2167,9 +2102,105 @@
2102 iconify();
2103 }
2104 }
2170 #undef IS_STATE
2106 }
2107
2108 /**
2109 * Handle _NET_WM_STATE atom.
2110 */
2111 void
2112 Frame::handleClientStateMessage(XClientMessageEvent *ev, Client *client)
2113 {
2114 StateAction sa = getStateActionFromMessage(ev);
2115 handleStateAtom(sa, ev->data.l[1], client);
2116 handleStateAtom(sa, ev->data.l[2], client);
2117 client->updateEwmhStates();
2118 }
2119
2120 /**
2121 * Get StateAction from NET_WM atom.
2122 */
2123 StateAction
2124 Frame::getStateActionFromMessage(XClientMessageEvent *ev)
2125 {
2126 StateAction sa = STATE_SET;
2127 if (ev->data.l[0]== NET_WM_STATE_REMOVE) {
2128 sa = STATE_UNSET;
2129 } else if (ev->data.l[0]== NET_WM_STATE_ADD) {
2130 sa = STATE_SET;
2131 } else if (ev->data.l[0]== NET_WM_STATE_TOGGLE) {
2132 sa = STATE_TOGGLE;
2133 }
2134 return sa;
2135 }
2136
2137 /**
2138 * Handle state atom for client.
2139 */
2140 void
2141 Frame::handleStateAtom(StateAction sa, long atom, Client *client)
2142 {
2143 if (client == _client) {
2144 handleCurrentClientStateAtom(sa, atom, client);
2145 }
2146
2147 switch (atom) {
2148 case STATE_SKIP_TASKBAR:
2149 client->setStateSkip(sa, SKIP_TASKBAR);
2150 break;
2151 case STATE_SKIP_PAGER:
2152 client->setStateSkip(sa, SKIP_PAGER);
2153 break;
2154 case STATE_DEMANDS_ATTENTION:
2155 client->setStateDemandsAttention(sa, true);
2156 break;
2157 }
2158 }
2159
2160 /**
2161 * Handle state atom for actions that apply only on active client.
2162 */
2163 void
2164 Frame::handleCurrentClientStateAtom(StateAction sa, long atom, Client *client)
2165 {
2166 switch (atom) {
2167 case STATE_STICKY:
2168 setStateSticky(sa);
2169 break;
2170 case STATE_MAXIMIZED_HORZ:
2171 if (! client->isCfgDeny(CFG_DENY_STATE_MAXIMIZED_HORZ)) {
2172 setStateMaximized(sa, true, false, false);
2173 }
2174 break;
2175 case STATE_MAXIMIZED_VERT:
2176 if (! client->isCfgDeny(CFG_DENY_STATE_MAXIMIZED_VERT)) {
2177 setStateMaximized(sa, false, true, false);
2178 }
2179 break;
2180 case STATE_SHADED:
2181 setShaded(sa);
2182 break;
2183 case STATE_HIDDEN:
2184 if (! client->isCfgDeny(CFG_DENY_STATE_HIDDEN)) {
2185 setStateIconified(sa);
2186 }
2187 break;
2188 case STATE_FULLSCREEN:
2189 if (! client->isCfgDeny(CFG_DENY_STATE_FULLSCREEN)) {
2190 setStateFullscreen(sa);
2191 }
2192 break;
2193 case STATE_ABOVE:
2194 if (! client->isCfgDeny(CFG_DENY_STATE_ABOVE)) {
2195 setStateAlwaysOnTop(sa);
2196 }
2197 break;
2198 case STATE_BELOW:
2199 if (! client->isCfgDeny(CFG_DENY_STATE_BELOW)) {
2200 setStateAlwaysBelow(sa);
2201 }
2202 break;
2203 }
2204 }
2205
2206 //! @brief
2207 void
...