void gtk_xtbin_resize (GtkWidget *widget, gint width, gint height) { Arg args[2]; GtkXtBin *xtbin = GTK_XTBIN (widget); GtkAllocation allocation; #ifdef DEBUG_XTBIN OWB_PRINTF("gtk_xtbin_resize %p %d %d\n", (void *)widget, width, height); #endif xtbin->height = height; xtbin->width = width; // Avoid BadValue errors in XtSetValues if (height <= 0 || width <=0) { height = 1; width = 1; } XtSetArg(args[0], XtNheight, height); XtSetArg(args[1], XtNwidth, width); XtSetValues(xtbin->xtclient.top_widget, args, 2); /* we need to send a size allocate so the socket knows about the size changes */ allocation.x = xtbin->x; allocation.y = xtbin->y; allocation.width = xtbin->width; allocation.height = xtbin->height; gtk_widget_size_allocate(widget, &allocation); }
static void send_xembed_message (XtClient *xtclient, long message, long detail, long data1, long data2, long time) { XEvent xevent; Window w=XtWindow(xtclient->top_widget); Display* dpy=xtclient->xtdisplay; int errorcode; memset(&xevent,0,sizeof(xevent)); xevent.xclient.window = w; xevent.xclient.type = ClientMessage; xevent.xclient.message_type = XInternAtom(dpy,"_XEMBED",False); xevent.xclient.format = 32; xevent.xclient.data.l[0] = time; xevent.xclient.data.l[1] = message; xevent.xclient.data.l[2] = detail; xevent.xclient.data.l[3] = data1; xevent.xclient.data.l[4] = data2; trap_errors (); XSendEvent (dpy, w, False, NoEventMask, &xevent); XSync (dpy,False); if((errorcode = untrap_error())) { #ifdef DEBUG_XTBIN OWB_PRINTF("send_xembed_message error(%d)!!!\n",errorcode); #endif } }
void AccessControlList::show() { OWB_PRINTF_FORMATTED("AccessControlList::show count: %d\n", static_cast<int>(m_list.size())); for (size_t i = 0; i < m_list.size(); ++i) m_list[i]->show(); OWB_PRINTF("\n\n"); }
static void gtk_xtbin_realize (GtkWidget *widget) { GtkXtBin *xtbin; GtkAllocation allocation = { 0, 0, 200, 200 }; gint x, y, w, h, d; /* geometry of window */ #ifdef DEBUG_XTBIN OWB_PRINTF("gtk_xtbin_realize()\n"); #endif g_return_if_fail (GTK_IS_XTBIN (widget)); xtbin = GTK_XTBIN (widget); /* caculate the allocation before realize */ gdk_window_get_geometry(xtbin->parent_window, &x, &y, &w, &h, &d); allocation.width = w; allocation.height = h; gtk_widget_size_allocate (widget, &allocation); #ifdef DEBUG_XTBIN OWB_PRINTF("initial allocation %d %d %d %d\n", x, y, w, h); #endif xtbin->width = widget->allocation.width; xtbin->height = widget->allocation.height; /* use GtkSocket's realize */ (*GTK_WIDGET_CLASS(parent_class)->realize)(widget); /* create the Xt client widget */ xt_client_create(&(xtbin->xtclient), gtk_socket_get_id(GTK_SOCKET(xtbin)), xtbin->height, xtbin->width); xtbin->xtwindow = XtWindow(xtbin->xtclient.child_widget); gdk_flush(); /* now that we have created the xt client, add it to the socket. */ gtk_socket_add_id(GTK_SOCKET(widget), xtbin->xtwindow); }
static int untrap_error(void) { XSetErrorHandler(old_error_handler); if(trapped_error_code) { #ifdef DEBUG_XTBIN OWB_PRINTF("Get X Window Error = %d\n", trapped_error_code); #endif } return trapped_error_code; }
static void xt_client_handle_xembed_message(Widget w, XtPointer client_data, XEvent *event) { XtClient *xtplug = (XtClient*)client_data; switch (event->xclient.data.l[1]) { case XEMBED_EMBEDDED_NOTIFY: break; case XEMBED_WINDOW_ACTIVATE: #ifdef DEBUG_XTBIN OWB_PRINTF("Xt client get XEMBED_WINDOW_ACTIVATE\n"); #endif break; case XEMBED_WINDOW_DEACTIVATE: #ifdef DEBUG_XTBIN OWB_PRINTF("Xt client get XEMBED_WINDOW_DEACTIVATE\n"); #endif break; case XEMBED_MODALITY_ON: #ifdef DEBUG_XTBIN OWB_PRINTF("Xt client get XEMBED_MODALITY_ON\n"); #endif break; case XEMBED_MODALITY_OFF: #ifdef DEBUG_XTBIN OWB_PRINTF("Xt client get XEMBED_MODALITY_OFF\n"); #endif break; case XEMBED_FOCUS_IN: case XEMBED_FOCUS_OUT: { XEvent xevent; memset(&xevent, 0, sizeof(xevent)); if(event->xclient.data.l[1] == XEMBED_FOCUS_IN) { #ifdef DEBUG_XTBIN OWB_PRINTF("XTEMBED got focus in\n"); #endif xevent.xfocus.type = FocusIn; } else { #ifdef DEBUG_XTBIN OWB_PRINTF("XTEMBED got focus out\n"); #endif xevent.xfocus.type = FocusOut; } xevent.xfocus.window = XtWindow(xtplug->child_widget); xevent.xfocus.display = XtDisplay(xtplug->child_widget); XSendEvent(XtDisplay(xtplug->child_widget), xevent.xfocus.window, False, NoEventMask, &xevent ); XSync( XtDisplay(xtplug->child_widget), False); } break; default: break; } /* End of XEmbed Message */ }
void TraceGlyphBufferToString(const SimpleFontData* pSimpleFontData, const GlyphBuffer& glyphBuffer, int glyphIndexBegin, int glyphCount, const FloatPoint& point) { eastl::fixed_string<char8_t, 128> sDebug; sDebug.sprintf("[%d,%d] ", (int)point.x(), (int)point.y()); GlyphBufferGlyph* pGlyphArray = const_cast<GlyphBufferGlyph*>(glyphBuffer.glyphs(glyphIndexBegin)); for(int i = glyphIndexBegin; i < glyphIndexBegin + glyphCount; ++i, ++pGlyphArray) sDebug += (char8_t)ConvertGlyphToChar(pSimpleFontData->m_font.mpFont, *pGlyphArray); sDebug += "\n"; OWB_PRINTF("%s", sDebug.c_str()); }
static void gtk_xtbin_destroy (GtkObject *object) { GtkXtBin *xtbin; #ifdef DEBUG_XTBIN OWB_PRINTF("gtk_xtbin_destroy()\n"); #endif g_return_if_fail (object != NULL); g_return_if_fail (GTK_IS_XTBIN (object)); xtbin = GTK_XTBIN (object); if(xtbin->xtwindow) { /* remove the event handler */ xt_client_destroy(&(xtbin->xtclient)); xtbin->xtwindow = 0; num_widgets--; /* reduce our usage count */ /* If this is the last running widget, remove the Xt display connection from the mainloop */ if (0 == num_widgets) { #ifdef DEBUG_XTBIN OWB_PRINTF("removing the Xt connection from the main loop\n"); #endif g_main_context_remove_poll((GMainContext*)NULL, &xt_event_poll_fd); g_source_remove(tag); gtk_timeout_remove(xt_polling_timer_id); xt_polling_timer_id = 0; } } GTK_OBJECT_CLASS(parent_class)->destroy(object); }
void ApplicationCacheResource::dumpType(unsigned type) { if (type & Implicit) OWB_PRINTF("implicit "); if (type & Manifest) OWB_PRINTF("manifest "); if (type & Explicit) OWB_PRINTF("explicit "); if (type & Foreign) OWB_PRINTF("foreign "); if (type & Fallback) OWB_PRINTF("fallback "); if (type & Opportunistic) OWB_PRINTF("opportunistic "); if (type & Dynamic) OWB_PRINTF("dynamic "); OWB_PRINTF("\n"); }
/* * Free tail arenas linked after head, which may not be the true list head. * Reset pool->current to point to head in case it pointed at a tail arena. */ static void FreeArenaList(ArenaPool *pool, Arena *head, bool reallyFree) { Arena **ap, *a; ap = &head->next; a = *ap; if (!a) return; #ifdef DEBUG do { ASSERT(a->base <= a->avail && a->avail <= a->limit); a->avail = a->base; CLEAR_UNUSED(a); } while ((a = a->next) != 0); a = *ap; #endif if (freelist_count >= FREELIST_MAX) reallyFree = true; if (reallyFree) { do { *ap = a->next; CLEAR_ARENA(a); #ifdef DEBUG_ARENA_MALLOC if (a) { i--; OWB_PRINTF("Free: %d\n", i); } #endif fastFree(a); a = 0; } while ((a = *ap) != 0); } else { /* Insert the whole arena chain at the front of the freelist. */ do { ap = &(*ap)->next; freelist_count++; } while (*ap); *ap = arena_freelist; arena_freelist = a; head->next = 0; } pool->current = head; }
static void gtk_xtbin_unrealize (GtkWidget *object) { GtkXtBin *xtbin; GtkWidget *widget; #ifdef DEBUG_XTBIN OWB_PRINTF("gtk_xtbin_unrealize()\n"); #endif /* gtk_object_destroy() will already hold a refcount on object */ xtbin = GTK_XTBIN(object); widget = GTK_WIDGET(object); GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE); if (GTK_WIDGET_REALIZED (widget)) { xt_client_unrealize(&(xtbin->xtclient)); } (*GTK_WIDGET_CLASS (parent_class)->unrealize)(widget); }
/* Initial Xt plugin */ static void xt_client_init( XtClient * xtclient, Visual *xtvisual, Colormap xtcolormap, int xtdepth) { XtAppContext app_context; char *mArgv[1]; int mArgc = 0; /* * Initialize Xt stuff */ xtclient->top_widget = NULL; xtclient->child_widget = NULL; xtclient->xtdisplay = NULL; xtclient->xtvisual = NULL; xtclient->xtcolormap = 0; xtclient->xtdepth = 0; if (!xt_is_initialized) { #ifdef DEBUG_XTBIN OWB_PRINTF("starting up Xt stuff\n"); #endif XtToolkitInitialize(); app_context = XtCreateApplicationContext(); if (fallback) XtAppSetFallbackResources(app_context, fallback); xtdisplay = XtOpenDisplay(app_context, gdk_get_display(), NULL, "Wrapper", NULL, 0, &mArgc, mArgv); if (xtdisplay) xt_is_initialized = TRUE; } xtclient->xtdisplay = xtdisplay; xtclient->xtvisual = xtvisual; xtclient->xtcolormap = xtcolormap; xtclient->xtdepth = xtdepth; }
static void xt_client_event_handler( Widget w, XtPointer client_data, XEvent *event) { XtClient *xtplug = (XtClient*)client_data; switch(event->type) { case ClientMessage: /* Handle xembed message */ if (event->xclient.message_type== XInternAtom (XtDisplay(xtplug->child_widget), "_XEMBED", False)) { xt_client_handle_xembed_message(w, client_data, event); } break; case ReparentNotify: break; case MappingNotify: xt_client_set_info (w, XEMBED_MAPPED); break; case UnmapNotify: xt_client_set_info (w, 0); break; case FocusIn: send_xembed_message ( xtplug, XEMBED_REQUEST_FOCUS, 0, 0, 0, 0); break; case FocusOut: break; case KeyPress: #ifdef DEBUG_XTBIN OWB_PRINTF("Key Press Got!\n"); #endif break; default: break; } /* End of switch(event->type) */ }
/* Create the Xt client widgets * */ static void xt_client_create ( XtClient* xtclient , Window embedderid, int height, int width ) { int n; Arg args[6]; Widget child_widget; Widget top_widget; #ifdef DEBUG_XTBIN OWB_PRINTF("xt_client_create() \n"); #endif top_widget = XtAppCreateShell("drawingArea", "Wrapper", applicationShellWidgetClass, xtclient->xtdisplay, NULL, 0); xtclient->top_widget = top_widget; /* set size of Xt window */ n = 0; XtSetArg(args[n], XtNheight, height);n++; XtSetArg(args[n], XtNwidth, width);n++; XtSetValues(top_widget, args, n); child_widget = XtVaCreateWidget("form", compositeWidgetClass, top_widget, NULL); n = 0; XtSetArg(args[n], XtNheight, height);n++; XtSetArg(args[n], XtNwidth, width);n++; XtSetArg(args[n], XtNvisual, xtclient->xtvisual ); n++; XtSetArg(args[n], XtNdepth, xtclient->xtdepth ); n++; XtSetArg(args[n], XtNcolormap, xtclient->xtcolormap ); n++; XtSetArg(args[n], XtNborderWidth, 0); n++; XtSetValues(child_widget, args, n); XSync(xtclient->xtdisplay, FALSE); xtclient->oldwindow = top_widget->core.window; top_widget->core.window = embedderid; /* this little trick seems to finish initializing the widget */ #if XlibSpecificationRelease >= 6 XtRegisterDrawable(xtclient->xtdisplay, embedderid, top_widget); #else _XtRegisterWindow( embedderid, top_widget); #endif XtRealizeWidget(child_widget); /* listen to all Xt events */ XSelectInput(xtclient->xtdisplay, XtWindow(top_widget), 0x0FFFFF); xt_client_set_info (child_widget, 0); XtManageChild(child_widget); xtclient->child_widget = child_widget; /* set the event handler */ XtAddEventHandler(child_widget, 0x0FFFFF & ~ResizeRedirectMask, TRUE, (XtEventHandler)xt_client_event_handler, xtclient); XtAddEventHandler(child_widget, SubstructureNotifyMask | ButtonReleaseMask, TRUE, (XtEventHandler)xt_client_focus_listener, xtclient); XSync(xtclient->xtdisplay, FALSE); }
/* ** ArenaAllocate() -- allocate space from an arena pool ** ** Description: ArenaAllocate() allocates space from an arena ** pool. ** ** First try to satisfy the request from arenas starting at ** pool->current. ** ** If there is not enough space in the arena pool->current, try ** to claim an arena, on a first fit basis, from the global ** freelist (arena_freelist). ** ** If no arena in arena_freelist is suitable, then try to ** allocate a new arena from the heap. ** ** Returns: pointer to allocated space or NULL ** */ void* ArenaAllocate(ArenaPool *pool, unsigned int nb) { Arena *a; char *rp; /* returned pointer */ ASSERT((nb & pool->mask) == 0); nb = (uword)ARENA_ALIGN(pool, nb); /* force alignment */ /* attempt to allocate from arenas at pool->current */ { a = pool->current; do { if ( a->avail +nb <= a->limit ) { pool->current = a; rp = (char *)a->avail; a->avail += nb; return rp; } } while( NULL != (a = a->next) ); } /* attempt to allocate from arena_freelist */ { Arena *p = NULL; /* previous pointer, for unlinking from freelist */ for ( a = arena_freelist; a != NULL ; p = a, a = a->next ) { if ( a->base +nb <= a->limit ) { if ( p == NULL ) arena_freelist = a->next; else p->next = a->next; a->avail = a->base; rp = (char *)a->avail; a->avail += nb; /* the newly allocated arena is linked after pool->current * and becomes pool->current */ a->next = pool->current->next; pool->current->next = a; pool->current = a; if ( 0 == pool->first.next ) pool->first.next = a; freelist_count--; return(rp); } } } /* attempt to allocate from the heap */ { unsigned int sz = max(pool->arenasize, nb); sz += sizeof *a + pool->mask; /* header and alignment slop */ #ifdef DEBUG_ARENA_MALLOC i++; OWB_PRINTF("Malloc: %d\n", i); #endif a = (Arena*)fastMalloc(sz); if (a) { a->limit = (uword)a + sz; a->base = a->avail = (uword)ARENA_ALIGN(pool, a + 1); rp = (char *)a->avail; a->avail += nb; /* the newly allocated arena is linked after pool->current * and becomes pool->current */ a->next = pool->current->next; pool->current->next = a; pool->current = a; if ( !pool->first.next ) pool->first.next = a; return(rp); } } /* we got to here, and there's no memory to allocate */ return(0); } /* --- end ArenaAllocate() --- */
String ImageBuffer::toDataURL(const String&) const { OWB_PRINTF("ImageBuffer::toDataURL\n"); notImplemented(); return String(); }
GtkWidget* gtk_xtbin_new (GdkWindow *parent_window, String * f) { GtkXtBin *xtbin; gpointer user_data; assert(parent_window != NULL); xtbin = gtk_type_new (GTK_TYPE_XTBIN); if (!xtbin) return (GtkWidget*)NULL; if (f) fallback = f; /* Initialize the Xt toolkit */ xtbin->parent_window = parent_window; xt_client_init(&(xtbin->xtclient), GDK_VISUAL_XVISUAL(gdk_rgb_get_visual()), GDK_COLORMAP_XCOLORMAP(gdk_rgb_get_colormap()), gdk_rgb_get_visual()->depth); if (!xtbin->xtclient.xtdisplay) { /* If XtOpenDisplay failed, we can't go any further. * Bail out. */ #ifdef DEBUG_XTBIN OWB_PRINTF("gtk_xtbin_init: XtOpenDisplay() returned NULL.\n"); #endif g_free (xtbin); return (GtkWidget *)NULL; } /* If this is the first running widget, hook this display into the mainloop */ if (0 == num_widgets) { int cnumber; /* * hook Xt event loop into the glib event loop. */ /* the assumption is that gtk_init has already been called */ GSource* gs = g_source_new(&xt_event_funcs, sizeof(GSource)); if (!gs) { return NULL; } g_source_set_priority(gs, GDK_PRIORITY_EVENTS); g_source_set_can_recurse(gs, TRUE); tag = g_source_attach(gs, (GMainContext*)NULL); #ifdef VMS cnumber = XConnectionNumber(xtdisplay); #else cnumber = ConnectionNumber(xtdisplay); #endif xt_event_poll_fd.fd = cnumber; xt_event_poll_fd.events = G_IO_IN; xt_event_poll_fd.revents = 0; /* hmm... is this correct? */ g_main_context_add_poll ((GMainContext*)NULL, &xt_event_poll_fd, G_PRIORITY_LOW); /* add a timer so that we can poll and process Xt timers */ xt_polling_timer_id = gtk_timeout_add(25, (GtkFunction)xt_event_polling_timer_callback, xtdisplay); } /* Bump up our usage count */ num_widgets++; /* Build the hierachy */ xtbin->xtdisplay = xtbin->xtclient.xtdisplay; gtk_widget_set_parent_window(GTK_WIDGET(xtbin), parent_window); gdk_window_get_user_data(xtbin->parent_window, &user_data); if (user_data) gtk_container_add(GTK_CONTAINER(user_data), GTK_WIDGET(xtbin)); return GTK_WIDGET (xtbin); }
void ImageBuffer::putImageData(ImageData*, const IntRect&, const IntPoint&) { OWB_PRINTF("ImageBuffer::putImageData\n"); notImplemented(); }