Bug 127180 - Motif xmTextFieldClass widgets not handled properly
Summary: Motif xmTextFieldClass widgets not handled properly
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: general (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-11 23:47 UTC by Orion Poplawski
Modified: 2006-05-26 14:35 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Orion Poplawski 2006-05-11 23:47:22 UTC
Version:            (using KDE KDE 3.5.2)
Installed from:    Fedora RPMs
Compiler:          gcc-4.1.0 
OS:                Linux

The follow code does not work properly in KDE.  You cannot select and enter text in the command area.  Works in Gnome, Xfce, and Irix.

#include <Xm/MainW.h>
#include <Xm/Label.h>
#include <Xm/Command.h>
#include <Xm/TextF.h>

#include <stdio.h>
#include <string.h> /* For String Handling */
#include <stdlib.h>

#define MAX_STR_LEN 30 /* Max Char length of Text Field */

/* Callback function prototypes */

void   cmd_cbk(), quit_cbk();

Widget   msg_wid;

char *cmd_label  = "Command Area: ";
char *msg_label  =  "Message Area: ";

int cmd_label_length;
int msg_label_length;


main(int argc,  char **argv)

{
    Widget        top_wid, main_win, menubar, menu,
                  label, cmd_wid;
    XtAppContext  app;
    XmString      label_str, quit;

    cmd_label_length = strlen(cmd_label);
    msg_label_length = strlen(msg_label);

    /* initialize toolkit and create top_widlevel shell */
    top_wid = XtVaAppInitialize(&app, "Main Window",
        NULL, 0, &argc, argv, NULL, NULL);


    /* Create MainWindow */

   main_win = XtVaCreateWidget("main_w",
        xmMainWindowWidgetClass, top_wid,
        XmNcommandWindowLocation, XmCOMMAND_BELOW_WORKSPACE,
        NULL);

    /* Create a simple MenuBar that contains one menu */
    quit = XmStringCreateLocalized("Quit");
    menubar = XmVaCreateSimpleMenuBar(main_win, "menubar",
        XmVaCASCADEBUTTON, quit, 'Q',
        NULL);


    menu = XmVaCreateSimplePulldownMenu(menubar, "file_menu", 0,
        quit_cbk,
        XmVaPUSHBUTTON, quit, 'Q', NULL, NULL,
        NULL);

    XmStringFree(quit);

    /*  Manage Menubar */

    XtManageChild(menubar);

    /* create a label text widget that wil be work area  */
    label_str = XmStringCreateLocalized("Work Area");

    label = XtVaCreateManagedWidget("main_window",
        xmLabelWidgetClass,   main_win,
        XmNlabelString, label_str,
        XmNwidth, 1000,
        XmNheight, 800,
        NULL);

     XmStringFree(label_str);


    /* Create the command area  */


    cmd_wid = XtVaCreateWidget(  "Command",
        xmTextFieldWidgetClass,  main_win,
        XmNmaxLength, MAX_STR_LEN,
       NULL);


    XmTextSetString(cmd_wid,cmd_label);
    XmTextSetInsertionPosition(cmd_wid, cmd_label_length);

    XtAddCallback(cmd_wid, XmNactivateCallback, cmd_cbk, NULL);

    XtManageChild(cmd_wid);


 /* Create the message area  */

    msg_wid= XtVaCreateWidget(  "Message:",
        xmTextFieldWidgetClass,   main_win,
        XmNeditable, False,
        XmNmaxLength, MAX_STR_LEN,
        NULL);

    XmTextSetString(msg_wid,msg_label);

    XtManageChild(msg_wid);

/* set the label as the work, command and message areas
   of the main window */

    XtVaSetValues(main_win,
        XmNmenuBar,    menubar,
        XmNworkWindow, label,
        XmNcommandWindow, cmd_wid,
        XmNmessageWindow,msg_wid,
        NULL);

    XtManageChild(main_win);
    XtRealizeWidget(top_wid);
    XtAppMainLoop(app);
}

/* execute the command and redirect message area */

void cmd_cbk(Widget cmd_widget, XtPointer *client_data,
            XmAnyCallbackStruct  *cbs)
{
    char cmd[MAX_STR_LEN],msg[MAX_STR_LEN];
                                                                                         
    XmTextGetSubstring(cmd_widget,cmd_label_length,
            MAX_STR_LEN - cmd_label_length, MAX_STR_LEN ,cmd);

    /* Append input message to Message area */

    XmTextReplace(msg_wid,msg_label_length, MAX_STR_LEN,cmd);

    /* Reset Command Area label  and insertion point*/

    XmTextSetString(cmd_widget, cmd_label);
    XmTextSetInsertionPosition(cmd_widget, cmd_label_length);
}

void  quit_cbk(Widget w, int item_no)

{    if (item_no == 0) /* the "quit" item */
        exit(0);
}
Comment 1 Lubos Lunak 2006-05-25 15:28:49 UTC
I doesn't work for me with GNOME either. And anyway, I suggest reporting this to the developers of the toolkit, I'm not going to debug Motif, if nothing else because I have no idea how to do it. If they find out what KWin does wrong or at least differently from others then I can do the work on the KDE side.

Comment 2 Orion Poplawski 2006-05-25 17:07:36 UTC
This was the patch applied by Fedora to fix the issue:

--- kdebase-3.5.2/kcontrol/krdb/ad/AAAXaw.ad.tn 2006-05-12 20:43:13.000000000 +0200
+++ kdebase-3.5.2/kcontrol/krdb/ad/AAAXaw.ad    2006-05-12 20:43:28.000000000 +0200
@@ -34,8 +34,4 @@
 *ShapeStyle: Rectangle
 *SmeBSB*shadowWidth: 3
 *Scrollbar*Cursor: left_ptr
-*Command.translations: \
-       <LeaveWindow>:  reset()\n\
-       <Btn1Down>:     set()\n\
-       <Btn1Up>:       notify() unset()

Work around was to disable "Apply colors to non-KDE applications".

No idea what either of these really do.
Comment 3 Lubos Lunak 2006-05-26 14:35:01 UTC
Ah, so this is not really KWin, I didn't realize resources could modify even behaviour in Motif.
Comment 4 Lubos Lunak 2006-05-26 14:35:55 UTC
SVN commit 544911 by lunakl:

These command translations apparently break some Motif apps.
BUG: 127180



 M  +0 -5      AAAXaw.ad  


--- branches/KDE/3.5/kdebase/kcontrol/krdb/ad/AAAXaw.ad #544910:544911
@@ -34,8 +34,3 @@
 *ShapeStyle: Rectangle
 *SmeBSB*shadowWidth: 3
 *Scrollbar*Cursor: left_ptr
-*Command.translations: \
-	<LeaveWindow>:	reset()\n\
-	<Btn1Down>:	set()\n\
-	<Btn1Up>:	notify() unset()
-