Merge lp:~glcompbench-dev/glcompbench/bug-984058 into lp:glcompbench

Proposed by Jesse Barker
Status: Merged
Merged at revision: 81
Proposed branch: lp:~glcompbench-dev/glcompbench/bug-984058
Merge into: lp:glcompbench
Diff against target: 152 lines (+26/-15)
4 files modified
src/composite-canvas-egl.cc (+1/-0)
src/composite-canvas-glx.cc (+1/-0)
src/composite-canvas.cc (+19/-10)
src/composite-window.cc (+5/-5)
To merge this branch: bzr merge lp:~glcompbench-dev/glcompbench/bug-984058
Reviewer Review Type Date Requested Status
Alexandros Frantzis Pending
Review via email: mp+102594@code.launchpad.net

Description of the change

Canvas: Given the asynchronous nature of event dispatch, we must check for whether we might be handling events for a window that has already been destroyed. So, once we get the next event from the queue, we need to extract the window ID from the event struct, then check to see if there's a pending DestroyNotify event for our window. If so, we remove it from our managed window list, and, if our managed window list was command-line supplied, remove the ID from the list parsed by the option handling code so other canvases don't trip over it. If not, it's business as usual.

To post a comment you must log in.
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

I don't see a need for CompositeCanvas::get_window_from_xevent(), we can just use event.xany.window for all events. Other than that, it looks good.

84. By Jesse Barker

Canvas: Slightly less intrusive version of the logic used to extract the window
ID from the event structure.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/composite-canvas-egl.cc'
--- src/composite-canvas-egl.cc 2011-12-12 13:16:47 +0000
+++ src/composite-canvas-egl.cc 2012-04-19 14:20:25 +0000
@@ -301,6 +301,7 @@
301301
302 std::stringstream ss;302 std::stringstream ss;
303303
304 ss << " EGL " << eglQueryString(egl_display_, EGL_VERSION) << std::endl;
304 ss << " OpenGL Information" << std::endl;305 ss << " OpenGL Information" << std::endl;
305 ss << " GL_VENDOR: " << glGetString(GL_VENDOR) << std::endl;306 ss << " GL_VENDOR: " << glGetString(GL_VENDOR) << std::endl;
306 ss << " GL_RENDERER: " << glGetString(GL_RENDERER) << std::endl;307 ss << " GL_RENDERER: " << glGetString(GL_RENDERER) << std::endl;
307308
=== modified file 'src/composite-canvas-glx.cc'
--- src/composite-canvas-glx.cc 2011-12-09 16:09:11 +0000
+++ src/composite-canvas-glx.cc 2012-04-19 14:20:25 +0000
@@ -254,6 +254,7 @@
254254
255 std::stringstream ss;255 std::stringstream ss;
256256
257 ss << " GLX " << glXGetClientString(xdpy_, GLX_VERSION) << std::endl;
257 ss << " OpenGL Information" << std::endl;258 ss << " OpenGL Information" << std::endl;
258 ss << " GL_VENDOR: " << glGetString(GL_VENDOR) << std::endl;259 ss << " GL_VENDOR: " << glGetString(GL_VENDOR) << std::endl;
259 ss << " GL_RENDERER: " << glGetString(GL_RENDERER) << std::endl;260 ss << " GL_RENDERER: " << glGetString(GL_RENDERER) << std::endl;
260261
=== modified file 'src/composite-canvas.cc'
--- src/composite-canvas.cc 2012-03-09 03:58:54 +0000
+++ src/composite-canvas.cc 2012-04-19 14:20:25 +0000
@@ -368,7 +368,6 @@
368{368{
369 XEvent event;369 XEvent event;
370 bool needs_redraw(false);370 bool needs_redraw(false);
371 Window window(0);
372 Profiler::ScopedSamples xevent_scoped(CompositeCanvas::profiler_xevent_pair());371 Profiler::ScopedSamples xevent_scoped(CompositeCanvas::profiler_xevent_pair());
373372
374 if (Options::idle_redraw && !XPending(xdpy_))373 if (Options::idle_redraw && !XPending(xdpy_))
@@ -376,16 +375,32 @@
376375
377 XNextEvent(xdpy_, &event);376 XNextEvent(xdpy_, &event);
378377
379 if (event.type == damage_event_ + XDamageNotify) {378 // We have to allow for the possibility that the window has actually
379 // been destroyed, but we saw the current event before the destroy event.
380 // So, check for a queued-up DestroyNotify event for our window before
381 // trying to update (bug 984058).
382 Window window = event.xany.window;
383 XEvent destroyEvent;
384 if (True == XCheckTypedWindowEvent(xdpy_, window, DestroyNotify, &destroyEvent)) {
385 Log::debug("--- Destroy Win: 0x%x\n", window);
386 remove_window(window);
387 // If we're using a user provided list of windows, prune this one
388 // out to make sure we don't create any new objects with a bad
389 // window list.
390 if (!Options::window_ids.empty())
391 {
392 Options::window_ids.remove(window);
393 }
394 needs_redraw = true;
395 }
396 else if (event.type == damage_event_ + XDamageNotify) {
380 // This is a little ugly, but then so is violating strict aliasing397 // This is a little ugly, but then so is violating strict aliasing
381 // to make the hideous cast to reference this as an XDamageNotifyEvent.398 // to make the hideous cast to reference this as an XDamageNotifyEvent.
382 window = event.xany.window;
383 Log::debug("### Damage Win: 0x%x\n", window);399 Log::debug("### Damage Win: 0x%x\n", window);
384 handle_damage(window);400 handle_damage(window);
385 needs_redraw = true;401 needs_redraw = true;
386 }402 }
387 else if (event.type == ConfigureNotify) {403 else if (event.type == ConfigureNotify) {
388 window = event.xconfigure.window;
389 Log::debug("Configure Win: 0x%x %d x %d\n",404 Log::debug("Configure Win: 0x%x %d x %d\n",
390 window,405 window,
391 width_, height_);406 width_, height_);
@@ -398,24 +413,20 @@
398 update_window(window);413 update_window(window);
399 }414 }
400 else if (event.type == Expose) {415 else if (event.type == Expose) {
401 window = event.xexpose.window;
402 Log::debug("Expose Win: 0x%x\n", window);416 Log::debug("Expose Win: 0x%x\n", window);
403 needs_redraw = true;417 needs_redraw = true;
404 }418 }
405 else if (event.type == UnmapNotify) {419 else if (event.type == UnmapNotify) {
406 window = event.xunmap.window;
407 Log::debug("--- Unmap Win: 0x%x\n", window);420 Log::debug("--- Unmap Win: 0x%x\n", window);
408 update_window(window);421 update_window(window);
409 needs_redraw = true;422 needs_redraw = true;
410 }423 }
411 else if (event.type == MapNotify) {424 else if (event.type == MapNotify) {
412 window = event.xmap.window;
413 Log::debug("+++ Map Win: 0x%x\n", window);425 Log::debug("+++ Map Win: 0x%x\n", window);
414 update_window(window);426 update_window(window);
415 needs_redraw = true;427 needs_redraw = true;
416 }428 }
417 else if (event.type == ReparentNotify) {429 else if (event.type == ReparentNotify) {
418 window = event.xreparent.window;
419 Window parent = event.xreparent.parent;430 Window parent = event.xreparent.parent;
420 Log::debug("+++ Reparent Win: 0x%x Parent: 0x%x\n", parent);431 Log::debug("+++ Reparent Win: 0x%x Parent: 0x%x\n", parent);
421 if (parent == root_)432 if (parent == root_)
@@ -425,13 +436,11 @@
425 needs_redraw = true;436 needs_redraw = true;
426 }437 }
427 else if (event.type == CreateNotify) {438 else if (event.type == CreateNotify) {
428 window = event.xcreatewindow.window;
429 Log::debug("+++ Add Win: 0x%x Parent: 0x%x\n",439 Log::debug("+++ Add Win: 0x%x Parent: 0x%x\n",
430 window, event.xcreatewindow.parent);440 window, event.xcreatewindow.parent);
431 add_window(window);441 add_window(window);
432 }442 }
433 else if (event.type == DestroyNotify) {443 else if (event.type == DestroyNotify) {
434 window = event.xdestroywindow.window;
435 Log::debug("--- Destroy Win: 0x%x\n", window);444 Log::debug("--- Destroy Win: 0x%x\n", window);
436 remove_window(window);445 remove_window(window);
437 needs_redraw = true;446 needs_redraw = true;
438447
=== modified file 'src/composite-window.cc'
--- src/composite-window.cc 2011-08-03 14:34:10 +0000
+++ src/composite-window.cc 2012-04-19 14:20:25 +0000
@@ -34,7 +34,7 @@
34 if (pix_)34 if (pix_)
35 XFreePixmap(xdpy_, pix_);35 XFreePixmap(xdpy_, pix_);
3636
37 if (damage_)37 if (damage_ && attr_.map_state == IsUnmapped)
38 XDamageDestroy(xdpy_, damage_);38 XDamageDestroy(xdpy_, damage_);
39}39}
4040
@@ -72,12 +72,12 @@
72 width_, height_, attr_.map_state);72 width_, height_, attr_.map_state);
7373
74 /* Update pixmap */74 /* Update pixmap */
75 if (!pix_ && attr_.map_state != 0) {75 if (!pix_ && attr_.map_state != IsUnmapped) {
76 pix_ = XCompositeNameWindowPixmap(xdpy_, win_);76 pix_ = XCompositeNameWindowPixmap(xdpy_, win_);
77 Log::debug(" => Pixmap <= 0x%x\n", (unsigned) pix_);77 Log::debug(" => Pixmap <= 0x%x\n", (unsigned) pix_);
78 update_tfp = true;78 update_tfp = true;
79 }79 }
80 else if (pix_ && attr_.map_state == 0) {80 else if (pix_ && attr_.map_state == IsUnmapped) {
81 Log::debug(" => Destroying Pixmap 0x%x\n", (unsigned) pix_);81 Log::debug(" => Destroying Pixmap 0x%x\n", (unsigned) pix_);
82 pix_to_free = pix_;82 pix_to_free = pix_;
83 pix_ = None;83 pix_ = None;
@@ -85,11 +85,11 @@
8585
86 Log::debug(" => Damage State <= 0x%x\n", (unsigned) damage_);86 Log::debug(" => Damage State <= 0x%x\n", (unsigned) damage_);
87 /* Update damage object */87 /* Update damage object */
88 if (!damage_ && attr_.map_state != 0) {88 if (!damage_ && attr_.map_state != IsUnmapped) {
89 damage_ = XDamageCreate(xdpy_, win_, XDamageReportNonEmpty);89 damage_ = XDamageCreate(xdpy_, win_, XDamageReportNonEmpty);
90 Log::debug(" => Damage <= 0x%x\n", (unsigned) damage_);90 Log::debug(" => Damage <= 0x%x\n", (unsigned) damage_);
91 }91 }
92 else if (damage_ && attr_.map_state == 0) {92 else if (damage_ && attr_.map_state == IsUnmapped) {
93 Log::debug(" => Destroying damage 0x%x\n", (unsigned) damage_);93 Log::debug(" => Destroying damage 0x%x\n", (unsigned) damage_);
94 XDamageDestroy(xdpy_, damage_);94 XDamageDestroy(xdpy_, damage_);
95 damage_ = None;95 damage_ = None;

Subscribers

People subscribed via source and target branches

to all changes: