Mercurial > projects > dynamin
comparison dynamin/gui/x_window.d @ 34:e4d290aaa7ed
Use pointers to X event structs to avoid copying them.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Sat, 25 Jul 2009 22:50:45 -0500 |
parents | 329ce1001936 |
children | 7adc733aca2d |
comparison
equal
deleted
inserted
replaced
33:329ce1001936 | 34:e4d290aaa7ed |
---|---|
275 //if(c is null) | 275 //if(c is null) |
276 // continue; | 276 // continue; |
277 //{{{ helper functions | 277 //{{{ helper functions |
278 void createMouseEvent(void delegate(MouseEventArgs args) func) { | 278 void createMouseEvent(void delegate(MouseEventArgs args) func) { |
279 MouseButton button; | 279 MouseButton button; |
280 auto buttonEv = ev.xbutton; | 280 auto buttonEv = &ev.xbutton; |
281 switch(buttonEv.button) { | 281 switch(buttonEv.button) { |
282 case 1: button = MouseButton.Left; break; | 282 case 1: button = MouseButton.Left; break; |
283 case 2: button = MouseButton.Middle; break; | 283 case 2: button = MouseButton.Middle; break; |
284 case 3: button = MouseButton.Right; break; | 284 case 3: button = MouseButton.Right; break; |
285 default: return; | 285 default: return; |
302 break; | 302 break; |
303 case DestroyNotify: | 303 case DestroyNotify: |
304 setControl(evWindow, null); | 304 setControl(evWindow, null); |
305 break; | 305 break; |
306 case ClientMessage: | 306 case ClientMessage: |
307 auto clientEv = ev.xclient; | 307 auto clientEv = &ev.xclient; |
308 if(clientEv.message_type != XA.WM_PROTOCOLS) | 308 if(clientEv.message_type != XA.WM_PROTOCOLS) |
309 break; | 309 break; |
310 if(clientEv.data.l[0] == XA.WM_DELETE_WINDOW) { | 310 if(clientEv.data.l[0] == XA.WM_DELETE_WINDOW) { |
311 XDestroyWindow(evDisplay, evWindow); | 311 XDestroyWindow(evDisplay, evWindow); |
312 return; // TODO: check event, and figure out what to do | 312 return; // TODO: check event, and figure out what to do |
356 break; | 356 break; |
357 case ButtonRelease: | 357 case ButtonRelease: |
358 createMouseEvent((MouseEventArgs args) { c.mouseUp(args); }); | 358 createMouseEvent((MouseEventArgs args) { c.mouseUp(args); }); |
359 break; | 359 break; |
360 case MotionNotify: | 360 case MotionNotify: |
361 auto motionEv = ev.xmotion; | 361 auto motionEv = &ev.xmotion; |
362 Control captor = getCaptorControl(); | 362 Control captor = getCaptorControl(); |
363 Point pt = Point(motionEv.x+c.borderSize.left, motionEv.y+c.borderSize.top); | 363 Point pt = Point(motionEv.x+c.borderSize.left, motionEv.y+c.borderSize.top); |
364 if(captor) | 364 if(captor) |
365 pt = c.contentToContent(pt, captor); | 365 pt = c.contentToContent(pt, captor); |
366 else | 366 else |
371 captor.mouseDragged(args); | 371 captor.mouseDragged(args); |
372 } else | 372 } else |
373 captor.mouseMoved(args); | 373 captor.mouseMoved(args); |
374 break; | 374 break; |
375 case EnterNotify: | 375 case EnterNotify: |
376 auto enterEv = ev.xcrossing; | 376 auto enterEv = &ev.xcrossing; |
377 scope args = new MouseEventArgs(enterEv.x+c.borderSize.left, | 377 scope args = new MouseEventArgs(enterEv.x+c.borderSize.left, |
378 enterEv.y+c.borderSize.top, MouseButton.None); | 378 enterEv.y+c.borderSize.top, MouseButton.None); |
379 c.mouseMoved(args); | 379 c.mouseMoved(args); |
380 break; | 380 break; |
381 case LeaveNotify: | 381 case LeaveNotify: |
388 case Expose: | 388 case Expose: |
389 auto exposeEv = &ev.xexpose; | 389 auto exposeEv = &ev.xexpose; |
390 PaintQueue.add(c, exposeEv.x, exposeEv.y, exposeEv.width, exposeEv.height); | 390 PaintQueue.add(c, exposeEv.x, exposeEv.y, exposeEv.width, exposeEv.height); |
391 break; | 391 break; |
392 case PropertyNotify: | 392 case PropertyNotify: |
393 auto propertyEv = ev.xproperty; | 393 auto propertyEv = &ev.xproperty; |
394 if(propertyEv.atom == XA._NET_FRAME_EXTENTS && | 394 if(propertyEv.atom == XA._NET_FRAME_EXTENTS && |
395 propertyEv.state != PropertyDelete) | 395 propertyEv.state != PropertyDelete) |
396 c.backend_nativeToBorderSize(); | 396 c.backend_nativeToBorderSize(); |
397 break; | 397 break; |
398 case ConfigureNotify: | 398 case ConfigureNotify: |
399 auto configureEv = ev.xconfigure; | 399 auto configureEv = &ev.xconfigure; |
400 c.repaint(); | 400 c.repaint(); |
401 c.backend_nativeToLocationSize(); | 401 c.backend_nativeToLocationSize(); |
402 break; | 402 break; |
403 case SelectionRequest: | 403 case SelectionRequest: |
404 auto selReqEv = ev.xselectionrequest; | 404 auto selReqEv = &ev.xselectionrequest; |
405 XEvent fullEv; | 405 XEvent fullEv; |
406 auto selEv = &fullEv.xselection; | 406 auto selEv = &fullEv.xselection; |
407 selEv.type = SelectionNotify; | 407 selEv.type = SelectionNotify; |
408 selEv.requestor = selReqEv.requestor; | 408 selEv.requestor = selReqEv.requestor; |
409 selEv.selection = selReqEv.selection; | 409 selEv.selection = selReqEv.selection; |