///////////////////////////////////////////////////////
| 189 | |
| 190 | //////////////////////////////////////////////////////////// |
| 191 | void ClipboardImpl::processEvent(XEvent& windowEvent) |
| 192 | { |
| 193 | switch (windowEvent.type) |
| 194 | { |
| 195 | case SelectionClear: |
| 196 | { |
| 197 | // We don't have any resources we need to clean up |
| 198 | // when losing selection ownership so we don't do |
| 199 | // anything when we receive SelectionClear |
| 200 | // We will still respond to any future SelectionRequest |
| 201 | // events since doing so doesn't really do any harm |
| 202 | break; |
| 203 | } |
| 204 | case SelectionNotify: |
| 205 | { |
| 206 | // Notification that the current selection owner |
| 207 | // has responded to our request |
| 208 | |
| 209 | const XSelectionEvent& selectionEvent = windowEvent.xselection; |
| 210 | |
| 211 | m_clipboardContents.clear(); |
| 212 | |
| 213 | // If retrieving the selection fails or conversion is unsuccessful |
| 214 | // we leave the contents of the clipboard empty since we don't |
| 215 | // own it and we don't know what it could currently be |
| 216 | if ((selectionEvent.property == None) || (selectionEvent.selection != m_clipboard)) |
| 217 | break; |
| 218 | |
| 219 | Atom type = 0; |
| 220 | int format = 0; |
| 221 | unsigned long items = 0; |
| 222 | unsigned long remainingBytes = 0; |
| 223 | unsigned char* data = nullptr; |
| 224 | |
| 225 | // The selection owner should have wrote the selection |
| 226 | // data to the specified window property |
| 227 | const int result = XGetWindowProperty(m_display.get(), |
| 228 | m_window, |
| 229 | m_targetProperty, |
| 230 | 0, |
| 231 | 0x7fffffff, |
| 232 | False, |
| 233 | AnyPropertyType, |
| 234 | &type, |
| 235 | &format, |
| 236 | &items, |
| 237 | &remainingBytes, |
| 238 | &data); |
| 239 | |
| 240 | if (result == Success) |
| 241 | { |
| 242 | // We don't support INCR for now |
| 243 | // It is very unlikely that this will be returned |
| 244 | // for purely text data transfer anyway |
| 245 | if (type != getAtom("INCR", false)) |
| 246 | { |
| 247 | // Only copy the data if the format is what we expect |
| 248 | if ((type == m_utf8String) && (format == 8)) |
nothing calls this directly
no test coverage detected