struct PP_Var ppb_instance_private_execute_script(PP_Instance instance, struct PP_Var script, struct PP_Var *exception) { if (script.type != PP_VARTYPE_STRING) { trace_error("%s, 'script' is not a string\n", __func__); // TODO: fill exception return PP_MakeUndefined(); } struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_MakeUndefined(); } struct execute_script_param_s p; p.script = script; p.pp_i = pp_i; p.m_loop = ppb_message_loop_get_current(); p.depth = ppb_message_loop_get_depth(p.m_loop) + 1; ppb_var_add_ref(script); ppb_message_loop_post_work(p.m_loop, PP_MakeCompletionCallback(_execute_script_comt, &p), 0); ppb_message_loop_run_int(p.m_loop, 1); ppb_var_release(script); return p.result; }
static void set_text_input_type_ptac(void *param) { struct set_text_input_type_param_s *p = param; struct pp_instance_s *pp_i = tables_get_pp_instance(p->instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return; } if (pp_i->im_context) gw_gtk_im_context_focus_out(pp_i->im_context); switch (p->type) { case PP_TEXTINPUT_TYPE_DEV_NONE: case PP_TEXTINPUT_TYPE_DEV_PASSWORD: pp_i->im_context = NULL; break; case PP_TEXTINPUT_TYPE_DEV_TEXT: pp_i->im_context = pp_i->im_context_multi; break; default: pp_i->im_context = pp_i->im_context_simple; break; } pp_i->textinput_type = p->type; if (pp_i->im_context) gw_gtk_im_context_focus_in(pp_i->im_context); g_slice_free1(sizeof(*p), p); }
PP_Resource ppb_keyboard_input_event_create_1_2(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, uint32_t key_code, struct PP_Var character_text, struct PP_Var code) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource input_event = pp_resource_allocate(PP_RESOURCE_INPUT_EVENT, pp_i); struct pp_input_event_s *ie = pp_resource_acquire(input_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, can't allocate memory\n", __func__); return 0; } ie->event_class = PP_INPUTEVENT_CLASS_KEYBOARD; ie->type = type; ie->time_stamp = time_stamp; ie->modifiers = modifiers; ie->key_code = key_code; ie->character_text = character_text; ie->code = code; ppb_var_add_ref(character_text); ppb_var_add_ref(code); pp_resource_release(input_event); return input_event; }
PP_Resource ppb_device_ref_create(PP_Instance instance, struct PP_Var name, struct PP_Var longname, PP_DeviceType_Dev type) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource device_ref = pp_resource_allocate(PP_RESOURCE_DEVICE_REF, pp_i); struct pp_device_ref_s *dr = pp_resource_acquire(device_ref, PP_RESOURCE_DEVICE_REF); if (!dr) { trace_error("%s, resource allocation failure\n", __func__); return 0; } // no type checking is perfomed as it's an internal function dr->name = ppb_var_add_ref2(name); dr->longname = ppb_var_add_ref2(longname); dr->type = type; pp_resource_release(device_ref); return device_ref; }
PP_Resource ppb_image_data_create(PP_Instance instance, PP_ImageDataFormat format, const struct PP_Size *size, PP_Bool init_to_zero) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource image_data = pp_resource_allocate(PP_RESOURCE_IMAGE_DATA, pp_i); struct pp_image_data_s *id = pp_resource_acquire(image_data, PP_RESOURCE_IMAGE_DATA); if (!id) { trace_error("%s, failed to create image data resource\n", __func__); return 0; } id->format = format; id->width = size->width; id->height = size->height; id->stride = id->width * 4; (void)init_to_zero; // ignore flag, always clear memory id->data = calloc(id->stride * id->height, 1); if (!id->data) { pp_resource_release(image_data); ppb_core_release_resource(image_data); trace_error("%s, can't allocate memory for image\n", __func__); return 0; } id->cairo_surf = cairo_image_surface_create_for_data((void *)id->data, CAIRO_FORMAT_ARGB32, id->width, id->height, id->stride); pp_resource_release(image_data); return image_data; }
// Schedules task for execution on browser thread. // // Since there is no access to browser event loop, we start a nested event loop which is terminated // as long as there is no tasks left. That way we can implement waiting as entering a nested loop // and thus avoid deadlocks. void ppb_core_call_on_browser_thread(PP_Instance instance, void (*func)(void *), void *user_data) { struct call_on_browser_thread_task_s *task = g_slice_alloc(sizeof(*task)); task->func = func; task->user_data = user_data; // Push task into queue. The only purpose is to put task into queue even if message loop // is currenly terminating (in teardown state), so we are ignoring that. There are three // possible loop states. Message loop is either running, stopped, or terminating. If it's // still running, task will be executed in the context of that loop. If it's stopped or // stopping right now, task will be pushed to a queue. After that code below will schedule // nested loop on browser thread. PP_Resource m_loop = ppb_message_loop_get_for_browser_thread(); ppb_message_loop_post_work_with_result(m_loop, PP_MakeCCB(call_on_browser_thread_comt, task), 0, PP_OK, 0, __func__); struct pp_instance_s *pp_i = instance ? tables_get_pp_instance(instance) : tables_get_some_pp_instance(); if (!pp_i) { trace_error("%s, no alive instance available\n", __func__); return; } // Schedule activation routine. pthread_mutex_lock(&display.lock); if (pp_i->npp) npn.pluginthreadasynccall(pp_i->npp, activate_browser_thread_ml_ptac, user_data); pthread_mutex_unlock(&display.lock); }
PP_Resource ppb_video_capture_create(PP_Instance instance) { const struct PPP_VideoCapture_Dev_0_1 *ppp_video_capture_dev; struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } ppp_video_capture_dev = ppp_get_interface(PPP_VIDEO_CAPTURE_DEV_INTERFACE_0_1); if (!ppp_video_capture_dev) { trace_error("%s, no viable %s\n", __func__, PPP_VIDEO_CAPTURE_DEV_INTERFACE_0_1); return 0; } PP_Resource video_capture = pp_resource_allocate(PP_RESOURCE_VIDEO_CAPTURE, pp_i); struct pp_video_capture_s *vc = pp_resource_acquire(video_capture, PP_RESOURCE_VIDEO_CAPTURE); if (!vc) { trace_error("%s, resource allocation failure\n", __func__); return 0; } vc->fd = -1; vc->ppp_video_capture_dev = ppp_video_capture_dev; pp_resource_release(video_capture); return video_capture; }
PP_Resource ppb_url_request_info_create(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource request_info = pp_resource_allocate(PP_RESOURCE_URL_REQUEST_INFO, pp_i); struct pp_url_request_info_s *ri = pp_resource_acquire(request_info, PP_RESOURCE_URL_REQUEST_INFO); if (!ri) { trace_error("%s, resource allocation failure\n", __func__); return 0; } ri->method = PP_METHOD_UNKNOWN; ri->url = NULL; ri->headers = NULL; ri->stream_to_file = PP_FALSE; ri->follow_redirects = PP_TRUE; ri->record_download_progress = PP_FALSE; ri->record_upload_progress = PP_FALSE; ri->custom_referrer_url = NULL; ri->allow_cross_origin_requests = PP_FALSE; ri->allow_credentials = PP_FALSE; ri->custom_content_transfer_encoding = NULL; ri->prefetch_buffer_upper_threshold = -1; ri->prefetch_buffer_lower_threshold = -1; ri->custom_user_agent = NULL; ri->post_data = post_data_new(); pp_resource_release(request_info); return request_info; }
PP_Resource ppb_flash_menu_create(PP_Instance instance_id, const struct PP_Flash_Menu *menu_data) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance_id); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource flash_menu = pp_resource_allocate(PP_RESOURCE_FLASH_MENU, pp_i); if (pp_resource_get_type(flash_menu) != PP_RESOURCE_FLASH_MENU) { trace_error("%s, resource allocation failure\n", __func__); return 0; } struct flash_menu_create_param_s *p = g_slice_alloc0(sizeof(*p)); p->flash_menu = flash_menu; p->menu_data = menu_data; p->m_loop = ppb_message_loop_get_current(); p->depth = ppb_message_loop_get_depth(p->m_loop) + 1; ppb_message_loop_post_work_with_result(p->m_loop, PP_MakeCCB(flash_menu_create_comt, p), 0, PP_OK, p->depth, __func__); ppb_message_loop_run_nested(p->m_loop); g_slice_free1(sizeof(*p), p); return flash_menu; }
static void call_forceredraw_ptac(void *param) { struct pp_instance_s *pp_i = tables_get_pp_instance(GPOINTER_TO_SIZE(param)); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return; } if (pp_i->is_fullscreen || pp_i->windowed_mode) { XEvent ev = { .xgraphicsexpose = { .type = GraphicsExpose, .drawable = pp_i->is_fullscreen ? pp_i->fs_wnd : pp_i->wnd, .width = pp_i->is_fullscreen ? pp_i->fs_width : pp_i->width, .height = pp_i->is_fullscreen ? pp_i->fs_height : pp_i->height, } }; pthread_mutex_lock(&display.lock); XSendEvent(display.x, ev.xgraphicsexpose.drawable, True, ExposureMask, &ev); XFlush(display.x); pthread_mutex_unlock(&display.lock); } else {
PP_Resource ppb_wheel_input_event_create(PP_Instance instance, PP_TimeTicks time_stamp, uint32_t modifiers, const struct PP_FloatPoint *wheel_delta, const struct PP_FloatPoint *wheel_ticks, PP_Bool scroll_by_page) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource input_event = pp_resource_allocate(PP_RESOURCE_INPUT_EVENT, pp_i); struct pp_input_event_s *ie = pp_resource_acquire(input_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, can't allocate memory\n", __func__); return 0; } ie->event_class = PP_INPUTEVENT_CLASS_WHEEL; ie->time_stamp = time_stamp; ie->modifiers = modifiers; ie->wheel_delta.x = wheel_delta ? wheel_delta->x : 0; ie->wheel_delta.y = wheel_delta ? wheel_delta->y : 0; ie->wheel_ticks.x = wheel_ticks ? wheel_ticks->x : 0; ie->wheel_ticks.y = wheel_ticks ? wheel_ticks->y : 0; ie->scroll_by_page = scroll_by_page; pp_resource_release(input_event); return input_event; }
PP_Resource ppb_mouse_input_event_create(PP_Instance instance, PP_InputEvent_Type type, PP_TimeTicks time_stamp, uint32_t modifiers, PP_InputEvent_MouseButton mouse_button, const struct PP_Point *mouse_position, int32_t click_count, const struct PP_Point *mouse_movement) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource input_event = pp_resource_allocate(PP_RESOURCE_INPUT_EVENT, pp_i); struct pp_input_event_s *ie = pp_resource_acquire(input_event, PP_RESOURCE_INPUT_EVENT); if (!ie) { trace_error("%s, can't allocate memory\n", __func__); return 0; } ie->event_class = PP_INPUTEVENT_CLASS_MOUSE; ie->type = type; ie->time_stamp = time_stamp; ie->modifiers = modifiers; ie->mouse_button = mouse_button; ie->mouse_position.x = mouse_position ? mouse_position->x : 0; ie->mouse_position.y = mouse_position ? mouse_position->y : 0; ie->click_count = click_count; ie->mouse_movement.x = mouse_movement ? mouse_movement->x : 0; ie->mouse_movement.y = mouse_movement ? mouse_movement->y : 0; pp_resource_release(input_event); return input_event; }
PP_Resource ppb_graphics2d_create(PP_Instance instance, const struct PP_Size *size, PP_Bool is_always_opaque) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource graphics_2d = pp_resource_allocate(PP_RESOURCE_GRAPHICS2D, pp_i); struct pp_graphics2d_s *g2d = pp_resource_acquire(graphics_2d, PP_RESOURCE_GRAPHICS2D); if (!g2d) { trace_error("%s, can't create graphics2d resource\n", __func__); return 0; } g2d->is_always_opaque = is_always_opaque; g2d->scale = config.device_scale; g2d->width = size->width; g2d->height = size->height; g2d->stride = 4 * size->width; g2d->scaled_width = g2d->width * g2d->scale + 0.5; g2d->scaled_height = g2d->height * g2d->scale + 0.5; g2d->scaled_stride = 4 * g2d->scaled_width; g2d->data = calloc(g2d->stride * g2d->height, 1); g2d->second_buffer = calloc(g2d->scaled_stride * g2d->scaled_height, 1); if (!g2d->data || !g2d->second_buffer) { trace_warning("%s, can't allocate memory\n", __func__); free_and_nullify(g2d->data); free_and_nullify(g2d->second_buffer); pp_resource_release(graphics_2d); ppb_core_release_resource(graphics_2d); return 0; } g2d->cairo_surf = cairo_image_surface_create_for_data((unsigned char *)g2d->data, CAIRO_FORMAT_ARGB32, g2d->width, g2d->height, g2d->stride); g2d->task_list = NULL; if (pp_i->is_transparent) { // we need XRender picture (which in turn requires X Pixmap) to alpha blend // our images with existing pixmap provided by the browser. This is only needed // is instance is transparent, therefore depth is always 32-bit. pthread_mutex_lock(&display.lock); g2d->pixmap = XCreatePixmap(display.x, DefaultRootWindow(display.x), g2d->scaled_width, g2d->scaled_height, 32); XFlush(display.x); g2d->xr_pict = XRenderCreatePicture(display.x, g2d->pixmap, display.pictfmt_argb32, 0, 0); g2d->gc = XCreateGC(display.x, g2d->pixmap, 0, 0); XFlush(display.x); pthread_mutex_unlock(&display.lock); } pp_resource_release(graphics_2d); return graphics_2d; }
static PP_Resource do_ppb_audio_create(PP_Instance instance, PP_Resource audio_config, PPB_Audio_Callback_1_0 audio_callback_1_0, PPB_Audio_Callback audio_callback_1_1, void *user_data) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } if (!audio_callback_1_0 && !audio_callback_1_1) return PP_ERROR_BADARGUMENT; PP_Resource audio = pp_resource_allocate(PP_RESOURCE_AUDIO, pp_i); struct pp_audio_s *a = pp_resource_acquire(audio, PP_RESOURCE_AUDIO); if (!a) { trace_error("%s, resource allocation failure\n", __func__); return 0; } struct pp_audio_config_s *ac = pp_resource_acquire(audio_config, PP_RESOURCE_AUDIO_CONFIG); if (!ac) { trace_error("%s, bad audio config\n", __func__); goto err; } a->sample_rate = ac->sample_rate; a->sample_frame_count = ac->sample_frame_count; pp_resource_release(audio_config); a->callback_1_0 = audio_callback_1_0; a->callback_1_1 = audio_callback_1_1; a->user_data = user_data; a->stream_ops = audio_select_implementation(); if (a->stream_ops == NULL) { trace_error("%s, no viable audio implementation\n", __func__); goto err; } a->stream = a->stream_ops->create_playback_stream(a->sample_rate, a->sample_frame_count, playback_cb, a); if (!a->stream) { trace_error("%s, can't create playback stream\n", __func__); goto err; } pp_resource_release(audio); return audio; err: pp_resource_release(audio); pp_resource_expunge(audio); return 0; }
PP_Resource ppb_flash_message_loop_create(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource message_loop = pp_resource_allocate(PP_RESOURCE_FLASH_MESSAGE_LOOP, pp_i); return message_loop; }
PP_Resource ppb_printing_create(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource printing = pp_resource_allocate(PP_RESOURCE_PRINTING, pp_i); return printing; }
PP_Resource ppb_network_monitor_create(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource network_monitor = pp_resource_allocate(PP_RESOURCE_NETWORK_MONITOR, pp_i); return network_monitor; }
struct PP_Var ppb_instance_private_get_window_object(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_MakeUndefined(); } npn.retainobject(pp_i->np_window_obj); // TODO: call on browser thread? return ppb_var_create_object(instance, &n2p_proxy_class, pp_i->np_window_obj); }
struct PP_Var ppb_url_util_dev_get_plugin_instance_url(PP_Instance instance, struct PP_URLComponents_Dev *components) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); struct PP_Var var = PP_MakeString(pp_i->instance_url); if (components) parse_url_string(ppb_var_var_to_utf8(var, NULL), components); return var; }
PP_Bool ppb_instance_bind_graphics(PP_Instance instance, PP_Resource device) { PP_Bool retval; struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_FALSE; } if (device == 0) { // unbind pthread_mutex_lock(&pp_i->lock); pp_i->graphics = 0; pthread_mutex_unlock(&pp_i->lock); return PP_TRUE; } struct pp_graphics2d_s *g2d = pp_resource_acquire(device, PP_RESOURCE_GRAPHICS2D); struct pp_graphics3d_s *g3d = pp_resource_acquire(device, PP_RESOURCE_GRAPHICS3D); if (g2d) { if (pp_i != g2d->instance) { retval = PP_FALSE; goto done; } pthread_mutex_lock(&pp_i->lock); pp_i->graphics = device; pthread_mutex_unlock(&pp_i->lock); retval = PP_TRUE; } else if (g3d) { if (pp_i != g3d->instance) { retval = PP_FALSE; goto done; } pthread_mutex_lock(&pp_i->lock); pp_i->graphics = device; pthread_mutex_unlock(&pp_i->lock); pp_resource_release(device); retval = PP_TRUE; } else { trace_warning("%s, unsupported graphics resource %d on instance %d\n", __func__, device, instance); retval = PP_FALSE; } done: pp_resource_release(device); return retval; }
PP_Resource ppb_host_resolver_create(PP_Instance instance) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return 0; } PP_Resource host_resolver = pp_resource_allocate(PP_RESOURCE_HOST_RESOLVER, pp_i); return host_resolver; }
static void topmost_rect_ptac(void *param) { struct topmost_rect_param_s *p = param; struct pp_instance_s *pp_i = tables_get_pp_instance(p->instance); if (!pp_i) { trace_error("%s, no instance\n", __func__); goto err_1; } p->result = PP_FALSE; NPString topmost_func_src = NPString_literal( "(function(elem, x, y) {" "var r = elem.getBoundingClientRect();" "return document.elementFromPoint(x + r.left, y + r.top) == elem;" "})"); NPVariant topmost_func; if (!npn.evaluate(pp_i->npp, pp_i->np_window_obj, &topmost_func_src, &topmost_func)) goto err_1; if (!NPVARIANT_IS_OBJECT(topmost_func)) goto err_1; NPObject *topmost_func_obj = NPVARIANT_TO_OBJECT(topmost_func); NPVariant is_topmost; NPVariant args[3]; OBJECT_TO_NPVARIANT(pp_i->np_plugin_element_obj, args[0]); INT32_TO_NPVARIANT(p->rect.point.x + p->rect.size.width / 2, args[1]); INT32_TO_NPVARIANT(p->rect.point.y + p->rect.size.height / 2, args[2]); if (!npn.invokeDefault(pp_i->npp, topmost_func_obj, args, 3, &is_topmost)) goto err_2; if (!NPVARIANT_IS_BOOLEAN(is_topmost)) goto err_3; p->result = NPVARIANT_TO_BOOLEAN(is_topmost); err_3: npn.releasevariantvalue(&is_topmost); err_2: npn.releasevariantvalue(&topmost_func); err_1: ppb_message_loop_post_quit_depth(p->m_loop, PP_FALSE, p->depth); }
static void cancel_composition_text_ptac(void *param) { PP_Instance instance = GPOINTER_TO_SIZE(param); struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return; } if (pp_i->im_context) gw_gtk_im_context_reset(pp_i->im_context); }
int32_t ppb_input_event_request_filtering_input_events(PP_Instance instance, uint32_t event_classes) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_ERROR_BADARGUMENT; } pthread_mutex_lock(&display.lock); pp_i->filtered_event_mask |= event_classes; pthread_mutex_unlock(&display.lock); return PP_OK; }
void ppb_input_event_clear_input_event_request(PP_Instance instance, uint32_t event_classes) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return; } pthread_mutex_lock(&display.lock); pp_i->event_mask &= ~event_classes; pp_i->filtered_event_mask &= ~event_classes; pthread_mutex_unlock(&display.lock); return; }
static void update_instance_playing_audio_status_ptac(void *p) { PP_Instance instance = GPOINTER_TO_SIZE(p); struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) return; int is_playing_audio = g_atomic_int_get(&pp_i->audio_source_count) > 0; NPError err = npn.setvalue(pp_i->npp, NPPVpluginIsPlayingAudio, GINT_TO_POINTER(is_playing_audio)); if (err != NPERR_NO_ERROR) trace_info_f("%s, failed to set NPPVpluginIsPlayingAudio\n", __func__); }
void set_cursor_ptac(void *user_data) { Window wnd = None; Cursor cursor; struct comt_param_s *params = user_data; struct pp_instance_s *pp_i = tables_get_pp_instance(params->instance_id); if (!pp_i) goto quit; if (pp_i->is_fullscreen) { wnd = pp_i->fs_wnd; } else if (pp_i->windowed_mode) { wnd = pp_i->wnd; } else { if (npn.getvalue(pp_i->npp, NPNVnetscapeWindow, &wnd) != NPERR_NO_ERROR) wnd = None; } pthread_mutex_lock(&display.lock); if (params->hide_cursor) { cursor = display.transparent_cursor; } else { if (params->custom_image != 0) { cursor = create_cursor_from_image_data_resource(display.x, wnd, params->custom_image, params->hotspot_x, params->hotspot_y); } else { cursor = XCreateFontCursor(display.x, params->xtype); } } if (wnd != None && cursor != None) { XDefineCursor(display.x, wnd, cursor); XFlush(display.x); // remember to free cursor unless we hid it pp_i->have_prev_cursor = !params->hide_cursor; pp_i->prev_cursor = cursor; } pthread_mutex_unlock(&display.lock); quit: g_slice_free(struct comt_param_s, params); }
struct PP_Var ppb_url_util_dev_get_document_url(PP_Instance instance, struct PP_URLComponents_Dev *components) { struct pp_instance_s *pp_i = tables_get_pp_instance(instance); struct PP_Var result = PP_MakeString(""); NPIdentifier location_id = npn.getstringidentifier("location"); NPIdentifier href_id = npn.getstringidentifier("href"); NPObject *np_window_obj, *np_location_obj; NPVariant location_var, href_var; if (npn.getvalue(pp_i->npp, NPNVWindowNPObject, &np_window_obj) != NPERR_NO_ERROR) goto err_1; if (!npn.getproperty(pp_i->npp, np_window_obj, location_id, &location_var)) goto err_2; if (location_var.type != NPVariantType_Object) goto err_3; np_location_obj = location_var.value.objectValue; if (!npn.getproperty(pp_i->npp, np_location_obj, href_id, &href_var)) goto err_3; struct PP_Var var = np_variant_to_pp_var(href_var); if (var.type != PP_VARTYPE_STRING) { ppb_var_release(var); goto err_4; } ppb_var_release(result); result = var; if (components) parse_url_string(ppb_var_var_to_utf8(result, NULL), components); err_4: npn.releasevariantvalue(&href_var); err_3: npn.releasevariantvalue(&location_var); err_2: npn.releaseobject(np_window_obj); err_1: return result; }
static void selection_changed_comt(void *user_data, int32_t result) { PP_Instance instance = GPOINTER_TO_SIZE(user_data); struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return; } if (!pp_i->ppp_text_input_dev) pp_i->ppp_text_input_dev = ppp_get_interface(PPP_TEXTINPUT_DEV_INTERFACE_0_1); if (pp_i->ppp_text_input_dev) pp_i->ppp_text_input_dev->RequestSurroundingText(pp_i->id, 100); }
struct PP_Var ppb_flash_get_setting(PP_Instance instance, PP_FlashSetting setting) { long cpu_count; struct pp_instance_s *pp_i = tables_get_pp_instance(instance); if (!pp_i) { trace_error("%s, bad instance\n", __func__); return PP_MakeUndefined(); } struct PP_Var var = PP_MakeUndefined(); switch (setting) { case PP_FLASHSETTING_3DENABLED: var.type = PP_VARTYPE_BOOL; var.value.as_bool = config.enable_3d ? PP_TRUE : PP_FALSE; break; case PP_FLASHSETTING_INCOGNITO: var.type = PP_VARTYPE_BOOL; var.value.as_bool = pp_i->incognito_mode ? PP_TRUE : PP_FALSE; break; case PP_FLASHSETTING_STAGE3DENABLED: var.type = PP_VARTYPE_BOOL; var.value.as_bool = config.enable_3d ? PP_TRUE : PP_FALSE; break; case PP_FLASHSETTING_LANGUAGE: var = get_flashsetting_language(); break; case PP_FLASHSETTING_NUMCORES: cpu_count = sysconf(_SC_NPROCESSORS_ONLN); var.type = PP_VARTYPE_INT32; var.value.as_int = cpu_count > 0 ? cpu_count : 1; break; case PP_FLASHSETTING_LSORESTRICTIONS: var.type = PP_VARTYPE_INT32; var.value.as_int = PP_FLASHLSORESTRICTIONS_NONE; break; case PP_FLASHSETTING_STAGE3DBASELINEENABLED: // TODO: check if driver reliable enough var.type = PP_VARTYPE_BOOL; var.value.as_bool = PP_FALSE; break; } return var; }