[Spice-devel] [PATCH spice 4/4] spicec-x11: Add a class hint to our window managet hints
Hans de Goede
hdegoede at redhat.com
Wed Dec 15 10:01:42 PST 2010
Hi,
On 12/15/2010 06:24 PM, Alon Levy wrote:
> On Wed, Dec 15, 2010 at 04:50:09PM +0100, Hans de Goede wrote:
>> This helps people who want to tell their windowmanager to do something special
>> with spicec, like make it sticky, or whatever, see:
>> https://bugzilla.redhat.com/show_bug.cgi?id=662452#c4
>> ---
>> client/x11/red_window.cpp | 11 ++++++++++-
>> 1 files changed, 10 insertions(+), 1 deletions(-)
>>
>> diff --git a/client/x11/red_window.cpp b/client/x11/red_window.cpp
>> index 0816bf3..d7b19f9 100644
>> --- a/client/x11/red_window.cpp
>> +++ b/client/x11/red_window.cpp
>> @@ -1214,6 +1214,7 @@ void RedWindow_p::create(RedWindow& red_window, PixelsSource_p& pix_source,
>>
>> try {
>> int res;
>> + XClassHint *class_hint;
>>
>> XLockDisplay(x_display);
>> res = XSaveContext(x_display, window, user_data_context, (XPointer)&red_window);
>> @@ -1223,8 +1224,16 @@ void RedWindow_p::create(RedWindow& red_window, PixelsSource_p& pix_source,
>> }
>>
>> XSetWMProtocols(x_display, window,&wm_delete_window_atom, 1);
>> - XGCValues gc_vals;
>> + class_hint = XAllocClassHint();
>> + if (!class_hint) {
>> + THROW("allocating class hint failed");
>> + }
>> + class_hint->res_name = (char *)"spicec";
>> + class_hint->res_class = (char *)"spicec";
>> + XSetClassHint(x_display, window, class_hint);
>> + XFree(class_hint);
>>
>
> Is it wise to have both operations in the same try block? don't we want to continue
> as before if XAllocClassHint fails but the rest doesn't?
>
XAllocClassHint can never fail except when we run out of memory, at which time we're
very likely going to crash anyways. I could replace the test + throw by an assert I guess.
>> + XGCValues gc_vals;
>> XLockDisplay(x_display);
>> gc = XCreateGC(x_display, window, 0,&gc_vals);
>> XUnlockDisplay(x_display);
>> --
>> 1.7.3.2
>>
>> _______________________________________________
>> Spice-devel mailing list
>> Spice-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/spice-devel
Regards,
Hans
More information about the Spice-devel
mailing list