+ * Get the z-priority for a given window. This is defined as an arbitrary integer value which is used only in + * comparison with other z-priority values; a window with a given z-priority will appear above other windows with + * a lower value, and below those with a higher one. (The ordering within z-priorities can be mixed). '...arbitrary integer value ... used only ...; ' is maybe not so relevant? Suggestion for the last part: (The ordering of windows with equal z-priorities is arbitrary.) ? =================== +static inline int GetWindowZPriority(const Window *w) 'inline' does not seem too needed. If you are worried about performance, a better idea is to store "GetWindowZPriority(this)" below. (A decent C++ compiler will inline the call and cache the above value by itself already, so it won't make a big difference either way.) =================== + case WC_CONSOLE: + return 5; + + case WC_DROPDOWN_MENU: + return 4; This hides dropdown-menus behind the console, which means you cannot use a dropdown any more. Unless you have a good reason for this order, I'd suggest to swap these. Another window you may want to consider is WC_ERRMSG. =================== + default: + return 0; + + case WC_MAIN_WINDOW: + return -1; If you add 1 to all numbers, you can make the function return an uint. =================== + if (w != NULL) { Your editing made the if/else statement difficult to read, and it introduced some dead code. In the 'else' of the above 'if (w != NULL) {', the condition 'if (_z_front_window != NULL) {' never holds, since you just tested that here. I suggest a rewrite of this code. The general preference is to have a sequence of cases, and deal with one at a time, completely. For example ... if (A) { ... } else { if (B) { ... } else { ... } } } can also be written as ... if (A) { ... return; } if (B) { ... return; } ... } which is easier to read as you don't have to navigate through all the if/else branches and remember all test results along the way. In the function, the 'w == NULL' seems the simpler case, so I'd do that one first, like ... if (w == NULL) { /* the 'else' part here. */ return; } /* the 'then' part here. */ } I am sure you can find a nice code layout. =================== + assert(!w->z_front || w->z_front->window_class == WC_INVALID || w->window_class == WC_INVALID || + GetWindowZPriority(w->z_front) >= GetWindowZPriority(w)); It took me a while to understand this, but it seems correct. Three minor code-style issues: - "!w->z_front" should be "w->z_front == NULL", as w->z_front is not a boolean value. - at the end of the first line is a trailing space character, which should not be there. - the second (and all next lines) of a multi-line statement should indent by 2 TAB characters. The last item is for cases like if (foo != 0 && foo != 1) { foo = 1; A single indent at the second line would make it look like it belongs to the 'then' part.