diff options
Diffstat (limited to 'src/fe-gtk')
-rw-r--r-- | src/fe-gtk/Makefile.am | 8 | ||||
-rw-r--r-- | src/fe-gtk/fe-gtk.c | 52 | ||||
-rw-r--r-- | src/fe-gtk/fe-gtk.vcxproj | 1 | ||||
-rw-r--r-- | src/fe-gtk/fe-gtk.vcxproj.filters | 3 | ||||
-rw-r--r-- | src/fe-gtk/fkeys.c | 4 | ||||
-rw-r--r-- | src/fe-gtk/maingui.c | 29 | ||||
-rw-r--r-- | src/fe-gtk/mmx_cmod.S | 530 | ||||
-rw-r--r-- | src/fe-gtk/mmx_cmod.h | 28 | ||||
-rw-r--r-- | src/fe-gtk/rawlog.c | 3 | ||||
-rw-r--r-- | src/fe-gtk/setup.c | 33 | ||||
-rw-r--r-- | src/fe-gtk/textgui.c | 3 | ||||
-rw-r--r-- | src/fe-gtk/xtext.c | 1270 | ||||
-rw-r--r-- | src/fe-gtk/xtext.h | 38 |
13 files changed, 50 insertions, 1952 deletions
diff --git a/src/fe-gtk/Makefile.am b/src/fe-gtk/Makefile.am index 24098ace..88e3dfea 100644 --- a/src/fe-gtk/Makefile.am +++ b/src/fe-gtk/Makefile.am @@ -9,14 +9,10 @@ hexchat_LDADD = ../common/libhexchatcommon.a $(GUI_LIBS) EXTRA_DIST = \ ascii.h banlist.h chanlist.h chanview.h chanview-tabs.c \ chanview-tree.c custom-list.h editlist.h fe-gtk.h fkeys.h gtkutil.h joind.h \ - maingui.h menu.h mmx_cmod.S mmx_cmod.h notifygui.h palette.h pixmaps.h \ + maingui.h menu.h notifygui.h palette.h pixmaps.h \ plugin-tray.h plugingui.c plugingui.h rawlog.h sexy-iso-codes.h \ sexy-spell-entry.h sexy-marshal.h textgui.h urlgrab.h userlistgui.h xtext.h -if USE_MMX -mmx_cmod_S = mmx_cmod.S -endif - if DO_PLUGIN plugingui_c = plugingui.c endif @@ -28,6 +24,6 @@ endif hexchat_SOURCES = ascii.c banlist.c chanlist.c chanview.c custom-list.c \ dccgui.c editlist.c fe-gtk.c fkeys.c gtkutil.c ignoregui.c joind.c menu.c \ - maingui.c $(mmx_cmod_S) notifygui.c palette.c pixmaps.c plugin-tray.c $(plugingui_c) \ + maingui.c notifygui.c palette.c pixmaps.c plugin-tray.c $(plugingui_c) \ rawlog.c servlistgui.c setup.c $(sexy_spell) textgui.c \ urlgrab.c userlistgui.c xtext.c diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index 5f811339..7fce696c 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -52,10 +52,6 @@ #include "urlgrab.h" #include "setup.h" -#ifdef USE_XLIB -#include <gdk/gdkx.h> -#endif - #ifdef USE_LIBCANBERRA #include <canberra.h> #endif @@ -66,49 +62,6 @@ GdkPixmap *channelwin_pix; static ca_context *ca_con; #endif -#ifdef USE_XLIB - -static void -redraw_trans_xtexts (void) -{ - GSList *list = sess_list; - session *sess; - int done_main = FALSE; - - while (list) - { - sess = list->data; - if (GTK_XTEXT (sess->gui->xtext)->transparent) - { - if (!sess->gui->is_tab || !done_main) - gtk_xtext_refresh (GTK_XTEXT (sess->gui->xtext), 1); - if (sess->gui->is_tab) - done_main = TRUE; - } - list = list->next; - } -} - -static GdkFilterReturn -root_event_cb (GdkXEvent *xev, GdkEventProperty *event, gpointer data) -{ - static Atom at = None; - XEvent *xevent = (XEvent *)xev; - - if (xevent->type == PropertyNotify) - { - if (at == None) - at = XInternAtom (xevent->xproperty.display, "_XROOTPMAP_ID", True); - - if (at == xevent->xproperty.atom) - redraw_trans_xtexts (); - } - - return GDK_FILTER_CONTINUE; -} - -#endif - /* === command-line parameter parsing : requires glib 2.6 === */ static char *arg_cfgdir = NULL; @@ -281,11 +234,6 @@ fe_args (int argc, char *argv[]) gtk_init (&argc, &argv); -#ifdef USE_XLIB - gdk_window_set_events (gdk_get_default_root_window (), GDK_PROPERTY_CHANGE_MASK); - gdk_window_add_filter (gdk_get_default_root_window (), (GdkFilterFunc)root_event_cb, NULL); -#endif - return -1; } diff --git a/src/fe-gtk/fe-gtk.vcxproj b/src/fe-gtk/fe-gtk.vcxproj index c8aa1550..a7c40a19 100644 --- a/src/fe-gtk/fe-gtk.vcxproj +++ b/src/fe-gtk/fe-gtk.vcxproj @@ -110,7 +110,6 @@ <ClInclude Include="joind.h" /> <ClInclude Include="maingui.h" /> <ClInclude Include="menu.h" /> - <ClInclude Include="mmx_cmod.h" /> <ClInclude Include="notifygui.h" /> <ClInclude Include="palette.h" /> <ClInclude Include="pixmaps.h" /> diff --git a/src/fe-gtk/fe-gtk.vcxproj.filters b/src/fe-gtk/fe-gtk.vcxproj.filters index 424f7564..e1de7844 100644 --- a/src/fe-gtk/fe-gtk.vcxproj.filters +++ b/src/fe-gtk/fe-gtk.vcxproj.filters @@ -51,9 +51,6 @@ <ClInclude Include="menu.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="mmx_cmod.h"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="notifygui.h"> <Filter>Header Files</Filter> </ClInclude> diff --git a/src/fe-gtk/fkeys.c b/src/fe-gtk/fkeys.c index beacd532..054e919c 100644 --- a/src/fe-gtk/fkeys.c +++ b/src/fe-gtk/fkeys.c @@ -804,10 +804,6 @@ key_dialog_show () gtk_box_pack_end (GTK_BOX (vbox), hbox2, 0, 0, 1); wid = gtk_xtext_new (colors, 0); - gtk_xtext_set_tint (GTK_XTEXT (wid), prefs.hex_text_tint_red, prefs.hex_text_tint_green, prefs.hex_text_tint_blue); - gtk_xtext_set_background (GTK_XTEXT (wid), - channelwin_pix, - prefs.hex_text_transparent); gtk_widget_set_usize (wid, 0, 75); gtk_box_pack_start (GTK_BOX (hbox2), wid, 1, 1, 1); gtk_xtext_set_font (GTK_XTEXT (wid), prefs.hex_text_font); diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index a537da6f..62cd803b 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -529,9 +529,6 @@ mg_configure_cb (GtkWidget *wid, GdkEventConfigure *event, session *sess) gtk_window_get_size (GTK_WINDOW (wid), &prefs.hex_gui_dialog_width, &prefs.hex_gui_dialog_height); } - - if (((GtkXText *) sess->gui->xtext)->transparent) - gtk_widget_queue_draw (sess->gui->xtext); } return FALSE; @@ -1504,7 +1501,7 @@ mg_create_color_menu (GtkWidget *menu, session *sess) mg_markup_item (submenu, _("<b>Bold</b>"), 100); mg_markup_item (submenu, _("<u>Underline</u>"), 101); - /*mg_markup_item (submenu, _("<i>Italic</i>"), 102);*/ + mg_markup_item (submenu, _("<i>Italic</i>"), 102); mg_markup_item (submenu, _("Normal"), 103); subsubmenu = mg_submenu (submenu, _("Colors 0-7")); @@ -2333,8 +2330,7 @@ mg_update_xtext (GtkWidget *wid) gtk_xtext_set_palette (xtext, colors); gtk_xtext_set_max_lines (xtext, prefs.hex_text_max_lines); - gtk_xtext_set_tint (xtext, prefs.hex_text_tint_red, prefs.hex_text_tint_green, prefs.hex_text_tint_blue); - gtk_xtext_set_background (xtext, channelwin_pix, prefs.hex_text_transparent); + gtk_xtext_set_background (xtext, channelwin_pix); gtk_xtext_set_wordwrap (xtext, prefs.hex_text_wordwrap); gtk_xtext_set_show_marker (xtext, prefs.hex_text_show_marker); gtk_xtext_set_show_separator (xtext, prefs.hex_text_indent ? prefs.hex_text_show_sep : 0); @@ -2345,23 +2341,7 @@ mg_update_xtext (GtkWidget *wid) exit (1); } - gtk_xtext_refresh (xtext, FALSE); -} - -/* handle errors reported by xtext */ - -static void -mg_xtext_error (int type) -{ - switch (type) - { - case 0: - fe_message (_("Unable to set transparent background!\n\n" - "You may be using a non-compliant window\n" - "manager that is not currently supported.\n"), FE_MSG_WARN); - prefs.hex_text_transparent = 0; - /* no others exist yet */ - } + gtk_xtext_refresh (xtext); } static void @@ -2394,7 +2374,6 @@ mg_create_textarea (session *sess, GtkWidget *box) xtext = GTK_XTEXT (gui->xtext); gtk_xtext_set_max_indent (xtext, prefs.hex_text_max_indent); gtk_xtext_set_thin_separator (xtext, prefs.hex_text_thin_sep); - gtk_xtext_set_error_function (xtext, mg_xtext_error); gtk_xtext_set_urlcheck_function (xtext, mg_word_check); gtk_xtext_set_max_lines (xtext, prefs.hex_text_max_lines); gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (xtext)); @@ -3207,6 +3186,7 @@ mg_create_topwindow (session *sess) prefs.hex_gui_win_height, 0); sess->gui->window = win; gtk_container_set_border_width (GTK_CONTAINER (win), GUI_BORDER); + gtk_window_set_opacity (GTK_WINDOW (win), (prefs.hex_gui_transparency / 255.)); g_signal_connect (G_OBJECT (win), "focus_in_event", G_CALLBACK (mg_topwin_focus_cb), sess); @@ -3311,6 +3291,7 @@ mg_create_tabwindow (session *sess) gtk_window_maximize (GTK_WINDOW (win)); if (prefs.hex_gui_win_fullscreen) gtk_window_fullscreen (GTK_WINDOW (win)); + gtk_window_set_opacity (GTK_WINDOW (win), (prefs.hex_gui_transparency / 255.)); gtk_container_set_border_width (GTK_CONTAINER (win), GUI_BORDER); g_signal_connect (G_OBJECT (win), "delete_event", diff --git a/src/fe-gtk/mmx_cmod.S b/src/fe-gtk/mmx_cmod.S deleted file mode 100644 index 12e866de..00000000 --- a/src/fe-gtk/mmx_cmod.S +++ /dev/null @@ -1,530 +0,0 @@ -/* - * Copyright (C) 1997-2001, Michael Jennings - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies of the Software, its documentation and marketing & publicity - * materials, and acknowledgment shall be given in the documentation, materials - * and software packages that this Software was used. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/* MMX routines for tinting XImages written by Willem Monsuwe <willem@stack.nl> */ - -/* Function calling conventions: - * shade_ximage_xx(void *data, int bpl, int w, int h, int rm, int gm, int bm); - */ - -#define data 8(%ebp) -#define bpl 12(%ebp) -#define w 16(%ebp) -#define h 20(%ebp) -#define rm 24(%ebp) -#define gm 28(%ebp) -#define bm 32(%ebp) - -#ifdef UNDERSCORE_SYMBOLS /* need this to link with msvc */ -#define SHADE_XIMAGE_15 _shade_ximage_15_mmx -#define SHADE_XIMAGE_16 _shade_ximage_16_mmx -#define SHADE_XIMAGE_32 _shade_ximage_32_mmx -#define HAVE_MMX _have_mmx -#else -#define SHADE_XIMAGE_15 shade_ximage_15_mmx -#define SHADE_XIMAGE_16 shade_ximage_16_mmx -#define SHADE_XIMAGE_32 shade_ximage_32_mmx -#define HAVE_MMX have_mmx -#endif - -.globl SHADE_XIMAGE_15 -.globl SHADE_XIMAGE_16 -.globl SHADE_XIMAGE_32 -.globl HAVE_MMX - -.bss -.text -.align 8 - -#define ENTER \ - pushl %ebp ;\ - movl %esp, %ebp ;\ - pushl %ebx ;\ - pushl %ecx ;\ - pushl %edx ;\ - pushl %edi ;\ - pushl %esi ;\ - movl data, %esi ;\ - movl w, %ebx ;\ - movl h, %edx - -#define LEAVE \ -4: ;\ - emms ;\ - popl %esi ;\ - popl %edi ;\ - popl %edx ;\ - popl %ecx ;\ - popl %ebx ;\ - movl %ebp, %esp ;\ - popl %ebp ;\ - ret - - -SHADE_XIMAGE_15: - ENTER - - leal -6(%esi, %ebx, 2), %esi - negl %ebx - jz 5f - - /* Setup multipliers */ - movd rm, %mm5 - movd gm, %mm6 - movd bm, %mm7 - punpcklwd %mm5, %mm5 /* 00 00 00 00 rm rm rm rm */ - punpcklwd %mm6, %mm6 /* 00 00 00 00 gm gm gm gm */ - punpcklwd %mm7, %mm7 /* 00 00 00 00 bm bm bm bm */ - punpckldq %mm5, %mm5 /* rm rm rm rm rm rm rm rm */ - punpckldq %mm6, %mm6 /* gm gm gm gm gm gm gm gm */ - punpckldq %mm7, %mm7 /* bm bm bm bm bm bm bm bm */ - - cmpl $256, rm - jg shade_ximage_15_mmx_saturate - cmpl $256, gm - jg shade_ximage_15_mmx_saturate - cmpl $256, bm - jg shade_ximage_15_mmx_saturate - -1: movl %ebx, %ecx - addl $3, %ecx - jns 3f -2: - movq (%esi, %ecx, 2), %mm0 - - movq %mm0, %mm1 /* rg gb */ - movq %mm0, %mm2 /* rg gb */ - psrlw $5, %mm1 /* 0r rg */ - psrlw $10, %mm0 /* 00 0r */ - psllw $11, %mm2 /* b0 00 */ - psllw $11, %mm1 /* g0 00 */ - psllw $8, %mm0 /* 0r 00 */ - psrlw $3, %mm1 /* 0g 00 */ - psrlw $3, %mm2 /* 0b 00 */ - - pmulhw %mm5, %mm0 /* 00 0r */ - pmulhw %mm6, %mm1 /* 00 0g */ - pmulhw %mm7, %mm2 /* 00 0b */ - - psllw $10, %mm0 /* r0 00 */ - psllw $5, %mm1 /* 0g g0 */ - por %mm2, %mm0 /* r0 0b */ - por %mm1, %mm0 /* rg gb */ - - movq %mm0, (%esi, %ecx, 2) - - addl $4, %ecx - js 2b - jmp 4f -3: - movw (%esi, %ecx, 2), %ax - movd %eax, %mm0 - - movq %mm0, %mm1 /* rg gb */ - movq %mm0, %mm2 /* rg gb */ - psrlw $5, %mm1 /* 0r rg */ - psrlw $10, %mm0 /* 00 0r */ - psllw $11, %mm2 /* b0 00 */ - psllw $11, %mm1 /* g0 00 */ - psllw $8, %mm0 /* 0r 00 */ - psrlw $3, %mm1 /* 0g 00 */ - psrlw $3, %mm2 /* 0b 00 */ - - pmulhw %mm5, %mm0 /* 00 0r */ - pmulhw %mm6, %mm1 /* 00 0g */ - pmulhw %mm7, %mm2 /* 00 0b */ - - psllw $10, %mm0 /* r0 00 */ - psllw $5, %mm1 /* 0g g0 */ - por %mm2, %mm0 /* r0 0b */ - por %mm1, %mm0 /* rg gb */ - - movd %mm0, %eax - movw %ax, (%esi, %ecx, 2) - - incl %ecx -4: - cmpl $2, %ecx - jng 3b - - addl bpl, %esi - decl %edx - jnz 1b -5: - LEAVE - - -shade_ximage_15_mmx_saturate: - - pcmpeqw %mm3, %mm3 - psllw $5, %mm3 /* ff e0 ff e0 ff e0 ff e0 */ - -1: movl %ebx, %ecx - addl $3, %ecx - jns 3f -2: - movq (%esi, %ecx, 2), %mm0 - - movq %mm0, %mm1 /* rg gb */ - movq %mm0, %mm2 /* rg gb */ - psrlw $5, %mm1 /* 0r rg */ - psrlw $10, %mm0 /* 00 0r */ - psllw $11, %mm2 /* b0 00 */ - psllw $11, %mm1 /* g0 00 */ - psllw $8, %mm0 /* 0r 00 */ - psrlw $3, %mm1 /* 0g 00 */ - psrlw $3, %mm2 /* 0b 00 */ - - pmulhw %mm5, %mm0 /* xx xr */ - pmulhw %mm6, %mm1 /* xx xg */ - pmulhw %mm7, %mm2 /* xx xb */ - - /* Saturate upper */ - paddusw %mm3, %mm0 /* ff er */ - paddusw %mm3, %mm1 /* ff eg */ - paddusw %mm3, %mm2 /* ff eb */ - - psubw %mm3, %mm0 /* 00 0r */ - psubw %mm3, %mm1 /* 00 0g */ - psubw %mm3, %mm2 /* 00 0b */ - - psllw $10, %mm0 /* r0 00 */ - psllw $5, %mm1 /* 0g g0 */ - por %mm2, %mm0 /* r0 0b */ - por %mm1, %mm0 /* rg gb */ - - movq %mm0, (%esi, %ecx, 2) - - addl $4, %ecx - js 2b - jmp 4f -3: - movw (%esi, %ecx, 2), %ax - movd %eax, %mm0 - - movq %mm0, %mm1 /* rg gb */ - movq %mm0, %mm2 /* rg gb */ - psrlw $5, %mm1 /* 0r rg */ - psrlw $10, %mm0 /* 00 0r */ - psllw $11, %mm2 /* b0 00 */ - psllw $11, %mm1 /* g0 00 */ - psllw $8, %mm0 /* 0r 00 */ - psrlw $3, %mm1 /* 0g 00 */ - psrlw $3, %mm2 /* 0b 00 */ - - pmulhw %mm5, %mm0 /* xx xr */ - pmulhw %mm6, %mm1 /* xx xg */ - pmulhw %mm7, %mm2 /* xx xb */ - - /* Saturate upper */ - paddusw %mm3, %mm0 /* ff er */ - paddusw %mm3, %mm1 /* ff eg */ - paddusw %mm3, %mm2 /* ff eb */ - - psubw %mm3, %mm0 /* 00 0r */ - psubw %mm3, %mm1 /* 00 0g */ - psubw %mm3, %mm2 /* 00 0b */ - - psllw $10, %mm0 /* r0 00 */ - psllw $5, %mm1 /* 0g g0 */ - por %mm2, %mm0 /* r0 0b */ - por %mm1, %mm0 /* rg gb */ - - movd %mm0, %eax - movw %ax, (%esi, %ecx, 2) - - incl %ecx -4: - cmpl $2, %ecx - jng 3b - - addl bpl, %esi - decl %edx - jnz 1b -5: - LEAVE - - -SHADE_XIMAGE_16: - ENTER - - leal -6(%esi, %ebx, 2), %esi - negl %ebx - jz 5f - - /* Setup multipliers */ - movd rm, %mm5 - movd gm, %mm6 - movd bm, %mm7 - punpcklwd %mm5, %mm5 /* 00 00 00 00 rm rm rm rm */ - punpcklwd %mm6, %mm6 /* 00 00 00 00 gm gm gm gm */ - punpcklwd %mm7, %mm7 /* 00 00 00 00 bm bm bm bm */ - punpckldq %mm5, %mm5 /* rm rm rm rm rm rm rm rm */ - punpckldq %mm6, %mm6 /* gm gm gm gm gm gm gm gm */ - punpckldq %mm7, %mm7 /* bm bm bm bm bm bm bm bm */ - - cmpl $256, rm - jg shade_ximage_16_mmx_saturate - cmpl $256, gm - jg shade_ximage_16_mmx_saturate - cmpl $256, bm - jg shade_ximage_16_mmx_saturate - -1: movl %ebx, %ecx - addl $3, %ecx - jns 3f -2: - movq (%esi, %ecx, 2), %mm0 - - movq %mm0, %mm1 /* rg gb */ - movq %mm0, %mm2 /* rg gb */ - psrlw $5, %mm1 /* 0r rg */ - psrlw $11, %mm0 /* 00 0r */ - psllw $11, %mm2 /* b0 00 */ - psllw $10, %mm1 /* g0 00 */ - psllw $8, %mm0 /* 0r 00 */ - psrlw $2, %mm1 /* 0g 00 */ - psrlw $3, %mm2 /* 0b 00 */ - - pmulhw %mm5, %mm0 /* 00 0r */ - pmulhw %mm6, %mm1 /* 00 0g */ - pmulhw %mm7, %mm2 /* 00 0b */ - - psllw $11, %mm0 /* r0 00 */ - psllw $5, %mm1 /* 0g g0 */ - por %mm2, %mm0 /* r0 0b */ - por %mm1, %mm0 /* rg gb */ - - movq %mm0, (%esi, %ecx, 2) - - addl $4, %ecx - js 2b - jmp 4f -3: - movw (%esi, %ecx, 2), %ax - movd %eax, %mm0 - - movq %mm0, %mm1 /* rg gb */ - movq %mm0, %mm2 /* rg gb */ - psrlw $5, %mm1 /* 0r rg */ - psrlw $11, %mm0 /* 00 0r */ - psllw $11, %mm2 /* b0 00 */ - psllw $10, %mm1 /* g0 00 */ - psllw $8, %mm0 /* 0r 00 */ - psrlw $2, %mm1 /* 0g 00 */ - psrlw $3, %mm2 /* 0b 00 */ - - pmulhw %mm5, %mm0 /* 00 0r */ - pmulhw %mm6, %mm1 /* 00 0g */ - pmulhw %mm7, %mm2 /* 00 0b */ - - psllw $11, %mm0 /* r0 00 */ - psllw $5, %mm1 /* 0g g0 */ - por %mm2, %mm0 /* r0 0b */ - por %mm1, %mm0 /* rg gb */ - - movd %mm0, %eax - movw %ax, (%esi, %ecx, 2) - - incl %ecx -4: - cmpl $2, %ecx - jng 3b - - addl bpl, %esi - decl %edx - jnz 1b -5: - LEAVE - - -shade_ximage_16_mmx_saturate: - - pcmpeqw %mm3, %mm3 - movq %mm3, %mm4 - psllw $5, %mm3 /* ff e0 ff e0 ff e0 ff e0 */ - psllw $6, %mm4 /* ff c0 ff c0 ff c0 ff c0 */ - -1: movl %ebx, %ecx - addl $3, %ecx - jns 3f -2: - movq (%esi, %ecx, 2), %mm0 - - movq %mm0, %mm1 /* rg gb */ - movq %mm0, %mm2 /* rg gb */ - psrlw $5, %mm1 /* 0r rg */ - psrlw $11, %mm0 /* 00 0r */ - psllw $11, %mm2 /* b0 00 */ - psllw $10, %mm1 /* g0 00 */ - psllw $8, %mm0 /* 0r 00 */ - psrlw $2, %mm1 /* 0g 00 */ - psrlw $3, %mm2 /* 0b 00 */ - - pmulhw %mm5, %mm0 /* xx xr */ - pmulhw %mm6, %mm1 /* xx xg */ - pmulhw %mm7, %mm2 /* xx xb */ - - /* Saturate upper */ - paddusw %mm3, %mm0 /* ff er */ - paddusw %mm4, %mm1 /* ff cg */ - paddusw %mm3, %mm2 /* ff eb */ - - psubw %mm4, %mm1 /* 00 0g */ - psubw %mm3, %mm2 /* 00 0b */ - - psllw $11, %mm0 /* r0 00 */ - psllw $5, %mm1 /* 0g g0 */ - por %mm2, %mm0 /* r0 0b */ - por %mm1, %mm0 /* rg gb */ - - movq %mm0, (%esi, %ecx, 2) - - addl $4, %ecx - js 2b - jmp 4f -3: - movw (%esi, %ecx, 2), %ax - movd %eax, %mm0 - - movq %mm0, %mm1 /* rg gb */ - movq %mm0, %mm2 /* rg gb */ - psrlw $5, %mm1 /* 0r rg */ - psrlw $11, %mm0 /* 00 0r */ - psllw $11, %mm2 /* b0 00 */ - psllw $10, %mm1 /* g0 00 */ - psllw $8, %mm0 /* 0r 00 */ - psrlw $2, %mm1 /* 0g 00 */ - psrlw $3, %mm2 /* 0b 00 */ - - pmulhw %mm5, %mm0 /* xx xr */ - pmulhw %mm6, %mm1 /* xx xg */ - pmulhw %mm7, %mm2 /* xx xb */ - - /* Saturate upper */ - paddusw %mm3, %mm0 /* ff er */ - paddusw %mm4, %mm1 /* ff cg */ - paddusw %mm3, %mm2 /* ff eb */ - - psubw %mm4, %mm1 /* 00 0g */ - psubw %mm3, %mm2 /* 00 0b */ - - psllw $11, %mm0 /* r0 00 */ - psllw $5, %mm1 /* 0g g0 */ - por %mm2, %mm0 /* r0 0b */ - por %mm1, %mm0 /* rg gb */ - - movd %mm0, %eax - movw %ax, (%esi, %ecx, 2) - - incl %ecx -4: - cmpl $2, %ecx - jng 3b - - addl bpl, %esi - decl %edx - jnz 1b -5: - LEAVE - - -SHADE_XIMAGE_32: - ENTER - - leal (%esi, %ebx, 4), %esi - negl %ebx - jz 3f - - movd rm, %mm4 - movd gm, %mm5 - movd bm, %mm6 - psllq $32, %mm4 - psllq $16, %mm5 - por %mm6, %mm4 - por %mm5, %mm4 - - pcmpeqw %mm6, %mm6 - psllw $15, %mm6 /* 80 00 80 00 80 00 80 00 */ - movq %mm6, %mm5 - pmulhw %mm4, %mm5 /* Get correction factor */ -1: - movl %ebx, %ecx -2: - movd (%esi, %ecx, 4), %mm1 /* 00 rr gg bb */ - pxor %mm0, %mm0 - punpcklbw %mm1, %mm0 /* 00 00 rr 00 gg 00 bb 00 */ - pxor %mm6, %mm0 /* Flip sign */ - - pmulhw %mm4, %mm0 /* 00 00 xx rr xx gg xx bb */ - psubw %mm5, %mm0 /* Correct range */ - packuswb %mm0, %mm0 /* 00 rr gg bb 00 rr gg bb */ - - movd %mm0, (%esi, %ecx, 4) - - incl %ecx - jnz 2b - - addl bpl, %esi - decl %edx - jnz 1b -3: - LEAVE - - -HAVE_MMX: - push %ebx -/* Check if bit 21 in flags word is writeable */ - pushfl - popl %eax - movl %eax,%ebx - xorl $0x00200000, %eax - pushl %eax - popfl - pushfl - popl %eax - - cmpl %eax, %ebx - je 8f - -/* OK, we have CPUID */ - - movl $1, %eax - cpuid - - test $0x00800000, %edx - jz 8f - - movl $1, %eax /* success, have mmx */ - popl %ebx - ret - -8: - xorl %eax,%eax /* failed, no mmx */ - popl %ebx - ret - -#if defined(__GNUC__) && !defined(_WIN32) -.section .note.GNU-stack, "", @progbits -.previous -#endif diff --git a/src/fe-gtk/mmx_cmod.h b/src/fe-gtk/mmx_cmod.h deleted file mode 100644 index 5b84a4b8..00000000 --- a/src/fe-gtk/mmx_cmod.h +++ /dev/null @@ -1,28 +0,0 @@ -/* HexChat - * Copyright (C) 1998-2010 Peter Zelezny. - * Copyright (C) 2009-2013 Berke Viktor. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#ifndef HEXCHAT_MMX_CMOD_H -#define HEXCHAT_MMX_CMOD_H - -void shade_ximage_15_mmx(void *data, int bpl, int w, int h, int rm, int gm, int bm); -void shade_ximage_16_mmx(void *data, int bpl, int w, int h, int rm, int gm, int bm); -void shade_ximage_32_mmx(void *data, int bpl, int w, int h, int rm, int gm, int bm); -int have_mmx (void); - -#endif diff --git a/src/fe-gtk/rawlog.c b/src/fe-gtk/rawlog.c index 7dfb38ba..fea53e84 100644 --- a/src/fe-gtk/rawlog.c +++ b/src/fe-gtk/rawlog.c @@ -121,9 +121,6 @@ open_rawlog (struct server *serv) gtk_widget_show (hbox); serv->gui->rawlog_textlist = gtk_xtext_new (colors, 0); - gtk_xtext_set_tint (GTK_XTEXT (serv->gui->rawlog_textlist), prefs.hex_text_tint_red, prefs.hex_text_tint_green, prefs.hex_text_tint_blue); - gtk_xtext_set_background (GTK_XTEXT (serv->gui->rawlog_textlist), - channelwin_pix, prefs.hex_text_transparent); gtk_container_add (GTK_CONTAINER (hbox), serv->gui->rawlog_textlist); gtk_xtext_set_font (GTK_XTEXT (serv->gui->rawlog_textlist), prefs.hex_text_font); diff --git a/src/fe-gtk/setup.c b/src/fe-gtk/setup.c index 4c2d4d11..41b50ac7 100644 --- a/src/fe-gtk/setup.c +++ b/src/fe-gtk/setup.c @@ -159,19 +159,11 @@ static const setting appearance_settings[] = {ST_HEADER, N_("Text Box"),0,0,0}, {ST_TOGGLE, N_("Colored nick names"), P_OFFINTNL(hex_text_color_nicks), N_("Give each person on IRC a different color"),0,0}, {ST_TOGGLR, N_("Indent nick names"), P_OFFINTNL(hex_text_indent), N_("Make nick names right-justified"),0,0}, -#if defined(USE_XLIB) || defined(WIN32) - {ST_TOGGLE, N_("Transparent background"), P_OFFINTNL(hex_text_transparent),0,0,0}, - {ST_TOGGLR, N_("Show marker line"), P_OFFINTNL(hex_text_show_marker), N_("Insert a red line after the last read text."),0,0}, - {ST_EFILE, N_("Background image:"), P_OFFSETNL(hex_text_background), 0, 0, sizeof prefs.hex_text_background}, + {ST_TOGGLE, N_ ("Show marker line"), P_OFFINTNL (hex_text_show_marker), N_ ("Insert a red line after the last read text."), 0, 0}, + {ST_EFILE, N_ ("Background image:"), P_OFFSETNL (hex_text_background), 0, 0, sizeof prefs.hex_text_background}, {ST_HEADER, N_("Transparency Settings"), 0,0,0}, - {ST_HSCALE, N_("Red:"), P_OFFINTNL(hex_text_tint_red),0,0,0}, - {ST_HSCALE, N_("Green:"), P_OFFINTNL(hex_text_tint_green),0,0,0}, - {ST_HSCALE, N_("Blue:"), P_OFFINTNL(hex_text_tint_blue),0,0,0}, -#else - {ST_TOGGLE, N_("Show marker line"), P_OFFINTNL(hex_text_show_marker), N_("Insert a red line after the last read text."),0,0}, - {ST_EFILE, N_("Background image:"), P_OFFSETNL(hex_text_background), 0, 0, sizeof prefs.hex_text_background}, -#endif + {ST_HSCALE, N_("Window Opacity:"), P_OFFINTNL(hex_gui_transparency),0,0,0}, {ST_HEADER, N_("Time Stamps"),0,0,0}, {ST_TOGGLE, N_("Enable time stamps"), P_OFFINTNL(hex_stamp_text),0,0,1}, @@ -839,12 +831,13 @@ setup_create_spin (GtkWidget *table, int row, const setting *set) } static gint -setup_apply_tint (int *tag) +setup_apply_trans (int *tag) { - prefs.hex_text_tint_red = setup_prefs.hex_text_tint_red; - prefs.hex_text_tint_green = setup_prefs.hex_text_tint_green; - prefs.hex_text_tint_blue = setup_prefs.hex_text_tint_blue; - mg_update_xtext (current_sess->gui->xtext); + prefs.hex_gui_transparency = setup_prefs.hex_gui_transparency; + gtk_window_set_opacity (GTK_WINDOW (current_sess->gui->window), + (prefs.hex_gui_transparency / 255.)); + + /* mg_update_xtext (current_sess->gui->xtext); */ *tag = 0; return 0; } @@ -858,7 +851,7 @@ setup_hscale_cb (GtkHScale *wid, const setting *set) if (tag == 0) { - tag = g_idle_add ((GSourceFunc) setup_apply_tint, &tag); + tag = g_idle_add ((GSourceFunc) setup_apply_trans, &tag); } } @@ -879,6 +872,12 @@ setup_create_hscale (GtkWidget *table, int row, const setting *set) G_CALLBACK (setup_hscale_cb), (gpointer)set); gtk_table_attach (GTK_TABLE (table), wid, 3, 6, row, row + 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); + +#ifndef WIN32 /* Windows always supports this */ + /* Only used for transparency currently */ + if (!gtk_widget_is_composited (current_sess->gui->window)) + gtk_widget_set_sensitive (wid, FALSE); +#endif } diff --git a/src/fe-gtk/textgui.c b/src/fe-gtk/textgui.c index 0bdb4476..14fae28e 100644 --- a/src/fe-gtk/textgui.c +++ b/src/fe-gtk/textgui.c @@ -383,9 +383,6 @@ pevent_dialog_show () G_CALLBACK (pevent_dialog_select), store); pevent_dialog_twid = gtk_xtext_new (colors, 0); - gtk_xtext_set_tint (GTK_XTEXT (pevent_dialog_twid), prefs.hex_text_tint_red, prefs.hex_text_tint_green, prefs.hex_text_tint_blue); - gtk_xtext_set_background (GTK_XTEXT (pevent_dialog_twid), - channelwin_pix, prefs.hex_text_transparent); pevent_dialog_entry = gtk_entry_new_with_max_length (255); g_signal_connect (G_OBJECT (pevent_dialog_entry), "activate", diff --git a/src/fe-gtk/xtext.c b/src/fe-gtk/xtext.c index 44ac9cc5..c202bc18 100644 --- a/src/fe-gtk/xtext.c +++ b/src/fe-gtk/xtext.c @@ -21,19 +21,7 @@ * */ -#define HEXCHAT /* using HexChat */ -#define TINT_VALUE 195 /* 195/255 of the brightness. */ -#define MOTION_MONITOR /* URL hilights. */ -#define SMOOTH_SCROLL /* line-by-line or pixel scroll? */ -#define SCROLL_HACK /* use XCopyArea scroll, or full redraw? */ -#undef COLOR_HILIGHT /* Color instead of underline? */ -/* Italic is buggy because it assumes drawing an italic string will have - identical extents to the normal font. This is only true some of the - time, so we can't use this hack yet. */ -#undef ITALIC /* support Italic? */ #define GDK_MULTIHEAD_SAFE -#define USE_DB /* double buffer */ - #define MARGIN 2 /* dont touch. */ #define REFRESH_TIMEOUT 20 #define WORDWRAP_LIMIT 24 @@ -43,24 +31,10 @@ #include <stdlib.h> #include <time.h> -#ifdef HEXCHAT #ifdef WIN32 #include "../../config-win32.h" #else -#include "../../config.h" /* can define USE_XLIB here */ -#endif -#else -#define USE_XLIB -#endif - -#ifdef USE_XLIB -#include <gdk/gdkx.h> -#include <X11/Xlib.h> -#include <X11/Xatom.h> -#endif - -#ifdef USE_MMX -#include "mmx_cmod.h" +#include "../../config.h" #endif #include "../common/hexchat.h" @@ -87,12 +61,8 @@ #define is_del(c) \ (c == ' ' || c == '\n' || c == '>' || c == '<' || c == 0) -#ifdef SCROLL_HACK /* force scrolling off */ #define dontscroll(buf) (buf)->last_pixel_pos = 0x7fffffff -#else -#define dontscroll(buf) -#endif static GtkWidgetClass *parent_class = NULL; @@ -135,16 +105,10 @@ enum static guint xtext_signals[LAST_SIGNAL]; -#ifdef HEXCHAT char *nocasestrstr (const char *text, const char *tofind); /* util.c */ int xtext_get_stamp_str (time_t, char **); -#endif static void gtk_xtext_render_page (GtkXText * xtext); static void gtk_xtext_calc_lines (xtext_buffer *buf, int); -#if defined(USE_XLIB) || defined(WIN32) -static void gtk_xtext_load_trans (GtkXText * xtext); -static void gtk_xtext_free_trans (GtkXText * xtext); -#endif static char *gtk_xtext_selection_get_text (GtkXText *xtext, int *len_ret); static textentry *gtk_xtext_nth (GtkXText *xtext, int line, int *subline); static void gtk_xtext_adjustment_changed (GtkAdjustment * adj, @@ -175,25 +139,6 @@ static void gtk_xtext_search_textentry_fini (gpointer, gpointer); static void gtk_xtext_search_fini (xtext_buffer *); static gboolean gtk_xtext_search_init (xtext_buffer *buf, const gchar *text, gtk_xtext_search_flags flags, GError **perr); -/* some utility functions first */ - -#ifndef HEXCHAT /* HexChat has this in util.c */ - -static char * -nocasestrstr (const char *s, const char *tofind) -{ - register const size_t len = strlen (tofind); - - if (len == 0) - return (char *)s; - while (toupper(*s) != toupper(*tofind) || g_ascii_strncasecmp (s, tofind, len)) - if (*s++ == '\0') - return (char *)NULL; - return (char *)s; -} - -#endif - /* gives width of a 8bit string - with no mIRC codes in it */ static int @@ -211,260 +156,7 @@ gtk_xtext_text_width_8bit (GtkXText *xtext, unsigned char *str, int len) return width; } -#ifdef WIN32 - -static void -win32_draw_bg (GtkXText *xtext, int x, int y, int width, int height) -{ - HDC hdc; - HWND hwnd; - HRGN rgn; - - if (xtext->shaded) - { - /* xtext->pixmap is really a GdkImage, created in win32_tint() */ - gdk_draw_image (xtext->draw_buf, xtext->bgc, (GdkImage*)xtext->pixmap, - x, y, x, y, width, height); - } else - { - hwnd = GDK_WINDOW_HWND (xtext->draw_buf); - hdc = GetDC (hwnd); - - rgn = CreateRectRgn (x, y, x + width, y + height); - SelectClipRgn (hdc, rgn); - - PaintDesktop (hdc); - - ReleaseDC (hwnd, hdc); - DeleteObject (rgn); - } -} - -static void -xtext_draw_bg (GtkXText *xtext, int x, int y, int width, int height) -{ - if (xtext->transparent) - win32_draw_bg (xtext, x, y, width, height); - else - gdk_draw_rectangle (xtext->draw_buf, xtext->bgc, 1, x, y, width, height); -} - -#else - -#define xtext_draw_bg(xt,x,y,w,h) gdk_draw_rectangle(xt->draw_buf, xt->bgc, \ - 1,x,y,w,h); - -#endif - -/* ========================================= */ -/* ========== XFT 1 and 2 BACKEND ========== */ -/* ========================================= */ - -#ifdef USE_XFT - -static void -backend_font_close (GtkXText *xtext) -{ - XftFontClose (GDK_WINDOW_XDISPLAY (xtext->draw_buf), xtext->font); -#ifdef ITALIC - XftFontClose (GDK_WINDOW_XDISPLAY (xtext->draw_buf), xtext->ifont); -#endif -} - -static void -backend_init (GtkXText *xtext) -{ - if (xtext->xftdraw == NULL) - { - xtext->xftdraw = XftDrawCreate ( - GDK_WINDOW_XDISPLAY (xtext->draw_buf), - GDK_WINDOW_XWINDOW (xtext->draw_buf), - GDK_VISUAL_XVISUAL (gdk_drawable_get_visual (xtext->draw_buf)), - GDK_COLORMAP_XCOLORMAP (gdk_drawable_get_colormap (xtext->draw_buf))); - XftDrawSetSubwindowMode (xtext->xftdraw, IncludeInferiors); - } -} - -static void -backend_deinit (GtkXText *xtext) -{ - if (xtext->xftdraw) - { - XftDrawDestroy (xtext->xftdraw); - xtext->xftdraw = NULL; - } -} - -static XftFont * -backend_font_open_real (Display *xdisplay, char *name, gboolean italics) -{ - XftFont *font = NULL; - PangoFontDescription *fontd; - int weight, slant, screen = DefaultScreen (xdisplay); - - fontd = pango_font_description_from_string (name); - - if (pango_font_description_get_size (fontd) != 0) - { - weight = pango_font_description_get_weight (fontd); - /* from pangoft2-fontmap.c */ - if (weight < (PANGO_WEIGHT_NORMAL + PANGO_WEIGHT_LIGHT) / 2) - weight = XFT_WEIGHT_LIGHT; - else if (weight < (PANGO_WEIGHT_NORMAL + 600) / 2) - weight = XFT_WEIGHT_MEDIUM; - else if (weight < (600 + PANGO_WEIGHT_BOLD) / 2) - weight = XFT_WEIGHT_DEMIBOLD; - else if (weight < (PANGO_WEIGHT_BOLD + PANGO_WEIGHT_ULTRABOLD) / 2) - weight = XFT_WEIGHT_BOLD; - else - weight = XFT_WEIGHT_BLACK; - - slant = pango_font_description_get_style (fontd); - if (slant == PANGO_STYLE_ITALIC) - slant = XFT_SLANT_ITALIC; - else if (slant == PANGO_STYLE_OBLIQUE) - slant = XFT_SLANT_OBLIQUE; - else - slant = XFT_SLANT_ROMAN; - - font = XftFontOpen (xdisplay, screen, - XFT_FAMILY, XftTypeString, pango_font_description_get_family (fontd), - XFT_CORE, XftTypeBool, False, - XFT_SIZE, XftTypeDouble, (double)pango_font_description_get_size (fontd)/PANGO_SCALE, - XFT_WEIGHT, XftTypeInteger, weight, - XFT_SLANT, XftTypeInteger, italics ? XFT_SLANT_ITALIC : slant, - NULL); - } - pango_font_description_free (fontd); - - if (font == NULL) - { - font = XftFontOpenName (xdisplay, screen, name); - if (font == NULL) - font = XftFontOpenName (xdisplay, screen, "sans-11"); - } - - return font; -} - -static void -backend_font_open (GtkXText *xtext, char *name) -{ - Display *dis = GDK_WINDOW_XDISPLAY (xtext->draw_buf); - - xtext->font = backend_font_open_real (dis, name, FALSE); -#ifdef ITALIC - xtext->ifont = backend_font_open_real (dis, name, TRUE); -#endif -} - -inline static int -backend_get_char_width (GtkXText *xtext, unsigned char *str, int *mbl_ret) -{ - XGlyphInfo ext; - - if (*str < 128) - { - *mbl_ret = 1; - return xtext->fontwidth[*str]; - } - - *mbl_ret = charlen (str); - XftTextExtentsUtf8 (GDK_WINDOW_XDISPLAY (xtext->draw_buf), xtext->font, str, *mbl_ret, &ext); - - return ext.xOff; -} - -static int -backend_get_text_width (GtkXText *xtext, guchar *str, int len, int is_mb) -{ - XGlyphInfo ext; - - if (!is_mb) - return gtk_xtext_text_width_8bit (xtext, str, len); - - XftTextExtentsUtf8 (GDK_WINDOW_XDISPLAY (xtext->draw_buf), xtext->font, str, len, &ext); - return ext.xOff; -} - -static void -backend_draw_text (GtkXText *xtext, int dofill, GdkGC *gc, int x, int y, - char *str, int len, int str_width, int is_mb) -{ - /*Display *xdisplay = GDK_WINDOW_XDISPLAY (xtext->draw_buf);*/ - void (*draw_func) (XftDraw *, XftColor *, XftFont *, int, int, XftChar8 *, int) = (void *)XftDrawString8; - XftFont *font; - - /* if all ascii, use String8 to avoid the conversion penalty */ - if (is_mb) - draw_func = (void *)XftDrawStringUtf8; - - if (dofill) - { -/* register GC xgc = GDK_GC_XGC (gc); - XSetForeground (xdisplay, xgc, xtext->xft_bg->pixel); - XFillRectangle (xdisplay, GDK_WINDOW_XWINDOW (xtext->draw_buf), xgc, x, - y - xtext->font->ascent, str_width, xtext->fontsize);*/ - XftDrawRect (xtext->xftdraw, xtext->xft_bg, x, - y - xtext->font->ascent, str_width, xtext->fontsize); - } - - font = xtext->font; -#ifdef ITALIC - if (xtext->italics) - font = xtext->ifont; -#endif - - draw_func (xtext->xftdraw, xtext->xft_fg, font, x, y, str, len); - - if (xtext->overdraw) - draw_func (xtext->xftdraw, xtext->xft_fg, font, x, y, str, len); - - if (xtext->bold) - draw_func (xtext->xftdraw, xtext->xft_fg, font, x + 1, y, str, len); -} - -/*static void -backend_set_clip (GtkXText *xtext, GdkRectangle *area) -{ - gdk_gc_set_clip_rectangle (xtext->fgc, area); - gdk_gc_set_clip_rectangle (xtext->bgc, area); -} - -static void -backend_clear_clip (GtkXText *xtext) -{ - gdk_gc_set_clip_rectangle (xtext->fgc, NULL); - gdk_gc_set_clip_rectangle (xtext->bgc, NULL); -}*/ - -/*static void -backend_set_clip (GtkXText *xtext, GdkRectangle *area) -{ - Region reg; - XRectangle rect; - - rect.x = area->x; - rect.y = area->y; - rect.width = area->width; - rect.height = area->height; - - reg = XCreateRegion (); - XUnionRectWithRegion (&rect, reg, reg); - XftDrawSetClip (xtext->xftdraw, reg); - XDestroyRegion (reg); - - gdk_gc_set_clip_rectangle (xtext->fgc, area); -} - -static void -backend_clear_clip (GtkXText *xtext) -{ - XftDrawSetClip (xtext->xftdraw, NULL); - gdk_gc_set_clip_rectangle (xtext->fgc, NULL); -} -*/ -#else /* !USE_XFT */ +#define xtext_draw_bg(xt,x,y,w,h) gdk_draw_rectangle(xt->draw_buf, xt->bgc, 1, x, y, w, h); /* ======================================= */ /* ============ PANGO BACKEND ============ */ @@ -474,9 +166,7 @@ static void backend_font_close (GtkXText *xtext) { pango_font_description_free (xtext->font->font); -#ifdef ITALIC pango_font_description_free (xtext->font->ifont); -#endif } static void @@ -531,10 +221,8 @@ backend_font_open (GtkXText *xtext, char *name) xtext->font = NULL; return; } -#ifdef ITALIC xtext->font->ifont = backend_font_open_real (name); pango_font_description_set_style (xtext->font->ifont, PANGO_STYLE_ITALIC); -#endif backend_init (xtext); pango_layout_set_font_description (xtext->layout, xtext->font->font); @@ -619,46 +307,31 @@ backend_draw_text (GtkXText *xtext, int dofill, GdkGC *gc, int x, int y, GdkColor col; PangoLayoutLine *line; -#ifdef ITALIC if (xtext->italics) pango_layout_set_font_description (xtext->layout, xtext->font->ifont); -#endif pango_layout_set_text (xtext->layout, str, len); if (dofill) { -#ifdef WIN32 - if (xtext->transparent && !xtext->backcolor) - win32_draw_bg (xtext, x, y - xtext->font->ascent, str_width, - xtext->fontsize); - else -#endif - { - gdk_gc_get_values (gc, &val); - col.pixel = val.background.pixel; - gdk_gc_set_foreground (gc, &col); - gdk_draw_rectangle (xtext->draw_buf, gc, 1, x, y - - xtext->font->ascent, str_width, xtext->fontsize); - col.pixel = val.foreground.pixel; - gdk_gc_set_foreground (gc, &col); - } + gdk_gc_get_values (gc, &val); + col.pixel = val.background.pixel; + gdk_gc_set_foreground (gc, &col); + gdk_draw_rectangle (xtext->draw_buf, gc, 1, x, y - + xtext->font->ascent, str_width, xtext->fontsize); + col.pixel = val.foreground.pixel; + gdk_gc_set_foreground (gc, &col); } line = pango_layout_get_lines (xtext->layout)->data; xtext_draw_layout_line (xtext->draw_buf, gc, x, y, line); - if (xtext->overdraw) - xtext_draw_layout_line (xtext->draw_buf, gc, x, y, line); - if (xtext->bold) xtext_draw_layout_line (xtext->draw_buf, gc, x + 1, y, line); -#ifdef ITALIC if (xtext->italics) pango_layout_set_font_description (xtext->layout, xtext->font->font); -#endif } /*static void @@ -675,7 +348,6 @@ backend_clear_clip (GtkXText *xtext) gdk_gc_set_clip_rectangle (xtext->bgc, NULL); }*/ -#endif /* !USE_PANGO */ static void xtext_set_fg (GtkXText *xtext, GdkGC *gc, int index) @@ -684,21 +356,8 @@ xtext_set_fg (GtkXText *xtext, GdkGC *gc, int index) col.pixel = xtext->palette[index]; gdk_gc_set_foreground (gc, &col); - -#ifdef USE_XFT - if (gc == xtext->fgc) - xtext->xft_fg = &xtext->color[index]; - else - xtext->xft_bg = &xtext->color[index]; -#endif } -#ifdef USE_XFT - -#define xtext_set_bg(xt,gc,index) xt->xft_bg = &xt->color[index] - -#else - static void xtext_set_bg (GtkXText *xtext, GdkGC *gc, int index) { @@ -708,8 +367,6 @@ xtext_set_bg (GtkXText *xtext, GdkGC *gc, int index) gdk_gc_set_background (gc, &col); } -#endif - static void gtk_xtext_init (GtkXText * xtext) { @@ -727,11 +384,7 @@ gtk_xtext_init (GtkXText * xtext) xtext->italics = FALSE; xtext->hidden = FALSE; xtext->font = NULL; -#ifdef USE_XFT - xtext->xftdraw = NULL; -#else xtext->layout = NULL; -#endif xtext->jump_out_offset = 0; xtext->jump_in_offset = 0; xtext->ts_x = 0; @@ -740,7 +393,6 @@ gtk_xtext_init (GtkXText * xtext) xtext->clip_x2 = 1000000; xtext->clip_y = 0; xtext->clip_y2 = 1000000; - xtext->error_function = NULL; xtext->urlcheck_function = NULL; xtext->color_paste = FALSE; xtext->skip_border_fills = FALSE; @@ -750,8 +402,6 @@ gtk_xtext_init (GtkXText * xtext) xtext->recycle = FALSE; xtext->dont_render = FALSE; xtext->dont_render2 = FALSE; - xtext->overdraw = FALSE; - xtext->tint_red = xtext->tint_green = xtext->tint_blue = TINT_VALUE; xtext->adj = (GtkAdjustment *) gtk_adjustment_new (0, 0, 1, 1, 1, 1); g_object_ref (G_OBJECT (xtext->adj)); @@ -772,9 +422,6 @@ gtk_xtext_init (GtkXText * xtext) gtk_selection_add_targets (GTK_WIDGET (xtext), GDK_SELECTION_PRIMARY, targets, n_targets); } - - if (getenv ("HEXCHAT_OVERDRAW")) - xtext->overdraw = TRUE; } static void @@ -816,11 +463,7 @@ gtk_xtext_adjustment_timeout (GtkXText * xtext) static void gtk_xtext_adjustment_changed (GtkAdjustment * adj, GtkXText * xtext) { -#ifdef SMOOTH_SCROLL if (xtext->buffer->old_value != xtext->adj->value) -#else - if ((int) xtext->buffer->old_value != (int) xtext->adj->value) -#endif { if (xtext->adj->value >= xtext->adj->upper - xtext->adj->page_size) xtext->buffer->scrollbar_down = TRUE; @@ -890,12 +533,7 @@ gtk_xtext_destroy (GtkObject * object) if (xtext->pixmap) { -#if defined(USE_XLIB) || defined(WIN32) - if (xtext->transparent) - gtk_xtext_free_trans (xtext); - else -#endif - g_object_unref (xtext->pixmap); + g_object_unref (xtext->pixmap); xtext->pixmap = NULL; } @@ -1004,11 +642,7 @@ gtk_xtext_realize (GtkWidget * widget) attributes.window_type = GDK_WINDOW_CHILD; attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK -#ifdef MOTION_MONITOR | GDK_POINTER_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK; -#else - | GDK_POINTER_MOTION_MASK; -#endif cmap = gtk_widget_get_colormap (widget); attributes.colormap = cmap; @@ -1064,12 +698,6 @@ gtk_xtext_realize (GtkWidget * widget) /* draw directly to window */ xtext->draw_buf = widget->window; -#if defined(USE_XLIB) || defined(WIN32) - if (xtext->transparent) - { - gtk_xtext_load_trans (xtext); - } else -#endif if (xtext->pixmap) { gdk_gc_set_tile (xtext->bgc, xtext->pixmap); @@ -1099,17 +727,10 @@ gtk_xtext_size_allocate (GtkWidget * widget, GtkAllocation * allocation) { GtkXText *xtext = GTK_XTEXT (widget); int height_only = FALSE; - int do_trans = TRUE; if (allocation->width == xtext->buffer->window_width) height_only = TRUE; - if (allocation->x == widget->allocation.x && - allocation->y == widget->allocation.y && xtext->avoid_trans) - do_trans = FALSE; - - xtext->avoid_trans = FALSE; - widget->allocation = *allocation; if (GTK_WIDGET_REALIZED (widget)) { @@ -1126,13 +747,6 @@ gtk_xtext_size_allocate (GtkWidget * widget, GtkAllocation * allocation) xtext->buffer->pagetop_ent = NULL; gtk_xtext_adjustment_set (xtext->buffer, FALSE); } -#if defined(USE_XLIB) || defined(WIN32) - if (do_trans && xtext->transparent && xtext->shaded) - { - gtk_xtext_free_trans (xtext); - gtk_xtext_load_trans (xtext); - } -#endif if (xtext->buffer->scrollbar_down) gtk_adjustment_set_value (xtext->adj, xtext->adj->upper - xtext->adj->page_size); @@ -1353,24 +967,6 @@ gtk_xtext_draw_marker (GtkXText * xtext, textentry * ent, int y) } } -#ifdef USE_SHM -static int -have_shm_pixmaps(Display *dpy) -{ - int major, minor; - static int checked = 0; - static int have = FALSE; - - if (!checked) - { - XShmQueryVersion (dpy, &major, &minor, &have); - checked = 1; - } - - return have; -} -#endif - static void gtk_xtext_paint (GtkWidget *widget, GdkRectangle *area) { @@ -1378,35 +974,6 @@ gtk_xtext_paint (GtkWidget *widget, GdkRectangle *area) textentry *ent_start, *ent_end; int x, y; -#if defined(USE_XLIB) || defined(WIN32) - if (xtext->transparent) - { - gdk_window_get_origin (widget->window, &x, &y); - /* update transparency only if it moved */ - if (xtext->last_win_x != x || xtext->last_win_y != y) - { - xtext->last_win_x = x; - xtext->last_win_y = y; -#ifndef WIN32 -#ifdef USE_SHM - if (xtext->shaded && !have_shm_pixmaps(GDK_WINDOW_XDISPLAY (xtext->draw_buf))) -#else - if (xtext->shaded) -#endif - { - xtext->recycle = TRUE; - gtk_xtext_load_trans (xtext); - xtext->recycle = FALSE; - } else -#endif - { - gtk_xtext_free_trans (xtext); - gtk_xtext_load_trans (xtext); - } - } - } -#endif - if (area->x == 0 && area->y == 0 && area->height == widget->allocation.height && area->width == widget->allocation.width) @@ -1954,8 +1521,6 @@ gtk_xtext_get_word (GtkXText * xtext, int x, int y, textentry ** ret_ent, return word; } -#ifdef MOTION_MONITOR - static void gtk_xtext_unrender_hilight (GtkXText *xtext) { @@ -2000,8 +1565,6 @@ gtk_xtext_leave_notify (GtkWidget * widget, GdkEventCrossing * event) return FALSE; } -#endif - /* check if we should mark time stamps, and if a redraw is needed */ static gboolean @@ -2131,7 +1694,6 @@ gtk_xtext_motion_notify (GtkWidget * widget, GdkEventMotion * event) } return FALSE; } -#ifdef MOTION_MONITOR if (xtext->separator && xtext->buffer->indent) { @@ -2191,8 +1753,6 @@ gtk_xtext_motion_notify (GtkWidget * widget, GdkEventMotion * event) gtk_xtext_leave_notify (widget, NULL); -#endif - return FALSE; } @@ -2640,9 +2200,7 @@ gtk_xtext_class_init (GtkXTextClass * class) widget_class->selection_get = gtk_xtext_selection_get; widget_class->expose_event = gtk_xtext_expose; widget_class->scroll_event = gtk_xtext_scroll; -#ifdef MOTION_MONITOR widget_class->leave_notify_event = gtk_xtext_leave_notify; -#endif xtext_class->word_click = NULL; } @@ -2917,34 +2475,22 @@ gtk_xtext_render_flush (GtkXText * xtext, int x, int y, unsigned char *str, { if (!xtext->in_hilight) /* is it a hilight prefix? */ return str_width; -#ifndef COLOR_HILIGHT if (!xtext->un_hilight) /* doing a hilight? no need to draw the text */ goto dounder; -#endif } -#ifdef USE_DB -#ifdef WIN32 - if (!xtext->transparent) -#endif + pix = gdk_pixmap_new (xtext->draw_buf, str_width, xtext->fontsize, xtext->depth); + if (pix) { - pix = gdk_pixmap_new (xtext->draw_buf, str_width, xtext->fontsize, xtext->depth); - if (pix) - { -#ifdef USE_XFT - XftDrawChange (xtext->xftdraw, GDK_WINDOW_XWINDOW (pix)); -#endif - dest_x = x; - dest_y = y - xtext->font->ascent; + dest_x = x; + dest_y = y - xtext->font->ascent; - gdk_gc_set_ts_origin (xtext->bgc, xtext->ts_x - x, xtext->ts_y - dest_y); + gdk_gc_set_ts_origin (xtext->bgc, xtext->ts_x - x, xtext->ts_y - dest_y); - x = 0; - y = xtext->font->ascent; - xtext->draw_buf = pix; - } + x = 0; + y = xtext->font->ascent; + xtext->draw_buf = pix; } -#endif dofill = TRUE; @@ -2959,7 +2505,6 @@ gtk_xtext_render_flush (GtkXText * xtext, int x, int y, unsigned char *str, backend_draw_text (xtext, dofill, gc, x, y, str, len, str_width, is_mb); -#ifdef USE_DB if (pix) { GdkRectangle clip; @@ -2967,13 +2512,6 @@ gtk_xtext_render_flush (GtkXText * xtext, int x, int y, unsigned char *str, gdk_gc_set_ts_origin (xtext->bgc, xtext->ts_x, xtext->ts_y); xtext->draw_buf = GTK_WIDGET (xtext)->window; -#ifdef USE_XFT - XftDrawChange (xtext->xftdraw, GDK_WINDOW_XWINDOW (xtext->draw_buf)); -#endif -#if 0 - gdk_draw_drawable (xtext->draw_buf, xtext->bgc, pix, 0, 0, dest_x, - dest_y, str_width, xtext->fontsize); -#else clip.x = xtext->clip_x; clip.y = xtext->clip_y; clip.width = xtext->clip_x2 - xtext->clip_x; @@ -2989,25 +2527,13 @@ gtk_xtext_render_flush (GtkXText * xtext, int x, int y, unsigned char *str, gdk_draw_drawable (xtext->draw_buf, xtext->bgc, pix, dest.x - dest_x, dest.y - dest_y, dest.x, dest.y, dest.width, dest.height); -#endif g_object_unref (pix); } -#endif if (xtext->underline) { -#ifdef USE_XFT - GdkColor col; -#endif - -#ifndef COLOR_HILIGHT dounder: -#endif -#ifdef USE_XFT - col.pixel = xtext->xft_fg->pixel; - gdk_gc_set_foreground (gc, &col); -#endif if (pix) y = dest_y + xtext->font->ascent + 1; else @@ -3139,21 +2665,15 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent, xtext->backcolor = TRUE; mark = TRUE; } -#ifdef MOTION_MONITOR if (xtext->hilight_ent == ent && xtext->hilight_start <= i + offset && xtext->hilight_end > i + offset) { if (!xtext->un_hilight) { -#ifdef COLOR_HILIGHT - xtext_set_bg (xtext, gc, 2); -#else xtext->underline = TRUE; -#endif } xtext->in_hilight = TRUE; } -#endif if (!xtext->skip_border_fills && !xtext->dont_render) { @@ -3183,7 +2703,6 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent, while (i < len) { -#ifdef MOTION_MONITOR if (xtext->hilight_ent == ent && xtext->hilight_start == (i + offset)) { x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb); @@ -3191,16 +2710,11 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent, j = 0; if (!xtext->un_hilight) { -#ifdef COLOR_HILIGHT - xtext_set_bg (xtext, gc, 2); -#else xtext->underline = TRUE; -#endif } xtext->in_hilight = TRUE; } -#endif if ((xtext->parsing_color && isdigit (str[i]) && xtext->nc < 2) || (xtext->parsing_color && str[i] == ',' && isdigit (str[i+1]) && xtext->nc < 3 && !xtext->parsing_backcolor)) @@ -3428,28 +2942,12 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent, xtext->dont_render2 = FALSE; } -#ifdef MOTION_MONITOR if (xtext->hilight_ent == ent && xtext->hilight_end == (i + offset)) { x += gtk_xtext_render_flush (xtext, x, y, pstr, j, gc, ent->mb); pstr += j; j = 0; -#ifdef COLOR_HILIGHT - if (mark) - { - xtext_set_bg (xtext, gc, XTEXT_MARK_BG); - xtext->backcolor = TRUE; - } else - { - xtext_set_bg (xtext, gc, xtext->col_back); - if (xtext->col_back != XTEXT_BG) - xtext->backcolor = TRUE; - else - xtext->backcolor = FALSE; - } -#else xtext->underline = FALSE; -#endif xtext->in_hilight = FALSE; if (xtext->render_hilights_only) { @@ -3458,7 +2956,6 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent, break; } } -#endif if (!mark && ent->mark_start == (i + offset)) { @@ -3531,630 +3028,6 @@ gtk_xtext_render_str (GtkXText * xtext, int y, textentry * ent, return ret; } -#ifdef USE_XLIB - -/* get the desktop/root window */ - -static Window desktop_window = None; - -static Window -get_desktop_window (Display *xdisplay, Window the_window) -{ - Atom prop, type; - int format; - unsigned long length, after; - unsigned char *data; - unsigned int nchildren; - Window w, root, *children, parent; - - prop = XInternAtom (xdisplay, "_XROOTPMAP_ID", True); - if (prop == None) - { - prop = XInternAtom (xdisplay, "_XROOTCOLOR_PIXEL", True); - if (prop == None) - return None; - } - - for (w = the_window; w; w = parent) - { - if ((XQueryTree (xdisplay, w, &root, &parent, &children, - &nchildren)) == False) - return None; - - if (nchildren) - XFree (children); - - XGetWindowProperty (xdisplay, w, prop, 0L, 1L, False, - AnyPropertyType, &type, &format, &length, &after, - &data); - if (data) - XFree (data); - - if (type != None) - return (desktop_window = w); - } - - return (desktop_window = None); -} - -/* find the root window (backdrop) Pixmap */ - -static Pixmap -get_pixmap_prop (Display *xdisplay, Window the_window) -{ - Atom type; - int format; - unsigned long length, after; - unsigned char *data; - Pixmap pix = None; - static Atom prop = None; - - if (desktop_window == None) - desktop_window = get_desktop_window (xdisplay, the_window); - if (desktop_window == None) - desktop_window = DefaultRootWindow (xdisplay); - - if (prop == None) - prop = XInternAtom (xdisplay, "_XROOTPMAP_ID", True); - if (prop == None) - return None; - - XGetWindowProperty (xdisplay, desktop_window, prop, 0L, 1L, False, - AnyPropertyType, &type, &format, &length, &after, - &data); - if (data) - { - if (type == XA_PIXMAP) - pix = *((Pixmap *) data); - - XFree (data); - } - - return pix; -} - -/* slow generic routine, for the depths/bpp we don't know about */ - -static void -shade_ximage_generic (GdkVisual *visual, XImage *ximg, int bpl, int w, int h, int rm, int gm, int bm, int bg) -{ - int x, y; - int bgr = (256 - rm) * (bg & visual->red_mask); - int bgg = (256 - gm) * (bg & visual->green_mask); - int bgb = (256 - bm) * (bg & visual->blue_mask); - - for (x = 0; x < w; x++) - { - for (y = 0; y < h; y++) - { - unsigned long pixel = XGetPixel (ximg, x, y); - int r, g, b; - - r = rm * (pixel & visual->red_mask) + bgr; - g = gm * (pixel & visual->green_mask) + bgg; - b = bm * (pixel & visual->blue_mask) + bgb; - - XPutPixel (ximg, x, y, - ((r >> 8) & visual->red_mask) | - ((g >> 8) & visual->green_mask) | - ((b >> 8) & visual->blue_mask)); - } - } -} - -#endif - -/* Fast shading routine. Based on code by Willem Monsuwe <willem@stack.nl> */ - -#define SHADE_IMAGE(bytes, type, rmask, gmask, bmask) \ - unsigned char *ptr; \ - int x, y; \ - int bgr = (256 - rm) * (bg & rmask); \ - int bgg = (256 - gm) * (bg & gmask); \ - int bgb = (256 - bm) * (bg & bmask); \ - ptr = (unsigned char *) data + (w * bytes); \ - for (y = h; --y >= 0;) \ - { \ - for (x = -w; x < 0; x++) \ - { \ - int r, g, b; \ - b = ((type *) ptr)[x]; \ - r = rm * (b & rmask) + bgr; \ - g = gm * (b & gmask) + bgg; \ - b = bm * (b & bmask) + bgb; \ - ((type *) ptr)[x] = ((r >> 8) & rmask) \ - | ((g >> 8) & gmask) \ - | ((b >> 8) & bmask); \ - } \ - ptr += bpl; \ - } - -/* RGB 15 */ -static void -shade_ximage_15 (void *data, int bpl, int w, int h, int rm, int gm, int bm, int bg) -{ - SHADE_IMAGE (2, guint16, 0x7c00, 0x3e0, 0x1f); -} - -/* RGB 16 */ -static void -shade_ximage_16 (void *data, int bpl, int w, int h, int rm, int gm, int bm, int bg) -{ - SHADE_IMAGE (2, guint16, 0xf800, 0x7e0, 0x1f); -} - -/* RGB 24 */ -static void -shade_ximage_24 (void *data, int bpl, int w, int h, int rm, int gm, int bm, int bg) -{ - /* 24 has to be a special case, there's no guint24, or 24bit MOV :) */ - unsigned char *ptr; - int x, y; - int bgr = (256 - rm) * ((bg & 0xff0000) >> 16); - int bgg = (256 - gm) * ((bg & 0xff00) >> 8); - int bgb = (256 - bm) * (bg & 0xff); - - ptr = (unsigned char *) data + (w * 3); - for (y = h; --y >= 0;) - { - for (x = -(w * 3); x < 0; x += 3) - { - int r, g, b; - -#if (G_BYTE_ORDER == G_BIG_ENDIAN) - r = (ptr[x + 0] * rm + bgr) >> 8; - g = (ptr[x + 1] * gm + bgg) >> 8; - b = (ptr[x + 2] * bm + bgb) >> 8; - ptr[x + 0] = r; - ptr[x + 1] = g; - ptr[x + 2] = b; -#else - r = (ptr[x + 2] * rm + bgr) >> 8; - g = (ptr[x + 1] * gm + bgg) >> 8; - b = (ptr[x + 0] * bm + bgb) >> 8; - ptr[x + 2] = r; - ptr[x + 1] = g; - ptr[x + 0] = b; -#endif - } - ptr += bpl; - } -} - -/* RGB 32 */ -static void -shade_ximage_32 (void *data, int bpl, int w, int h, int rm, int gm, int bm, int bg) -{ - SHADE_IMAGE (4, guint32, 0xff0000, 0xff00, 0xff); -} - -static void -shade_image (GdkVisual *visual, void *data, int bpl, int bpp, int w, int h, - int rm, int gm, int bm, int bg, int depth) -{ -#ifdef USE_MMX - int bg_r, bg_g, bg_b; - - bg_r = bg & visual->red_mask; - bg_g = bg & visual->green_mask; - bg_b = bg & visual->blue_mask; - - /* the MMX routines are about 50% faster at 16-bit. */ - /* only use MMX routines with a pure black background */ - if (bg_r == 0 && bg_g == 0 && bg_b == 0 && have_mmx ()) /* do a runtime check too! */ - { - switch (depth) - { - case 15: - shade_ximage_15_mmx (data, bpl, w, h, rm, gm, bm); - break; - case 16: - shade_ximage_16_mmx (data, bpl, w, h, rm, gm, bm); - break; - case 24: - if (bpp != 32) - goto generic; - case 32: - shade_ximage_32_mmx (data, bpl, w, h, rm, gm, bm); - break; - default: - goto generic; - } - } else - { -generic: -#endif - switch (depth) - { - case 15: - shade_ximage_15 (data, bpl, w, h, rm, gm, bm, bg); - break; - case 16: - shade_ximage_16 (data, bpl, w, h, rm, gm, bm, bg); - break; - case 24: - if (bpp != 32) - { - shade_ximage_24 (data, bpl, w, h, rm, gm, bm, bg); - break; - } - case 32: - shade_ximage_32 (data, bpl, w, h, rm, gm, bm, bg); - } -#ifdef USE_MMX - } -#endif -} - -#ifdef USE_XLIB - -#ifdef USE_SHM - -static XImage * -get_shm_image (Display *xdisplay, XShmSegmentInfo *shminfo, int x, int y, - int w, int h, int depth, Pixmap pix) -{ - XImage *ximg; - - shminfo->shmid = -1; - shminfo->shmaddr = (char*) -1; - ximg = XShmCreateImage (xdisplay, 0, depth, ZPixmap, 0, shminfo, w, h); - if (!ximg) - return NULL; - - shminfo->shmid = shmget (IPC_PRIVATE, ximg->bytes_per_line * ximg->height, - IPC_CREAT|0600); - if (shminfo->shmid == -1) - { - XDestroyImage (ximg); - return NULL; - } - - shminfo->readOnly = False; - ximg->data = shminfo->shmaddr = (char *)shmat (shminfo->shmid, 0, 0); - if (shminfo->shmaddr == ((char *)-1)) - { - shmctl (shminfo->shmid, IPC_RMID, 0); - XDestroyImage (ximg); - return NULL; - } - - XShmAttach (xdisplay, shminfo); - XSync (xdisplay, False); - shmctl (shminfo->shmid, IPC_RMID, 0); - XShmGetImage (xdisplay, pix, ximg, x, y, AllPlanes); - - return ximg; -} - -static XImage * -get_image (GtkXText *xtext, Display *xdisplay, XShmSegmentInfo *shminfo, - int x, int y, int w, int h, int depth, Pixmap pix) -{ - XImage *ximg; - - xtext->shm = 1; - ximg = get_shm_image (xdisplay, shminfo, x, y, w, h, depth, pix); - if (!ximg) - { - xtext->shm = 0; - ximg = XGetImage (xdisplay, pix, x, y, w, h, -1, ZPixmap); - } - - return ximg; -} - -#endif - -static GdkPixmap * -shade_pixmap (GtkXText * xtext, Pixmap p, int x, int y, int w, int h) -{ - unsigned int dummy, width, height, depth; - GdkPixmap *shaded_pix; - Window root; - Pixmap tmp; - XImage *ximg; - XGCValues gcv; - GC tgc; - Display *xdisplay = GDK_WINDOW_XDISPLAY (xtext->draw_buf); - -#ifdef USE_SHM - int shm_pixmaps; - shm_pixmaps = have_shm_pixmaps(xdisplay); -#endif - - XGetGeometry (xdisplay, p, &root, &dummy, &dummy, &width, &height, - &dummy, &depth); - - if (width < x + w || height < y + h || x < 0 || y < 0) - { - gcv.subwindow_mode = IncludeInferiors; - gcv.graphics_exposures = False; - tgc = XCreateGC (xdisplay, p, GCGraphicsExposures|GCSubwindowMode, - &gcv); - tmp = XCreatePixmap (xdisplay, p, w, h, depth); - XSetTile (xdisplay, tgc, p); - XSetFillStyle (xdisplay, tgc, FillTiled); - XSetTSOrigin (xdisplay, tgc, -x, -y); - XFillRectangle (xdisplay, tmp, tgc, 0, 0, w, h); - XFreeGC (xdisplay, tgc); - -#ifdef USE_SHM - if (shm_pixmaps) - ximg = get_image (xtext, xdisplay, &xtext->shminfo, 0, 0, w, h, depth, tmp); - else -#endif - ximg = XGetImage (xdisplay, tmp, 0, 0, w, h, -1, ZPixmap); - XFreePixmap (xdisplay, tmp); - } else - { -#ifdef USE_SHM - if (shm_pixmaps) - ximg = get_image (xtext, xdisplay, &xtext->shminfo, x, y, w, h, depth, p); - else -#endif - ximg = XGetImage (xdisplay, p, x, y, w, h, -1, ZPixmap); - } - - if (!ximg) - return NULL; - - if (depth <= 14) - { - shade_ximage_generic (gdk_drawable_get_visual (GTK_WIDGET (xtext)->window), - ximg, ximg->bytes_per_line, w, h, xtext->tint_red, - xtext->tint_green, xtext->tint_blue, - xtext->palette[XTEXT_BG]); - } else - { - shade_image (gdk_drawable_get_visual (GTK_WIDGET (xtext)->window), - ximg->data, ximg->bytes_per_line, ximg->bits_per_pixel, - w, h, xtext->tint_red, xtext->tint_green, xtext->tint_blue, - xtext->palette[XTEXT_BG], depth); - } - - if (xtext->recycle) - shaded_pix = xtext->pixmap; - else - { -#ifdef USE_SHM - if (xtext->shm && shm_pixmaps) - { - shaded_pix = gdk_pixmap_foreign_new_for_display ( - gdk_drawable_get_display (xtext->draw_buf), - XShmCreatePixmap (xdisplay, p, ximg->data, &xtext->shminfo, w, h, depth)); - } else -#endif - { - shaded_pix = gdk_pixmap_new (GTK_WIDGET (xtext)->window, w, h, depth); - } - } - -#ifdef USE_SHM - if (!xtext->shm || !shm_pixmaps) -#endif - XPutImage (xdisplay, GDK_WINDOW_XWINDOW (shaded_pix), - GDK_GC_XGC (xtext->fgc), ximg, 0, 0, 0, 0, w, h); - XDestroyImage (ximg); - - return shaded_pix; -} - -#endif /* !USE_XLIB */ - -/* free transparency xtext->pixmap */ -#if defined(USE_XLIB) || defined(WIN32) - -static void -gtk_xtext_free_trans (GtkXText * xtext) -{ - if (xtext->pixmap) - { -#ifdef USE_SHM - if (xtext->shm && have_shm_pixmaps(GDK_WINDOW_XDISPLAY (xtext->draw_buf))) - { - XFreePixmap (GDK_WINDOW_XDISPLAY (xtext->pixmap), - GDK_WINDOW_XWINDOW (xtext->pixmap)); - XShmDetach (GDK_WINDOW_XDISPLAY (xtext->draw_buf), &xtext->shminfo); - shmdt (xtext->shminfo.shmaddr); - } -#endif - g_object_unref (xtext->pixmap); - xtext->pixmap = NULL; - xtext->shm = 0; - } -} - -#endif - -#ifdef WIN32 - -static GdkPixmap * -win32_tint (GtkXText *xtext, GdkImage *img, int width, int height) -{ - guchar *pixelp; - int x, y; - GdkPixmap *pix; - GdkVisual *visual = gdk_drawable_get_visual (GTK_WIDGET (xtext)->window); - guint32 pixel; - int r, g, b; - - if (img->depth <= 14) - { - /* slow generic routine */ - for (y = 0; y < height; y++) - { - for (x = 0; x < width; x++) - { - if (img->depth == 1) - { - pixel = (((guchar *) img->mem)[y * img->bpl + (x >> 3)] & (1 << (7 - (x & 0x7)))) != 0; - goto here; - } - - if (img->depth == 4) - { - pixelp = (guchar *) img->mem + y * img->bpl + (x >> 1); - if (x&1) - { - pixel = (*pixelp) & 0x0F; - goto here; - } - - pixel = (*pixelp) >> 4; - goto here; - } - - pixelp = (guchar *) img->mem + y * img->bpl + x * img->bpp; - - switch (img->bpp) - { - case 1: - pixel = *pixelp; break; - - /* Windows is always LSB, no need to check img->byte_order. */ - case 2: - pixel = pixelp[0] | (pixelp[1] << 8); break; - - case 3: - pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16); break; - - case 4: - pixel = pixelp[0] | (pixelp[1] << 8) | (pixelp[2] << 16); break; - } - -here: - r = (pixel & visual->red_mask) >> visual->red_shift; - g = (pixel & visual->green_mask) >> visual->green_shift; - b = (pixel & visual->blue_mask) >> visual->blue_shift; - - /* actual tinting is only these 3 lines */ - pixel = ((r * xtext->tint_red) >> 8) << visual->red_shift | - ((g * xtext->tint_green) >> 8) << visual->green_shift | - ((b * xtext->tint_blue) >> 8) << visual->blue_shift; - - if (img->depth == 1) - if (pixel & 1) - ((guchar *) img->mem)[y * img->bpl + (x >> 3)] |= (1 << (7 - (x & 0x7))); - else - ((guchar *) img->mem)[y * img->bpl + (x >> 3)] &= ~(1 << (7 - (x & 0x7))); - else if (img->depth == 4) - { - pixelp = (guchar *) img->mem + y * img->bpl + (x >> 1); - - if (x&1) - { - *pixelp &= 0xF0; - *pixelp |= (pixel & 0x0F); - } else - { - *pixelp &= 0x0F; - *pixelp |= (pixel << 4); - } - } else - { - pixelp = (guchar *) img->mem + y * img->bpl + x * img->bpp; - - /* Windows is always LSB, no need to check img->byte_order. */ - switch (img->bpp) - { - case 4: - pixelp[3] = 0; - case 3: - pixelp[2] = ((pixel >> 16) & 0xFF); - case 2: - pixelp[1] = ((pixel >> 8) & 0xFF); - case 1: - pixelp[0] = (pixel & 0xFF); - } - } - } - } - } else - { - shade_image (visual, img->mem, img->bpl, img->bpp, width, height, - xtext->tint_red, xtext->tint_green, xtext->tint_blue, - xtext->palette[XTEXT_BG], visual->depth); - } - - /* no need to dump it to a Pixmap, it's one and the same on win32 */ - pix = (GdkPixmap *)img; - - return pix; -} - -#endif /* !WIN32 */ - -/* grab pixmap from root window and set xtext->pixmap */ -#if defined(USE_XLIB) || defined(WIN32) - -static void -gtk_xtext_load_trans (GtkXText * xtext) -{ -#ifdef WIN32 - GdkImage *img; - int width, height; - HDC hdc; - HWND hwnd; - - /* if not shaded, we paint directly with PaintDesktop() */ - if (!xtext->shaded) - return; - - hwnd = GDK_WINDOW_HWND (GTK_WIDGET (xtext)->window); - hdc = GetDC (hwnd); - PaintDesktop (hdc); - ReleaseDC (hwnd, hdc); - - gdk_drawable_get_size (GTK_WIDGET (xtext)->window, &width, &height); - img = gdk_drawable_get_image (GTK_WIDGET (xtext)->window, 0, 0, width+128, height); - xtext->pixmap = win32_tint (xtext, img, img->width, img->height); - -#else - - Pixmap rootpix; - GtkWidget *widget = GTK_WIDGET (xtext); - int x, y; - - rootpix = get_pixmap_prop (GDK_WINDOW_XDISPLAY (widget->window), GDK_WINDOW_XWINDOW (widget->window)); - if (rootpix == None) - { - if (xtext->error_function) - xtext->error_function (0); - xtext->transparent = FALSE; - return; - } - - gdk_window_get_origin (widget->window, &x, &y); - - if (xtext->shaded) - { - int width, height; - gdk_drawable_get_size (GTK_WIDGET (xtext)->window, &width, &height); - xtext->pixmap = shade_pixmap (xtext, rootpix, x, y, width+105, height); - if (xtext->pixmap == NULL) - { - xtext->shaded = 0; - goto noshade; - } - gdk_gc_set_tile (xtext->bgc, xtext->pixmap); - gdk_gc_set_ts_origin (xtext->bgc, 0, 0); - xtext->ts_x = xtext->ts_y = 0; - } else - { -noshade: - xtext->pixmap = gdk_pixmap_foreign_new_for_display (gdk_drawable_get_display (GTK_WIDGET (xtext)->window), rootpix); - gdk_gc_set_tile (xtext->bgc, xtext->pixmap); - gdk_gc_set_ts_origin (xtext->bgc, -x, -y); - xtext->ts_x = -x; - xtext->ts_y = -y; - } - gdk_gc_set_fill (xtext->bgc, GDK_TILED); -#endif /* !WIN32 */ -} - -#endif /* ! XLIB || WIN32 */ - /* walk through str until this line doesn't fit anymore */ static int @@ -4388,7 +3261,6 @@ gtk_xtext_render_line (GtkXText * xtext, textentry * ent, int line, indent = ent->indent; start_subline = subline; -#ifdef HEXCHAT /* draw the timestamp */ if (xtext->auto_indent && xtext->buffer->time_stamp && (!xtext->skip_stamp || xtext->mark_stamp || xtext->force_stamp)) @@ -4400,7 +3272,6 @@ gtk_xtext_render_line (GtkXText * xtext, textentry * ent, int line, gtk_xtext_render_stamp (xtext, ent, time_str, len, line, win_width); g_free (time_str); } -#endif /* draw each line one by one */ do @@ -4468,13 +3339,6 @@ gtk_xtext_set_palette (GtkXText * xtext, GdkColor palette[]) for (i = (XTEXT_COLS-1); i >= 0; i--) { -#ifdef USE_XFT - xtext->color[i].color.red = palette[i].red; - xtext->color[i].color.green = palette[i].green; - xtext->color[i].color.blue = palette[i].blue; - xtext->color[i].color.alpha = 0xffff; - xtext->color[i].pixel = palette[i].pixel; -#endif xtext->palette[i] = palette[i].pixel; } @@ -4564,7 +3428,6 @@ gtk_xtext_set_font (GtkXText *xtext, char *name) xtext->space_width = xtext->fontwidth[' ']; xtext->fontsize = xtext->font->ascent + xtext->font->descent; -#ifdef HEXCHAT { char *time_str; int stamp_size = xtext_get_stamp_str (time(0), &time_str); @@ -4572,7 +3435,6 @@ gtk_xtext_set_font (GtkXText *xtext, char *name) gtk_xtext_text_width (xtext, time_str, stamp_size, NULL) + MARGIN; g_free (time_str); } -#endif gtk_xtext_fix_indent (xtext->buffer); @@ -4583,42 +3445,16 @@ gtk_xtext_set_font (GtkXText *xtext, char *name) } void -gtk_xtext_set_background (GtkXText * xtext, GdkPixmap * pixmap, gboolean trans) +gtk_xtext_set_background (GtkXText * xtext, GdkPixmap * pixmap) { GdkGCValues val; - gboolean shaded = FALSE; - - if (trans && (xtext->tint_red != 255 || xtext->tint_green != 255 || xtext->tint_blue != 255)) - shaded = TRUE; - -#if !defined(USE_XLIB) && !defined(WIN32) - shaded = FALSE; - trans = FALSE; -#endif if (xtext->pixmap) { -#if defined(USE_XLIB) || defined(WIN32) - if (xtext->transparent) - gtk_xtext_free_trans (xtext); - else -#endif - g_object_unref (xtext->pixmap); + g_object_unref (xtext->pixmap); xtext->pixmap = NULL; } - xtext->transparent = trans; - -#if defined(USE_XLIB) || defined(WIN32) - if (trans) - { - xtext->shaded = shaded; - if (GTK_WIDGET_REALIZED (xtext)) - gtk_xtext_load_trans (xtext); - return; - } -#endif - dontscroll (xtext->buffer); xtext->pixmap = pixmap; @@ -4880,6 +3716,8 @@ gtk_xtext_render_page (GtkXText * xtext) int height; int subline; int startline = xtext->adj->value; + int pos, overlap; + GdkRectangle area; if(!GTK_WIDGET_REALIZED(xtext)) return; @@ -4892,11 +3730,7 @@ gtk_xtext_render_page (GtkXText * xtext) if (width < 34 || height < xtext->fontsize || width < xtext->buffer->indent + 32) return; -#ifdef SMOOTH_SCROLL xtext->pixel_offset = (xtext->adj->value - startline) * xtext->fontsize; -#else - xtext->pixel_offset = 0; -#endif subline = line = 0; ent = xtext->buffer->text_first; @@ -4908,36 +3742,14 @@ gtk_xtext_render_page (GtkXText * xtext) xtext->buffer->pagetop_subline = subline; xtext->buffer->pagetop_line = startline; -#ifdef SCROLL_HACK -{ - int pos, overlap; - GdkRectangle area; - if (xtext->buffer->num_lines <= xtext->adj->page_size) dontscroll (xtext->buffer); -#ifdef SMOOTH_SCROLL pos = xtext->adj->value * xtext->fontsize; -#else - pos = startline * xtext->fontsize; -#endif overlap = xtext->buffer->last_pixel_pos - pos; xtext->buffer->last_pixel_pos = pos; -#ifdef USE_DB -#ifdef WIN32 - if (!xtext->transparent && !xtext->pixmap && abs (overlap) < height) -#else - if (!xtext->pixmap && abs (overlap) < height) -#endif -#else - /* dont scroll PageUp/Down without a DB, it looks ugly */ -#ifdef WIN32 - if (!xtext->transparent && !xtext->pixmap && abs (overlap) < height - (3*xtext->fontsize)) -#else - if (!xtext->pixmap && abs (overlap) < height - (3*xtext->fontsize)) -#endif -#endif + if (abs (overlap) < height) { /* so the obscured regions are exposed */ gdk_gc_set_exposures (xtext->fgc, TRUE); @@ -4970,8 +3782,6 @@ gtk_xtext_render_page (GtkXText * xtext) return; } -} -#endif xtext->buffer->grid_dirty = FALSE; width -= MARGIN; @@ -4999,17 +3809,10 @@ gtk_xtext_render_page (GtkXText * xtext) } void -gtk_xtext_refresh (GtkXText * xtext, int do_trans) +gtk_xtext_refresh (GtkXText * xtext) { if (GTK_WIDGET_REALIZED (GTK_WIDGET (xtext))) { -#if defined(USE_XLIB) || defined(WIN32) - if (xtext->transparent && do_trans) - { - gtk_xtext_free_trans (xtext); - gtk_xtext_load_trans (xtext); - } -#endif gtk_xtext_render_page (xtext); } } @@ -5183,7 +3986,7 @@ gtk_xtext_clear (xtext_buffer *buf, int lines) if (buf->xtext->buffer == buf) { gtk_xtext_calc_lines (buf, TRUE); - gtk_xtext_refresh (buf->xtext, 0); + gtk_xtext_refresh (buf->xtext); } else { gtk_xtext_calc_lines (buf, FALSE); @@ -5724,11 +4527,9 @@ gtk_xtext_append_entry (xtext_buffer *buf, textentry * ent, time_t stamp) if (buf->xtext->buffer == buf) { -#ifdef SCROLL_HACK /* this could be improved */ if ((buf->num_lines - 1) <= buf->xtext->adj->page_size) dontscroll (buf); -#endif if (!buf->xtext->add_io_tag) { @@ -5909,12 +4710,6 @@ gtk_xtext_foreach (xtext_buffer *buf, GtkXTextForeach func, void *data) } void -gtk_xtext_set_error_function (GtkXText *xtext, void (*error_function) (int)) -{ - xtext->error_function = error_function; -} - -void gtk_xtext_set_indent (GtkXText *xtext, gboolean indent) { xtext->auto_indent = indent; @@ -5957,17 +4752,6 @@ gtk_xtext_set_time_stamp (xtext_buffer *buf, gboolean time_stamp) } void -gtk_xtext_set_tint (GtkXText *xtext, int tint_red, int tint_green, int tint_blue) -{ - xtext->tint_red = tint_red; - xtext->tint_green = tint_green; - xtext->tint_blue = tint_blue; - - /*if (xtext->tint_red != 255 || xtext->tint_green != 255 || xtext->tint_blue != 255) - shaded = TRUE;*/ -} - -void gtk_xtext_set_urlcheck_function (GtkXText *xtext, int (*urlcheck_function) (GtkWidget *, char *)) { xtext->urlcheck_function = urlcheck_function; @@ -6059,10 +4843,6 @@ gtk_xtext_buffer_show (GtkXText *xtext, xtext_buffer *buf, int render) gtk_xtext_render_page (xtext); gtk_adjustment_changed (xtext->adj); - } else - { - /* avoid redoing the transparency */ - xtext->avoid_trans = TRUE; } } diff --git a/src/fe-gtk/xtext.h b/src/fe-gtk/xtext.h index 32e26af6..6956092f 100644 --- a/src/fe-gtk/xtext.h +++ b/src/fe-gtk/xtext.h @@ -21,16 +21,6 @@ #define HEXCHAT_XTEXT_H #include <gtk/gtk.h> -#ifdef USE_XFT -#include <X11/Xft/Xft.h> -#endif - -#ifdef USE_SHM -#include <X11/Xlib.h> -#include <sys/ipc.h> -#include <sys/shm.h> -#include <X11/extensions/XShm.h> -#endif #define GTK_TYPE_XTEXT (gtk_xtext_get_type ()) #define GTK_XTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_XTEXT, GtkXText)) @@ -132,10 +122,6 @@ struct _GtkXText xtext_buffer *orig_buffer; xtext_buffer *selection_buffer; -#ifdef USE_SHM - XShmSegmentInfo shminfo; -#endif - GtkAdjustment *adj; GdkPixmap *pixmap; /* 0 = use palette[19] */ GdkDrawable *draw_buf; /* points to ->window */ @@ -149,10 +135,6 @@ struct _GtkXText int last_win_h; int last_win_w; - int tint_red; - int tint_green; - int tint_blue; - GdkGC *bgc; /* backing pixmap */ GdkGC *fgc; /* text foreground color */ GdkGC *light_gc; /* sep bar */ @@ -188,14 +170,6 @@ struct _GtkXText guint16 fontwidth[128]; /* each char's width, only the ASCII ones */ -#ifdef USE_XFT - XftColor color[XTEXT_COLS]; - XftColor *xft_fg; - XftColor *xft_bg; /* both point into color[20] */ - XftDraw *xftdraw; - XftFont *font; - XftFont *ifont; /* italics */ -#else struct pangofont { PangoFontDescription *font; @@ -204,7 +178,6 @@ struct _GtkXText int descent; } *font, pango_font; PangoLayout *layout; -#endif int fontsize; int space_width; /* width (pixels) of the space " " character */ @@ -213,7 +186,6 @@ struct _GtkXText unsigned char scratch_buffer[4096]; - void (*error_function) (int type); int (*urlcheck_function) (GtkWidget * xtext, char *word); int jump_out_offset; /* point at which to stop rendering */ @@ -256,20 +228,15 @@ struct _GtkXText unsigned int in_hilight:1; unsigned int un_hilight:1; unsigned int recycle:1; - unsigned int avoid_trans:1; unsigned int force_render:1; - unsigned int shm:1; unsigned int color_paste:1; /* CTRL was pressed when selection finished */ /* settings/prefs */ unsigned int auto_indent:1; unsigned int thinline:1; - unsigned int transparent:1; - unsigned int shaded:1; unsigned int marker:1; unsigned int separator:1; unsigned int wordwrap:1; - unsigned int overdraw:1; unsigned int ignore_hidden:1; /* rawlog uses this */ }; @@ -286,11 +253,11 @@ void gtk_xtext_append_indent (xtext_buffer *buf, unsigned char *right_text, int right_len, time_t stamp); int gtk_xtext_set_font (GtkXText *xtext, char *name); -void gtk_xtext_set_background (GtkXText * xtext, GdkPixmap * pixmap, gboolean trans); +void gtk_xtext_set_background (GtkXText * xtext, GdkPixmap * pixmap); void gtk_xtext_set_palette (GtkXText * xtext, GdkColor palette[]); void gtk_xtext_clear (xtext_buffer *buf, int lines); void gtk_xtext_save (GtkXText * xtext, int fh); -void gtk_xtext_refresh (GtkXText * xtext, int do_trans); +void gtk_xtext_refresh (GtkXText * xtext); int gtk_xtext_lastlog (xtext_buffer *out, xtext_buffer *search_area); textentry *gtk_xtext_search (GtkXText * xtext, const gchar *text, gtk_xtext_search_flags flags, GError **err); void gtk_xtext_reset_marker_pos (GtkXText *xtext); @@ -308,7 +275,6 @@ void gtk_xtext_set_show_marker (GtkXText *xtext, gboolean show_marker); void gtk_xtext_set_show_separator (GtkXText *xtext, gboolean show_separator); void gtk_xtext_set_thin_separator (GtkXText *xtext, gboolean thin_separator); void gtk_xtext_set_time_stamp (xtext_buffer *buf, gboolean timestamp); -void gtk_xtext_set_tint (GtkXText *xtext, int tint_red, int tint_green, int tint_blue); void gtk_xtext_set_urlcheck_function (GtkXText *xtext, int (*urlcheck_function) (GtkWidget *, char *)); void gtk_xtext_set_wordwrap (GtkXText *xtext, gboolean word_wrap); |