comparison src/frame-x.c @ 70:131b0175ea99 r20-0b30

Import from CVS: tag r20-0b30
author cvs
date Mon, 13 Aug 2007 09:02:59 +0200
parents ec9a17fef872
children c0c698873ce1
comparison
equal deleted inserted replaced
69:804d1389bcd6 70:131b0175ea99
638 { 638 {
639 Atom encoding = XA_STRING; 639 Atom encoding = XA_STRING;
640 String new_XtValue = (String) value; 640 String new_XtValue = (String) value;
641 String old_XtValue = NULL; 641 String old_XtValue = NULL;
642 Arg av[2]; 642 Arg av[2];
643
644 #ifdef MULE
645 Bufbyte *ptr;
646 /* Optimize for common ASCII case */
647 for (ptr = value; *ptr; ptr++)
648 if (!BYTE_ASCII_P (*ptr))
649 {
650 CONST char * tmp;
651 encoding = DEVICE_XATOM_COMPOUND_TEXT (XDEVICE (FRAME_DEVICE (f)));
652 GET_C_CHARPTR_EXT_CTEXT_DATA_ALLOCA ((CONST char *) value, tmp);
653 new_XtValue = (String) tmp;
654 break;
655 }
656 #endif /* MULE */
643 657
644 /* ### Caching is device-independent - belongs in update_frame_title. */ 658 /* ### Caching is device-independent - belongs in update_frame_title. */
645 XtSetArg (av[0], Xt_resource_name, &old_XtValue); 659 XtSetArg (av[0], Xt_resource_name, &old_XtValue);
646 XtGetValues (FRAME_X_SHELL_WIDGET (f), av, 1); 660 XtGetValues (FRAME_X_SHELL_WIDGET (f), av, 1);
647 if (!old_XtValue || strcmp (new_XtValue, old_XtValue)) 661 if (!old_XtValue || strcmp (new_XtValue, old_XtValue))
1036 unsigned int keys_and_buttons; 1050 unsigned int keys_and_buttons;
1037 1051
1038 if (XQueryPointer (display, RootWindow (display, DefaultScreen (display)), 1052 if (XQueryPointer (display, RootWindow (display, DefaultScreen (display)),
1039 &root_window, &child_window, &root_x, &root_y, 1053 &root_window, &child_window, &root_x, &root_y,
1040 &win_x, &win_y, &keys_and_buttons) == False) 1054 &win_x, &win_y, &keys_and_buttons) == False)
1041 return Qnil; 1055 return Qnil;
1042 1056
1043 Ctext = xstrdup ((char *) XSTRING_DATA (text)); 1057 Ctext = xstrdup ((char *) XSTRING_DATA (text));
1044 1058
1045 /* 1059 /*
1046 * Eek - XEmacs doesn't keep the old X event around so we have to 1060 * Eek - XEmacs doesn't keep the old X event around so we have to
1071 dnd_destroy_cb_rec[0].closure = (XtPointer) Ctext; 1085 dnd_destroy_cb_rec[0].closure = (XtPointer) Ctext;
1072 dnd_destroy_cb_rec[1].callback = NULL; 1086 dnd_destroy_cb_rec[1].callback = NULL;
1073 dnd_destroy_cb_rec[1].closure = NULL; 1087 dnd_destroy_cb_rec[1].closure = NULL;
1074 1088
1075 CurrentDragWidget = 1089 CurrentDragWidget =
1076 DtDndDragStart (Wuh, &event, DtDND_BUFFER_TRANSFER, 1, XmDROP_COPY, 1090 DtDndDragStart (Wuh, &event, DtDND_BUFFER_TRANSFER, 1, XmDROP_COPY,
1077 dnd_convert_cb_rec, 1091 dnd_convert_cb_rec,
1078 dnd_destroy_cb_rec, 1092 dnd_destroy_cb_rec,
1079 NULL, 0); 1093 NULL, 0);
1080 return Qt; 1094 return Qt;
1081 } 1095 }
1082 return Qnil; 1096 return Qnil;
1083 } 1097 }
1084 1098
1105 if (transferInfo->dropData->protocol == DtDND_FILENAME_TRANSFER) 1119 if (transferInfo->dropData->protocol == DtDND_FILENAME_TRANSFER)
1106 { 1120 {
1107 for (ii = 0; ii < transferInfo->dropData->numItems; ii++) 1121 for (ii = 0; ii < transferInfo->dropData->numItems; ii++)
1108 { 1122 {
1109 filePath = transferInfo->dropData->data.files[ii]; 1123 filePath = transferInfo->dropData->data.files[ii];
1110 /* ### Mule-izing required */ 1124 /* ### Mule-izing required */
1111 path = make_string ((Bufbyte *)filePath, strlen (filePath)); 1125 path = make_string (filePath, strlen (filePath));
1112 va_run_hook_with_args (Qdrag_and_drop_functions, 2, frame, path); 1126 va_run_hook_with_args (Qdrag_and_drop_functions, 2, frame, path);
1113 } 1127 }
1114 } 1128 }
1115 else if (transferInfo->dropData->protocol == DtDND_BUFFER_TRANSFER) 1129 else if (transferInfo->dropData->protocol == DtDND_BUFFER_TRANSFER)
1116 { 1130 {
1120 drag_not_done = 1; 1134 drag_not_done = 1;
1121 for (ii = 0; ii < transferInfo->dropData->numItems; ii++) 1135 for (ii = 0; ii < transferInfo->dropData->numItems; ii++)
1122 { 1136 {
1123 filePath = transferInfo->dropData->data.buffers[ii].name; 1137 filePath = transferInfo->dropData->data.buffers[ii].name;
1124 /* ### Mule-izing required */ 1138 /* ### Mule-izing required */
1125 path = (filePath == NULL) ? Qnil 1139 path = (filePath == NULL) ? Qnil
1126 : make_string ((Bufbyte *)filePath, strlen (filePath)); 1140 : make_string (filePath, strlen (filePath));
1127 buf = transferInfo->dropData->data.buffers[ii].bp; 1141 buf = transferInfo->dropData->data.buffers[ii].bp;
1128 data = make_string ((Bufbyte *)buf, 1142 data = make_string(buf,
1129 transferInfo->dropData->data.buffers[ii].size); 1143 transferInfo->dropData->data.buffers[ii].size);
1130 va_run_hook_with_args(Qdrag_and_drop_functions, 3, frame, path, 1144 va_run_hook_with_args(Qdrag_and_drop_functions, 3, frame, path,
1131 data); 1145 data);
1132 } 1146 }
1133 drag_not_done = 0; 1147 drag_not_done = 0;
1134 unbind_to(speccount, Qnil); 1148 unbind_to(speccount, Qnil);
1135 } 1149 }
1136 1150
1137 UNGCPRO; 1151 UNGCPRO;
1138 return; 1152 return;
1139 } 1153 }
1644 if (!NILP (lisp_window_id)) 1658 if (!NILP (lisp_window_id))
1645 { 1659 {
1646 char *string; 1660 char *string;
1647 1661
1648 CHECK_STRING (lisp_window_id); 1662 CHECK_STRING (lisp_window_id);
1649 string = (char *) XSTRING_DATA (lisp_window_id); 1663 string = (char *) (XSTRING_DATA (lisp_window_id));
1650 if (string[0] == '0' && (string[1] == 'x' || string[1] == 'X')) 1664 if (string[0] == '0' && (string[1] == 'x' || string[1] == 'X'))
1651 sscanf (string+2, "%lxu", &window_id); 1665 sscanf (string+2, "%lxu", &window_id);
1652 #if 0 1666 #if 0
1653 else if (string[0] == 'w') 1667 else if (string[0] == 'w')
1654 { 1668 {
1824 x_wm_store_class_hints (shell_widget, XtName (frame_widget)); 1838 x_wm_store_class_hints (shell_widget, XtName (frame_widget));
1825 x_wm_maybe_store_wm_command (f); 1839 x_wm_maybe_store_wm_command (f);
1826 x_wm_hack_wm_protocols (shell_widget); 1840 x_wm_hack_wm_protocols (shell_widget);
1827 } 1841 }
1828 1842
1843 #ifdef HAVE_XIM
1844 XIM_init_frame (f);
1845 #endif /* HAVE_XIM */
1846
1829 #ifdef HACK_EDITRES 1847 #ifdef HACK_EDITRES
1830 /* Allow XEmacs to respond to EditRes requests. See the O'Reilly Xt */ 1848 /* Allow XEmacs to respond to EditRes requests. See the O'Reilly Xt */
1831 /* Instrinsics Programming Manual, Motif Edition, Aug 1993, Sect 14.14, */ 1849 /* Instrinsics Programming Manual, Motif Edition, Aug 1993, Sect 14.14, */
1832 /* pp. 483-493. */ 1850 /* pp. 483-493. */
1833 XtAddEventHandler (shell_widget, /* the shell widget in question */ 1851 XtAddEventHandler (shell_widget, /* the shell widget in question */
1998 x_get_frame_parent (struct frame *f) 2016 x_get_frame_parent (struct frame *f)
1999 { 2017 {
2000 Widget parentwid = 0; 2018 Widget parentwid = 0;
2001 Arg av[1]; 2019 Arg av[1];
2002 2020
2003 /* We may be passed a dangling deleted frame */
2004 /* I do not know how to test for this. -sb */
2005 XtSetArg (av[0], XtNtransientFor, &parentwid); 2021 XtSetArg (av[0], XtNtransientFor, &parentwid);
2006 XtGetValues (FRAME_X_SHELL_WIDGET (f), av, 1); 2022 XtGetValues (FRAME_X_SHELL_WIDGET (f), av, 1);
2007 /* find the frame whose wid is parentwid */ 2023 /* find the frame whose wid is parentwid */
2008 if (parentwid) 2024 if (parentwid)
2009 { 2025 {
2071 XtVaSetValues (w, 2087 XtVaSetValues (w,
2072 XtNwinGravity, win_gravity, 2088 XtNwinGravity, win_gravity,
2073 XtNx, xoff, 2089 XtNx, xoff,
2074 XtNy, yoff, 2090 XtNy, yoff,
2075 0); 2091 0);
2076 2092
2077 /* Sometimes you will find that 2093 /* Sometimes you will find that
2078 2094
2079 (set-frame-position (selected-frame) -50 -50) 2095 (set-frame-position (selected-frame) -50 -50)
2080 2096
2081 doesn't put the frame where you expect it to: i.e. it's closer to 2097 doesn't put the frame where you expect it to: i.e. it's closer to
2182 Window emacs_window; 2198 Window emacs_window;
2183 XWindowChanges xwc; 2199 XWindowChanges xwc;
2184 unsigned int flags; 2200 unsigned int flags;
2185 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); 2201 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device));
2186 2202
2187 if (FRAME_VISIBLE_P(f) || force) 2203 if (f->visible || force)
2188 { 2204 {
2189 emacs_window = XtWindow (FRAME_X_SHELL_WIDGET (f)); 2205 emacs_window = XtWindow (FRAME_X_SHELL_WIDGET (f));
2190 /* first raises all the dialog boxes, then put emacs just below the 2206 /* first raises all the dialog boxes, then put emacs just below the
2191 * bottom most dialog box */ 2207 * bottom most dialog box */
2192 bottom_dialog = lw_raise_all_pop_up_widgets (); 2208 bottom_dialog = lw_raise_all_pop_up_widgets ();
2221 { 2237 {
2222 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); 2238 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device));
2223 XWindowChanges xwc; 2239 XWindowChanges xwc;
2224 unsigned int flags; 2240 unsigned int flags;
2225 2241
2226 if (FRAME_VISIBLE_P(f)) 2242 if (f->visible)
2227 { 2243 {
2228 xwc.stack_mode = Below; 2244 xwc.stack_mode = Below;
2229 flags = CWStackMode; 2245 flags = CWStackMode;
2230 if (!XReconfigureWMWindow (display, XtWindow (FRAME_X_SHELL_WIDGET (f)), 2246 if (!XReconfigureWMWindow (display, XtWindow (FRAME_X_SHELL_WIDGET (f)),
2231 DefaultScreen (display), flags, &xwc)) 2247 DefaultScreen (display), flags, &xwc))
2237 static void 2253 static void
2238 x_make_frame_visible (struct frame *f) 2254 x_make_frame_visible (struct frame *f)
2239 { 2255 {
2240 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); 2256 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device));
2241 2257
2242 if (!FRAME_VISIBLE_P(f)) 2258 if (!f->visible)
2243 XMapRaised (display, XtWindow (FRAME_X_SHELL_WIDGET (f))); 2259 XMapRaised (display, XtWindow (FRAME_X_SHELL_WIDGET (f)));
2244 else 2260 else
2245 x_raise_frame_1 (f, 0); 2261 x_raise_frame_1 (f, 0);
2246 } 2262 }
2247 2263
2249 static void 2265 static void
2250 x_make_frame_invisible (struct frame *f) 2266 x_make_frame_invisible (struct frame *f)
2251 { 2267 {
2252 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); 2268 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device));
2253 2269
2254 if (!FRAME_VISIBLE_P(f)) 2270 if (!f->visible)
2255 return; 2271 return;
2256 2272
2257 if (!XWithdrawWindow (display, 2273 if (!XWithdrawWindow (display,
2258 XtWindow (FRAME_X_SHELL_WIDGET (f)), 2274 XtWindow (FRAME_X_SHELL_WIDGET (f)),
2259 DefaultScreen (display))) 2275 DefaultScreen (display)))
2265 { 2281 {
2266 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device)); 2282 Display *display = DEVICE_X_DISPLAY (XDEVICE (f->device));
2267 XWindowAttributes xwa; 2283 XWindowAttributes xwa;
2268 int result; 2284 int result;
2269 2285
2270 /* JV:
2271 This is bad, very bad :-(
2272 It is not compatible with our tristate visible and
2273 it should never ever change the visibility for us, this leads to
2274 the frame-freeze problem under fvwm because with the pager
2275
2276 Mappedness != Viewability != Visibility != Emacs f->visible
2277
2278 This first unequalness is the reason for the frame freezing problem
2279 under fvwm (it happens when the frame is another fvwm-page)
2280
2281 The second unequalness happen when it is on the same fvwm-page
2282 but in an invisible part of the visible screen.
2283
2284 For now we just return the XEmacs internal value --- which might not be up
2285 to date. Is that a problem? ---. Otherwise we should
2286 use async visibility like in standard Emacs.
2287 */
2288
2289 #if 0
2290 if (!XGetWindowAttributes (display, 2286 if (!XGetWindowAttributes (display,
2291 XtWindow (FRAME_X_SHELL_WIDGET (f)), 2287 XtWindow (FRAME_X_SHELL_WIDGET (f)),
2292 &xwa)) 2288 &xwa))
2293 result = 0; 2289 result = 0;
2294 else 2290 else
2295 result = xwa.map_state == IsViewable; 2291 result = xwa.map_state == IsViewable;
2296 /* In this implementation it should at least be != IsUnmapped
2297 JV */
2298 2292
2299 f->visible = result; 2293 f->visible = result;
2300 return result; 2294 return result;
2301 #endif
2302
2303 return f->visible;
2304 } 2295 }
2305 2296
2306 static int 2297 static int
2307 x_frame_totally_visible_p (struct frame *f) 2298 x_frame_totally_visible_p (struct frame *f)
2308 { 2299 {
2327 static void 2318 static void
2328 x_focus_on_frame (struct frame *f) 2319 x_focus_on_frame (struct frame *f)
2329 { 2320 {
2330 XWindowAttributes xwa; 2321 XWindowAttributes xwa;
2331 Widget shell_widget; 2322 Widget shell_widget;
2332 int viewable;
2333 2323
2334 assert (FRAME_X_P (f)); 2324 assert (FRAME_X_P (f));
2335 2325
2336 shell_widget = FRAME_X_SHELL_WIDGET (f); 2326 shell_widget = FRAME_X_SHELL_WIDGET (f);
2337 if (!XtWindow (shell_widget)) 2327 if (!XtWindow (shell_widget))
2351 */ 2341 */
2352 XGrabServer (XtDisplay (shell_widget)); 2342 XGrabServer (XtDisplay (shell_widget));
2353 if (XGetWindowAttributes (XtDisplay (shell_widget), 2343 if (XGetWindowAttributes (XtDisplay (shell_widget),
2354 XtWindow (shell_widget), 2344 XtWindow (shell_widget),
2355 &xwa)) 2345 &xwa))
2356 /* JV: it is bad to change the visibility like this, so we don't for the 2346 f->visible = xwa.map_state == IsViewable;
2357 moment, at least change_frame_visibility should be called
2358 Note also that under fvwm a frame can me Viewable (and thus Mapped)
2359 but still X-invisible
2360 f->visible = xwa.map_state == IsViewable; */
2361 viewable = xwa.map_state == IsViewable;
2362
2363 2347
2364 if (viewable) 2348 if (f->visible)
2365 { 2349 {
2366 Window focus; 2350 Window focus;
2367 int revert_to; 2351 int revert_to;
2368 XGetInputFocus (XtDisplay (shell_widget), &focus, &revert_to); 2352 XGetInputFocus (XtDisplay (shell_widget), &focus, &revert_to);
2369 /* Don't explicitly set the focus on this window unless the focus 2353 /* Don't explicitly set the focus on this window unless the focus