X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Fxo-misc.c;h=cf63de78c3e2cfc1c8377f53bd7ac2d4b96f6b32;hb=b471a5e1ffc9ad87400f079679fdf261875d513e;hp=988811eb2291356b6f290935ca7acd0b300f834e;hpb=cfd5ddfe5127ac20d01bd85c96ff16e39ca47696;p=xournal.git diff --git a/src/xo-misc.c b/src/xo-misc.c index 988811e..cf63de7 100644 --- a/src/xo-misc.c +++ b/src/xo-misc.c @@ -414,12 +414,24 @@ void fix_xinput_coords(GdkEvent *event) double get_pressure_multiplier(GdkEvent *event) { + double *axes; double rawpressure; + GdkDevice *device; + + if (event->type == GDK_MOTION_NOTIFY) { + axes = event->motion.axes; + device = event->motion.device; + } + else { + axes = event->button.axes; + device = event->button.device; + } - if (event->button.device == gdk_device_get_core_pointer() - || event->button.device->num_axes <= 2) return 1.0; + if (device == gdk_device_get_core_pointer() + || device->num_axes <= 2) return 1.0; - rawpressure = event->button.axes[2]/(event->button.device->axes[2].max - event->button.device->axes[2].min); + rawpressure = axes[2]/(device->axes[2].max - device->axes[2].min); + if (!finite(rawpressure)) return 1.0; return ((1-rawpressure)*ui.width_minimum_multiplier + rawpressure*ui.width_maximum_multiplier); } @@ -653,7 +665,7 @@ void rescale_bg_pixmaps(void) // in progressive mode we scale only visible pages if (ui.progressive_bg && !is_visible(pg)) continue; - if (pg->bg->type == BG_PIXMAP && pg->bg->canvas_item!=NULL) { // do the rescaling ourselves + if (pg->bg->type == BG_PIXMAP && pg->bg->canvas_item!=NULL) { g_object_get(G_OBJECT(pg->bg->canvas_item), "pixbuf", &pix, NULL); if (pix!=pg->bg->pixbuf) gnome_canvas_item_set(pg->bg->canvas_item, "pixbuf", pg->bg->pixbuf, NULL); @@ -675,8 +687,8 @@ void rescale_bg_pixmaps(void) // request an asynchronous update to a better pixmap if needed zoom_to_request = MIN(ui.zoom, MAX_SAFE_RENDER_DPI/72.0); if (pg->bg->pixbuf_scale == zoom_to_request) continue; - add_bgpdf_request(pg->bg->file_page_seq, zoom_to_request); - pg->bg->pixbuf_scale = zoom_to_request; + if (add_bgpdf_request(pg->bg->file_page_seq, zoom_to_request)) + pg->bg->pixbuf_scale = zoom_to_request; } } } @@ -1104,12 +1116,9 @@ void update_mappings_menu_linkings(void) void update_mappings_menu(void) { gtk_widget_set_sensitive(GET_COMPONENT("optionsButtonMappings"), ui.use_xinput); - gtk_widget_set_sensitive(GET_COMPONENT("optionsDiscardCoreEvents"), ui.use_xinput); gtk_widget_set_sensitive(GET_COMPONENT("optionsPressureSensitive"), ui.use_xinput); gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsButtonMappings")), ui.use_erasertip); - gtk_check_menu_item_set_active( - GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsDiscardCoreEvents")), ui.discard_corepointer); gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("optionsPressureSensitive")), ui.pressure_sensitivity); @@ -1320,7 +1329,7 @@ void update_page_stuff(void) break; default: gtk_check_menu_item_set_active( - GTK_CHECK_MENU_ITEM(GET_COMPONENT("papercolorOther")), TRUE); + GTK_CHECK_MENU_ITEM(GET_COMPONENT("papercolorNA")), TRUE); break; } switch (ui.cur_page->bg->ruling) { @@ -1561,16 +1570,18 @@ void process_thickness_activate(GtkMenuItem *menuitem, int tool, int val) update_cursor(); } -void process_papercolor_activate(GtkMenuItem *menuitem, int color) +void process_papercolor_activate(GtkMenuItem *menuitem, int color, guint rgba) { struct Page *pg; GList *pglist; gboolean hasdone; - if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem))) - return; + if (GTK_OBJECT_TYPE(menuitem) == GTK_TYPE_RADIO_MENU_ITEM) { + if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM (menuitem))) + return; + } - if ((ui.cur_page->bg->type != BG_SOLID) || ui.bg_apply_all_pages) + if ((ui.cur_page->bg->type != BG_SOLID) || ui.bg_apply_all_pages || color == COLOR_OTHER) gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(GET_COMPONENT("papercolorNA")), TRUE); @@ -1578,7 +1589,7 @@ void process_papercolor_activate(GtkMenuItem *menuitem, int color) hasdone = FALSE; for (pglist = journal.pages; pglist!=NULL; pglist = pglist->next) { if (ui.bg_apply_all_pages) pg = (struct Page *)pglist->data; - if (pg->bg->type == BG_SOLID && pg->bg->color_no != color) { + if (pg->bg->type == BG_SOLID && pg->bg->color_rgba != rgba) { prepare_new_undo(); if (hasdone) undo->multiop |= MULTIOP_CONT_UNDO; undo->multiop |= MULTIOP_CONT_REDO; @@ -1589,7 +1600,7 @@ void process_papercolor_activate(GtkMenuItem *menuitem, int color) undo->bg->canvas_item = NULL; pg->bg->color_no = color; - pg->bg->color_rgba = predef_bgcolors_rgba[color]; + pg->bg->color_rgba = rgba; update_canvas_bg(pg); } if (!ui.bg_apply_all_pages) break; @@ -2014,7 +2025,6 @@ void hide_unimplemented(void) { gtk_widget_hide(GET_COMPONENT("filePrintOptions")); gtk_widget_hide(GET_COMPONENT("journalFlatten")); - gtk_widget_hide(GET_COMPONENT("papercolorOther")); gtk_widget_hide(GET_COMPONENT("toolsSelectRegion")); gtk_widget_hide(GET_COMPONENT("buttonSelectRegion")); gtk_widget_hide(GET_COMPONENT("button2SelectRegion")); @@ -2110,17 +2120,6 @@ gboolean fix_extended_events (GtkWidget *widget, GdkEvent *event, } */ -// disable xinput when layer combo box is popped up, to avoid GTK+ 2.17 crash - -gboolean combobox_popup_disable_xinput (GtkWidget *widget, GdkEvent *event, - gpointer user_data) -{ - gboolean is_shown; - - g_object_get(G_OBJECT(widget), "popup-shown", &is_shown, NULL); - gtk_widget_set_extension_events(GTK_WIDGET (canvas), - (ui.use_xinput && !is_shown)?GDK_EXTENSION_EVENTS_ALL:GDK_EXTENSION_EVENTS_NONE); -} /* When enter is pressed into page spinbox, send focus back to canvas. */