On 16/01/12 08:31, Rodolfo kix Garcia wrote:
> On 16/01/12 06:56, Carlos R. Mafra wrote:
>
>> On Tue, 10 Jan 2012 at 0:34:53 +0100, Rodolfo kix Garcia wrote:
>>>
>>> Why we can change the name using right click on the Clip. Why? because
>>> the clip is using the functions of WINGs. Can we change the menu
>>> functions to WINGs?... probably yes, but I don't know. Probably the full
>>> code of menu should be re-written.
>>>
>>> Can somebody put more light here? Ideas?
>>
>> I've just finished a dirty hack to deal with this using WINGs.
>>
>> I mimicked what happens when you use the Clip, so when you left-click
>> the menu entry holding the Ctrl key, the same input dialog appears
>> asking for the new name. Surprisingly, the overall patch removes
>> ~60 lines of code (because you can get rid of editEntry).
>>
>> Right now the dialog appears under the menu (because both appear
>> in the middle of the screen). Perhaps it will not be difficult to
>> make the dialog appear shifted to the right or left, but I haven't
>> looked at that now. I just wanted a proof of concept.
>>
>> What do people think about changing this behavior? Instead of
>> editing the menu entry directly and facing the deadkey limitations of
>> XLookupString() like Rodolfo pointed out or getting an input dialog
>> like a rename via the Clip?
>
>
> IMO the new code is better than the current code, and we remove "low-level"
> code (X11 functions like XGrab,...) , therefore I like this change.
>
>>
>> I tend to choose the one that works in all cäsés.
>>
>> But I might be missing something too. Comments?
>>
> [snip]
>> + char buffer[128];
>
>
> I don't like this things, I prefer "char buffer[DOCK_NAME_LEN]" and set
> DOCK_NAME_LEN in dock.h Probably we should find if this length is used in
> other places in the code.
>
>> + char *name;
>> + int wks_no = entry_no - 2;
>> +
>> + name = wstrdup(scr->workspaces[wks_no]->name);
>> + snprintf(buffer, sizeof(buffer), _("Type the name for
>> workspace %i:"), wks_no + 1);
>
>
> probably this is wrong, Is too early and I wake up 5 seconds ago but probably
> if the buffer length is 128 we have a buffer overflow. Correct:
>
> snprintf(buffer, sizeof(buffer) -1, _("Type the name for workspace %i:"),
> wks_no + 1);
>
> Or using the previous stuff:
>
> snprintf(buffer, DOCK_NAME_LEN -1, _("Type the name for workspace %i:"),
> wks_no + 1);
buffer[DOCK_NAME_LEN -1] = '/0';
Can help too.
>> +
>> + if (wInputDialog(scr, _("Rename Workspace"), buffer,
>> &name))
>> + wWorkspaceRename(scr, wks_no, name);
>> +
>> + if (name)
>> + wfree(name);
>> +
>> goto byebye;
>> } else if (bev->state & ControlMask) {
>> goto byebye;
>
>
> byebye: :-)
>
> Cheers,
> kix
--
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/
--
To unsubscribe, send mail to [email protected].