fix menu transparency rendering bug, and add save_under to menu windows

This commit is contained in:
rathnor 2004-05-17 15:01:32 +00:00
parent 949a932036
commit c1fb3b3e1a
4 changed files with 51 additions and 28 deletions

View file

@ -1,5 +1,14 @@
(Format: Year/Month/Day)
Changes for 0.9.10:
*04/05/17:
* Fix rendering of transparency on menu exposes (Simon)
- also enable save unders for menu windows
This is kind of experimental. Backing store is off by default
in XF86-4. If you want to play, add: Option "BackingStore" "yes"
to the Screen section in your XF86Config file. And let me know
how it goes :) It basically means we don't have to refresh
menus as much, but uses more memory. Shouldn't break anything new.
Menu.cc FbWindow.hh/cc
*04/05/13:
* Fix a crash when a window closes while [opaque] moving (Simon)
- also tidy up several related things when a window hides

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: FbWindow.cc,v 1.32 2004/04/28 13:04:06 rathnor Exp $
// $Id: FbWindow.cc,v 1.33 2004/05/17 15:01:32 rathnor Exp $
#include "FbWindow.hh"
@ -92,6 +92,7 @@ FbWindow::FbWindow(int screen_num,
unsigned int width, unsigned int height,
long eventmask,
bool override_redirect,
bool save_unders,
int depth,
int class_type):
m_parent(0),
@ -101,13 +102,14 @@ FbWindow::FbWindow(int screen_num,
create(RootWindow(FbTk::App::instance()->display(), screen_num),
x, y, width, height, eventmask,
override_redirect, depth, class_type);
override_redirect, save_unders, depth, class_type);
};
FbWindow::FbWindow(const FbWindow &parent,
int x, int y, unsigned int width, unsigned int height,
long eventmask,
bool override_redirect,
bool override_redirect,
bool save_unders,
int depth, int class_type):
m_parent(&parent),
m_screen_num(parent.screenNumber()),
@ -115,7 +117,7 @@ FbWindow::FbWindow(const FbWindow &parent,
m_buffer_pm(0) {
create(parent.window(), x, y, width, height, eventmask,
override_redirect, depth, class_type);
override_redirect, save_unders, depth, class_type);
};
@ -432,7 +434,7 @@ void FbWindow::updateGeometry() {
void FbWindow::create(Window parent, int x, int y,
unsigned int width, unsigned int height,
long eventmask, bool override_redirect,
int depth, int class_type) {
bool save_unders, int depth, int class_type) {
if (s_display == 0)
@ -449,6 +451,11 @@ void FbWindow::create(Window parent, int x, int y,
values.override_redirect = True;
}
if (save_unders) {
valmask |= CWSaveUnder;
values.save_under = True;
}
m_window = XCreateWindow(s_display, parent, x, y, width, height,
0, // border width
depth, // depth

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: FbWindow.hh,v 1.29 2004/04/28 13:04:06 rathnor Exp $
// $Id: FbWindow.hh,v 1.30 2004/05/17 15:01:32 rathnor Exp $
#ifndef FBTK_FBWINDOW_HH
#define FBTK_FBWINDOW_HH
@ -55,6 +55,7 @@ public:
FbWindow(int screen_num,
int x, int y, unsigned int width, unsigned int height, long eventmask,
bool overrride_redirect = false,
bool save_unders = false,
int depth = CopyFromParent,
int class_type = InputOutput);
@ -63,6 +64,7 @@ public:
unsigned int width, unsigned int height,
long eventmask,
bool overrride_redirect = false,
bool save_unders = false,
int depth = CopyFromParent,
int class_type = InputOutput);
@ -171,6 +173,7 @@ private:
void create(Window parent, int x, int y, unsigned int width, unsigned int height,
long eventmask,
bool override_redirect,
bool save_unders,
int depth,
int class_type);
static Display *s_display; ///< display connection

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: Menu.cc,v 1.59 2004/04/19 22:47:36 fluxgen Exp $
// $Id: Menu.cc,v 1.60 2004/05/17 15:01:32 rathnor Exp $
//use GNU extensions
#ifndef _GNU_SOURCE
@ -122,7 +122,8 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl):
menu.window = FbTk::FbWindow(tm.screenNum(),
0, 0, 10, 10,
event_mask,
true); // override redirect
true, // override redirect
true); // save_under
// strip focus change mask from attrib, since we should only use it with main window
event_mask ^= FocusChangeMask;
@ -143,7 +144,7 @@ Menu::Menu(MenuTheme &tm, ImageControl &imgctrl):
menu.frame = FbTk::FbWindow(menu.window,
0, menu.title_h,
width(), menu.frame_h ? menu.frame_h : 1,
event_mask);
event_mask, false, true);
evm.add(*this, menu.frame);
// update style
reconfigure();
@ -1226,29 +1227,34 @@ void Menu::exposeEvent(XExposeEvent &ee) {
// this is a compilicated algorithm... lets do it step by step...
// first... we see in which sub level the expose starts... and how many
// items down in that sublevel
// Simon was here :-) I think this all makes much more sense when
// we rename sbl to "start_col", sbl_d to "end_col", ditto id -> row
// a "sublevel" is basically a column in a multi-column menu (e.g. placement)
if (menu.item_w == 0)
menu.item_w = 1;
if (menu.item_h == 0)
menu.item_h = 1;
unsigned int sbl = (ee.x / menu.item_w), id = (ee.y / menu.item_h),
// next... figure out how many sublevels over the redraw spans
sbl_d = ((ee.x + ee.width) / menu.item_w),
// then we see how many items down to redraw
id_d = ((ee.y + ee.height) / menu.item_h);
if (static_cast<signed>(id_d) > menu.persub)
id_d = menu.persub;
unsigned int
start_column = (ee.x / menu.item_w),
end_column = ((ee.x + ee.width) / menu.item_w),
start_row = (ee.y / menu.item_h),
end_row = ((ee.y + ee.height) / menu.item_h);
if (static_cast<signed>(end_row) > menu.persub)
end_row = menu.persub;
// draw the sublevels and the number of items the exposure spans
unsigned int i, ii;
unsigned int col, row;
int max_y = 0;
for (i = sbl; i <= sbl_d; i++) {
// set the iterator to the first item in the sublevel needing redrawing
unsigned int index = id + i * menu.persub;
for (col = start_column; col <= end_column; col++) {
// set the iterator to the first item in the column needing redrawing
unsigned int index = start_row + col * menu.persub;
if (index < menuitems.size()) {
Menuitems::iterator it = menuitems.begin() + index;
Menuitems::iterator it_end = menuitems.end();
for (ii = id; ii <= id_d && it != it_end; ++it, ii++) {
unsigned int index = ii + (i * menu.persub);
for (row = start_row; row <= end_row && it != it_end; ++it, row++) {
unsigned int index = row + (col * menu.persub);
max_y = max(drawItem(index,
(which_sub == static_cast<signed>(index)), // highlight
true, // clear
@ -1257,12 +1263,10 @@ void Menu::exposeEvent(XExposeEvent &ee) {
}
}
}
if (menu.persub != 0) {
int index_min = id + sbl * menu.persub;
int min_y = (index_min - (index_min/menu.persub)*menu.persub) * menu.item_h;
menu.frame.updateTransparent(0, min_y,
width(), max_y + menu.item_h);
}
menu.frame.updateTransparent(start_column * menu.item_w,
start_row * menu.item_h,
(end_column-start_column+1) * menu.item_w,
(end_row-start_row+1) * menu.item_h);
}
}