⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 magnifier_8c-source.html

📁 在Linux下实现magnification功能
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<a name="l00321"></a>00321                 <span class="keywordflow">else</span><a name="l00322"></a>00322                     <a class="code" href="magnifier_8c.html#df135b87caf84f55fccdf33f614415ae">DBG</a> (g_warning (<span class="stringliteral">"empty cursor pixmap created."</span>));<a name="l00323"></a>00323                 mask = gdk_pixmap_new (drawable, width, height, 1);<a name="l00324"></a>00324                 gdk_pixbuf_render_threshold_alpha (cursor_pixbuf, mask, 0, 0, 0, 0, <a name="l00325"></a>00325                                                    width, height,<a name="l00326"></a>00326                                                    200);<a name="l00327"></a>00327                 g_object_unref (gc);<a name="l00328"></a>00328                 magnifier-&gt;<a class="code" href="structMagnifier.html#92b3f715e639bde2e224d91c6801997b">priv</a>-&gt;<a class="code" href="struct__MagnifierPrivate.html#adc149b6251214598ded61e94701c72a">cursor</a> = pixmap;<a name="l00329"></a>00329                 magnifier-&gt;<a class="code" href="structMagnifier.html#92b3f715e639bde2e224d91c6801997b">priv</a>-&gt;<a class="code" href="struct__MagnifierPrivate.html#ca0b00458d05304b067667d70cb67999">cursor_mask</a> = mask;<a name="l00330"></a>00330                 xhot_string = gdk_pixbuf_get_option (cursor_pixbuf,<span class="stringliteral">"x_hot"</span>);<a name="l00331"></a>00331                 yhot_string = gdk_pixbuf_get_option (cursor_pixbuf,<span class="stringliteral">"y_hot"</span>);<a name="l00332"></a>00332                 <span class="keywordflow">if</span> (xhot_string) magnifier-&gt;<a class="code" href="structMagnifier.html#ed1a58ae12dbce3403e85d888d590d62">cursor_hotspot</a>.<a class="code" href="structGNOME__Magnifier__Point__type.html#2eaea83e1ea7142248119a1d9715da9c">x</a> = atoi (xhot_string);<a name="l00333"></a>00333                 <span class="keywordflow">if</span> (yhot_string) magnifier-&gt;<a class="code" href="structMagnifier.html#ed1a58ae12dbce3403e85d888d590d62">cursor_hotspot</a>.<a class="code" href="structGNOME__Magnifier__Point__type.html#a2aeb73b18588c327b743753378ba831">y</a> = atoi (yhot_string);<a name="l00334"></a>00334 <a name="l00335"></a>00335                 <span class="keywordflow">if</span> (pixmap) {<a name="l00336"></a>00336                         gdk_drawable_get_size (pixmap,<a name="l00337"></a>00337                                                &amp;magnifier-&gt;<a class="code" href="structMagnifier.html#92b3f715e639bde2e224d91c6801997b">priv</a>-&gt;<a class="code" href="struct__MagnifierPrivate.html#e1961bea1b89e23f62a52b7f02258394">cursor_default_size_x</a>,<a name="l00338"></a>00338                                                &amp;magnifier-&gt;<a class="code" href="structMagnifier.html#92b3f715e639bde2e224d91c6801997b">priv</a>-&gt;<a class="code" href="struct__MagnifierPrivate.html#98cdc898c86fa86b018124028100b41f">cursor_default_size_y</a>);<a name="l00339"></a>00339                         magnifier-&gt;<a class="code" href="structMagnifier.html#92b3f715e639bde2e224d91c6801997b">priv</a>-&gt;<a class="code" href="struct__MagnifierPrivate.html#89e8922fed2c13630cb45dd8cd38d453">cursor_hotspot_x</a> = magnifier-&gt;<a class="code" href="structMagnifier.html#ed1a58ae12dbce3403e85d888d590d62">cursor_hotspot</a>.<a class="code" href="structGNOME__Magnifier__Point__type.html#2eaea83e1ea7142248119a1d9715da9c">x</a>;<a name="l00340"></a>00340                         magnifier-&gt;<a class="code" href="structMagnifier.html#92b3f715e639bde2e224d91c6801997b">priv</a>-&gt;<a class="code" href="struct__MagnifierPrivate.html#c64cb6774c598b1390ccfe45d0d6e5e2">cursor_hotspot_y</a> = magnifier-&gt;<a class="code" href="structMagnifier.html#ed1a58ae12dbce3403e85d888d590d62">cursor_hotspot</a>.<a class="code" href="structGNOME__Magnifier__Point__type.html#a2aeb73b18588c327b743753378ba831">y</a>;<a name="l00341"></a>00341                 }<a name="l00342"></a>00342         }<a name="l00343"></a>00343 }<a name="l00344"></a>00344 <a name="l00345"></a>00345 <a name="l00346"></a>00346 GdkPixbuf *<a name="l00347"></a><a class="code" href="magnifier_8c.html#d22c8b3ffe12523f9a37904147d2c6dd">00347</a> <a class="code" href="magnifier_8c.html#d22c8b3ffe12523f9a37904147d2c6dd">magnifier_get_pixbuf_for_name</a> (<a class="code" href="structMagnifier.html">Magnifier</a> *magnifier, <span class="keyword">const</span> gchar *cursor_name)<a name="l00348"></a>00348 {<a name="l00349"></a>00349     GdkPixbuf *retval = NULL;<a name="l00350"></a>00350     <span class="keywordflow">if</span> (magnifier-&gt;<a class="code" href="structMagnifier.html#92b3f715e639bde2e224d91c6801997b">priv</a>-&gt;<a class="code" href="struct__MagnifierPrivate.html#95392051aba2572559d365b9ceced4f3">cursorlist</a>) <a name="l00351"></a>00351             retval = g_hash_table_lookup (magnifier-&gt;<a class="code" href="structMagnifier.html#92b3f715e639bde2e224d91c6801997b">priv</a>-&gt;<a class="code" href="struct__MagnifierPrivate.html#95392051aba2572559d365b9ceced4f3">cursorlist</a>, cursor_name);<a name="l00352"></a>00352     <span class="keywordflow">if</span> (retval) <a name="l00353"></a>00353             g_object_ref (retval);<a name="l00354"></a>00354     <span class="keywordflow">return</span> retval;<a name="l00355"></a>00355 }<a name="l00356"></a>00356 <a name="l00357"></a>00357 <span class="keywordtype">void</span><a name="l00358"></a><a class="code" href="magnifier_8h.html#950892a831f3f33c880de3523c6ba438">00358</a> <a class="code" href="magnifier_8c.html#950892a831f3f33c880de3523c6ba438">magnifier_set_cursor_pixmap_by_name</a> (<a class="code" href="structMagnifier.html">Magnifier</a> *magnifier,<a name="l00359"></a>00359                                      <span class="keyword">const</span> gchar *cursor_name, <a name="l00360"></a>00360                                      gboolean source_fallback)<a name="l00361"></a>00361 {<a name="l00362"></a>00362         GdkPixbuf *pixbuf;<a name="l00363"></a>00363         <span class="comment">/* search local table; if not found, use source screen's cursor if source_fallback is TRUE */</span><a name="l00364"></a>00364         <span class="keywordflow">if</span> ((pixbuf = <a class="code" href="magnifier_8c.html#d22c8b3ffe12523f9a37904147d2c6dd">magnifier_get_pixbuf_for_name</a> (magnifier, cursor_name)) == NULL) {<a name="l00365"></a>00365 <span class="preprocessor">#ifndef HAVE_XFIXES</span><a name="l00366"></a>00366 <span class="preprocessor"></span>                source_fallback = FALSE;<a name="l00367"></a>00367 <span class="preprocessor">#endif</span><a name="l00368"></a>00368 <span class="preprocessor"></span>                <span class="keywordflow">if</span> (source_fallback == TRUE)<a name="l00369"></a>00369                 {<a name="l00370"></a>00370                         pixbuf = <a class="code" href="gmag-events_8c.html#92028646c119503363680b103100f2b9">gmag_events_get_source_pixbuf</a> (magnifier);<a name="l00371"></a>00371                 }<a name="l00372"></a>00372                 <span class="keywordflow">else</span><a name="l00373"></a>00373                 {<a name="l00374"></a>00374                         pixbuf = <a class="code" href="magnifier_8c.html#d22c8b3ffe12523f9a37904147d2c6dd">magnifier_get_pixbuf_for_name</a> (magnifier, <span class="stringliteral">"default"</span>);<a name="l00375"></a>00375                 }<a name="l00376"></a>00376         }<a name="l00377"></a>00377         <a class="code" href="magnifier_8c.html#ce0cb09a2b2cb21339ec9cd2b4c74618">magnifier_set_cursor_from_pixbuf</a> (magnifier, pixbuf);<a name="l00378"></a>00378         <span class="keywordflow">if</span> (pixbuf) g_object_unref (pixbuf);<a name="l00379"></a>00379 }<a name="l00380"></a>00380 <a name="l00381"></a>00381 <span class="keywordtype">void</span><a name="l00382"></a><a class="code" href="magnifier_8h.html#d6b5286ea68315013935af2412cf4356">00382</a> <a class="code" href="magnifier_8c.html#d6b5286ea68315013935af2412cf4356">magnifier_notify_damage</a> (<a class="code" href="structMagnifier.html">Magnifier</a> *magnifier, XRectangle *rect)<a name="l00383"></a>00383 {<a name="l00384"></a>00384         <a class="code" href="structGNOME__Magnifier__RectBounds__type.html">GNOME_Magnifier_RectBounds</a> rect_bounds;<a name="l00385"></a>00385         rect_bounds.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#da72b580c4e14d8f1dcd85b2da3a8759">x1</a> = rect-&gt;x;<a name="l00386"></a>00386         rect_bounds.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#24de0d98768b0b42dc53ab51950760c0">y1</a> = rect-&gt;y;<a name="l00387"></a>00387         rect_bounds.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#721fd6fb9a4c3c6c3813402b31de633a">x2</a> = rect-&gt;x + rect-&gt;width;<a name="l00388"></a>00388         rect_bounds.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#3ba20b4c1f0db87a1b9f21169e20b5f3">y2</a> = rect-&gt;y + rect-&gt;height;<a name="l00389"></a>00389 <span class="preprocessor">#undef DEBUG_DAMAGE</span><a name="l00390"></a>00390 <span class="preprocessor"></span><span class="preprocessor">#ifdef DEBUG_DAMAGE</span><a name="l00391"></a>00391 <span class="preprocessor"></span>        g_message (<span class="stringliteral">"damage"</span>);<a name="l00392"></a>00392         g_message (<span class="stringliteral">"dirty %d, %d to %d, %d"</span>, rect_bounds.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#da72b580c4e14d8f1dcd85b2da3a8759">x1</a>, rect_bounds.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#24de0d98768b0b42dc53ab51950760c0">y1</a>, rect_bounds.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#721fd6fb9a4c3c6c3813402b31de633a">x2</a>, rect_bounds.<a class="code" href="structGNOME__Magnifier__RectBounds__type.html#3ba20b4c1f0db87a1b9f21169e20b5f3">y2</a>);<a name="l00393"></a>00393 <span class="preprocessor">#endif</span><a name="l00394"></a>00394 <span class="preprocessor"></span>        <a class="code" href="magnifier_8c.html#6d5dc2be3ea6ec00831ebed5670ee169">magnifier_zoom_regions_mark_dirty</a> (magnifier, rect_bounds);<a name="l00395"></a>00395 }<a name="l00396"></a>00396 <a name="l00397"></a>00397 <span class="keyword">static</span> <span class="keywordtype">void</span><a name="l00398"></a><a class="code" href="magnifier_8c.html#b7568d1c93d9a4a67a248d0f470e4ba4">00398</a> <a class="code" href="magnifier_8c.html#b7568d1c93d9a4a67a248d0f470e4ba4">magnifier_set_extension_listeners</a> (<a class="code" href="structMagnifier.html">Magnifier</a> *magnifier, GdkWindow *root)<a name="l00399"></a>00399 {<a name="l00400"></a>00400         <a class="code" href="gmag-events_8c.html#9dc8f8232bb936efc01799fc4746efdc">gmag_events_client_init</a> (magnifier);<a name="l00401"></a>00401         magnifier-&gt;<a class="code" href="structMagnifier.html#30dff20f422fd7a341a7a1989f478fe5">source_initialized</a> = TRUE;<a name="l00402"></a>00402 }<a name="l00403"></a>00403 <a name="l00404"></a>00404 <span class="keyword">static</span> <span class="keywordtype">void</span><a name="l00405"></a><a class="code" href="magnifier_8c.html#647a184911ad11bf72f7849720acdc9c">00405</a> <a class="code" href="magnifier_8c.html#647a184911ad11bf72f7849720acdc9c">magnifier_size_allocate</a> (GtkWidget *widget)<a name="l00406"></a>00406 {<a name="l00407"></a>00407         <a class="code" href="magnifier_8c.html#38ffea7cd2665602e790bb7decbf5b26">magnifier_check_set_struts</a> (<a class="code" href="magnifier_8c.html#88cb4e20f23de265f35bcf2ba3326958">_this_magnifier</a>);<a name="l00408"></a>00408 }<a name="l00409"></a>00409 <a name="l00410"></a>00410 <span class="keyword">static</span> <span class="keywordtype">void</span><a name="l00411"></a><a class="code" href="magnifier_8c.html#ba1dd0e25e50069acaa9479958f85cb7">00411</a> <a class="code" href="magnifier_8c.html#ba1dd0e25e50069acaa9479958f85cb7">magnifier_realize</a> (GtkWidget *widget)<a name="l00412"></a>00412 {<a name="l00413"></a>00413         XWMHints wm_hints;<a name="l00414"></a>00414         Atom wm_window_protocols[2];<a name="l00415"></a>00415         Atom wm_type_atoms[1];<a name="l00416"></a>00416         Atom net_wm_window_type;<a name="l00417"></a>00417         GdkDisplay *target_display = gdk_drawable_get_display (widget-&gt;window);<a name="l00418"></a>00418         <a name="l00419"></a>00419         <span class="keyword">static</span> gboolean initialized = FALSE;<a name="l00420"></a>00420 <a name="l00421"></a>00421 <span class="preprocessor">#ifndef MAG_WINDOW_OVERRIDE_REDIRECT    </span><a name="l00422"></a>00422 <span class="preprocessor"></span>        <span class="keywordflow">if</span> (!initialized) {<a name="l00423"></a>00423                 wm_window_protocols[0] = gdk_x11_get_xatom_by_name_for_display (target_display,<a name="l00424"></a>00424                                                                                 <span class="stringliteral">"WM_DELETE_WINDOW"</span>);<a name="l00425"></a>00425                 wm_window_protocols[1] = gdk_x11_get_xatom_by_name_for_display (target_display,<a name="l00426"></a>00426                                                                                 <span class="stringliteral">"_NET_WM_PING"</span>);<a name="l00427"></a>00427                 <span class="comment">/* use DOCK until Metacity RFE for new window type goes in */</span><a name="l00428"></a>00428                 wm_type_atoms[0] = gdk_x11_get_xatom_by_name_for_display (target_display,<a name="l00429"></a>00429                                                                           <span class="stringliteral">"_NET_WM_WINDOW_TYPE_DOCK"</span>);<a name="l00430"></a>00430         }<a name="l00431"></a>00431   <a name="l00432"></a>00432         wm_hints.flags = InputHint;<a name="l00433"></a>00433         wm_hints.input = False;<a name="l00434"></a>00434         

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -