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); }
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.
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.
Ah, so this is not really KWin, I didn't realize resources could modify even behaviour in Motif.
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() -