Skip to content

Commit f2331d5

Browse files
author
Fraser J. Gordon
committed
[[ LinuxGdk ]] Many minor fixes and cleanups
1 parent 611f1bb commit f2331d5

18 files changed

Lines changed: 71 additions & 33 deletions

File tree

engine/engine.xcodeproj/project.pbxproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,11 @@
15011501
721CAAC618351E7400858545 /* libicutu.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libicutu.a; path = ../prebuilt/lib/mac/libicutu.a; sourceTree = "<group>"; };
15021502
721CAAC718351E7400858545 /* libicuuc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libicuuc.a; path = ../prebuilt/lib/mac/libicuuc.a; sourceTree = "<group>"; };
15031503
7238DF4E1848B189007EA049 /* MCBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MCBlock.h; path = src/MCBlock.h; sourceTree = "<group>"; };
1504+
72C22E951945E48E00B18E8D /* syslnxfs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = syslnxfs.cpp; path = src/syslnxfs.cpp; sourceTree = "<group>"; };
1505+
72C22E961945E48E00B18E8D /* syslnxregion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = syslnxregion.cpp; path = src/syslnxregion.cpp; sourceTree = "<group>"; };
1506+
72C22E971945E48E00B18E8D /* sysunxrandom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sysunxrandom.cpp; path = src/sysunxrandom.cpp; sourceTree = "<group>"; };
1507+
72C22E981945E48E00B18E8D /* sysw32fs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sysw32fs.cpp; path = src/sysw32fs.cpp; sourceTree = "<group>"; };
1508+
72C22E991945E48E00B18E8D /* sysw32random.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sysw32random.cpp; path = src/sysw32random.cpp; sourceTree = "<group>"; };
15041509
72C28AF819112FDE007F2AA0 /* segment.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = segment.h; path = src/segment.h; sourceTree = "<group>"; };
15051510
72C28AF91911300D007F2AA0 /* segment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = segment.cpp; path = src/segment.cpp; sourceTree = "<group>"; };
15061511
72D6038218477E560022379C /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/QuartzCore.framework; sourceTree = DEVELOPER_DIR; };
@@ -2514,6 +2519,11 @@
25142519
4DFD486413BA28BF008DB91F /* System */ = {
25152520
isa = PBXGroup;
25162521
children = (
2522+
72C22E951945E48E00B18E8D /* syslnxfs.cpp */,
2523+
72C22E961945E48E00B18E8D /* syslnxregion.cpp */,
2524+
72C22E971945E48E00B18E8D /* sysunxrandom.cpp */,
2525+
72C22E981945E48E00B18E8D /* sysw32fs.cpp */,
2526+
72C22E991945E48E00B18E8D /* sysw32random.cpp */,
25172527
76EF31A9181E801800FAC195 /* sysosxrandom.cpp */,
25182528
4DDB66521413990400E5C84C /* sysregion.cpp */,
25192529
4DDB66531413990400E5C84C /* sysunxdate.cpp */,

engine/src/linux.stubs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ gdk libgdk-x11-2.0.so.0
260260
gdk_drag_context_get_selected_action: (pointer) -> (integer)
261261
gdk_set_program_class: (pointer) -> ()
262262
gdk_pointer_is_grabbed: () -> (integer)
263+
gdk_threads_init: () -> ()
264+
gdk_threads_enter: () -> ()
265+
gdk_threads_leave: () -> ()
266+
gdk_event_new: (integer) -> (pointer)
267+
gdk_region_rectangle: (pointer) -> (pointer)
263268

264269
gdk_pixbuf libgdk_pixbuf-2.0.so.0
265270
gdk_pixbuf_get_pixels: (pointer) -> (pointer)

engine/src/lnxdclnx.cpp

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -269,35 +269,24 @@ Boolean MCScreenDC::handle(Boolean dispatch, Boolean anyevent, Boolean& abort, B
269269
// Loop until both the pending event queue and GDK event queue are empty
270270
abort = reset = False;
271271
bool t_handled = false;
272-
while (dispatch || g_main_context_pending(NULL) || gdk_events_pending())
272+
while (true || dispatch || g_main_context_pending(NULL) || gdk_events_pending())
273273
{
274-
// Run the GLib event loop to exhaustion
275-
while (g_main_context_iteration(NULL, FALSE))
276-
;
274+
// Place all events onto the pending event queue
275+
EnqueueGdkEvents();
277276

278-
bool t_live;
279277
bool t_queue = false;
280278
if (dispatch && pendingevents != NULL)
281279
{
282280
// Get the next event from the queue
283281
t_event = gdk_event_copy(pendingevents->event);
284282
MCEventnode *tptr = (MCEventnode *)pendingevents->remove(pendingevents);
285283
delete tptr;
286-
t_live = false;
287-
}
288-
else
289-
{
290-
// In theory, all events should have already been queued as pending
291-
// through the GLib main loop. However, that only applies to those
292-
// that the server has already sent - this function call prompts the
293-
// server to send any events queued on its end.
294-
t_event = gdk_event_get();
295-
t_live = true;
296284
}
297285

298-
// Make sure we have an event
299286
if (t_event == NULL)
287+
{
300288
break;
289+
}
301290

302291
// What type of event are we dealing with?
303292
switch (t_event->type)
@@ -312,7 +301,9 @@ Boolean MCScreenDC::handle(Boolean dispatch, Boolean anyevent, Boolean& abort, B
312301
case GDK_DAMAGE:
313302
{
314303
// Handled separately
315-
gdk_display_put_event(dpy, t_event);
304+
//fprintf(stderr, "GDK_EXPOSE (window %p)\n", t_event->expose.window);
305+
MCEventnode *t_node = new MCEventnode(gdk_event_copy(t_event));
306+
t_node->appendto(pendingevents);
316307
expose();
317308
break;
318309
}
@@ -911,8 +902,10 @@ void MCScreenDC::EnqueueGdkEvents()
911902
while (true)
912903
{
913904
// Run the GLib main loop
905+
gdk_threads_leave();
914906
while (g_main_context_iteration(NULL, FALSE))
915907
;
908+
gdk_threads_enter();
916909

917910
// Enqueue any further GDK events
918911
GdkEvent *t_event = gdk_event_get();
@@ -1003,7 +996,7 @@ void DnDClientEvent(GdkEvent* p_event)
1003996
{
1004997
case GDK_DRAG_ENTER:
1005998
{
1006-
fprintf(stderr, "DND: drag enter\n");
999+
//fprintf(stderr, "DND: drag enter\n");
10071000
// Get the selection atom for this drag event
10081001
GdkAtom t_selection;
10091002
t_selection = gdk_drag_get_selection(p_event->dnd.context);
@@ -1040,7 +1033,7 @@ void DnDClientEvent(GdkEvent* p_event)
10401033

10411034
case GDK_DRAG_LEAVE:
10421035
{
1043-
fprintf(stderr, "DND: drag leave\n");
1036+
//fprintf(stderr, "DND: drag leave\n");
10441037
// The drag is no longer relevant to us
10451038
MCdispatcher->wmdragleave(p_event->dnd.window);
10461039
MCtransferstore->cleartypes();
@@ -1049,7 +1042,7 @@ void DnDClientEvent(GdkEvent* p_event)
10491042

10501043
case GDK_DRAG_MOTION:
10511044
{
1052-
fprintf(stderr, "DND: drag motion\n");
1045+
//fprintf(stderr, "DND: drag motion\n");
10531046
// Translate the position from root to relative coordinates
10541047
uint32_t wx, wy; // Window-relative coordinates
10551048
gint ox, oy; // Window origin in root coordinates
@@ -1088,7 +1081,7 @@ void DnDClientEvent(GdkEvent* p_event)
10881081

10891082
case GDK_DROP_START:
10901083
{
1091-
fprintf(stderr, "DND: drop start\n");
1084+
//fprintf(stderr, "DND: drop start\n");
10921085
// Temporarily adopt the asynchronous modifier state
10931086
uint16_t t_old_modstate = MCmodifierstate;
10941087
MCmodifierstate = MCscreen->querymods();

engine/src/lnxdcs.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,15 @@ Boolean MCScreenDC::open()
199199
&& initialise_weak_link_gdk() != 0
200200
&& initialise_weak_link_gdk_pixbuf() != 0;
201201

202-
gdk_init(0, NULL);
203-
204202
if (!t_has_gdk)
205203
{
206204
// TODO: implement
207205
exit(1);
208206
}
209207

208+
gdk_init(0, NULL);
209+
gdk_threads_init();
210+
210211
// Check to see if we are in a UTF8 locale
211212
// TS : Changed 2008-01-08 as a more relaible way of testing for UTF-8
212213
MCutf8 = (strcmp(nl_langinfo(CODESET), "UTF-8") == 0) ;
@@ -716,7 +717,6 @@ void MCScreenDC::raisewindow(Window window)
716717
}
717718

718719
void MCScreenDC::iconifywindow(Window window)
719-
720720
{
721721
gdk_window_iconify(window);
722722
}

engine/src/lnxstack.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ void MCStack::realize()
152152

153153
window = gdk_window_new(screen->getroot(), &gdkwa, gdk_valid_wa);
154154

155+
//fprintf(stderr, "Window %p - \"%s\"\n", window, MCNameGetCString(_name));
156+
155157
// This is necessary to be able to receive drag-and-drop events
156158
gdk_window_register_dnd(window);
157159

@@ -162,9 +164,13 @@ void MCStack::realize()
162164
if (m_window_shape != nil && m_window_shape -> is_sharp)
163165
gdk_window_shape_combine_mask(window, (GdkPixmap*)m_window_shape->handle, 0, 0);
164166

167+
// At least one window has been created so startup is complete
168+
gdk_notify_startup_complete();
169+
165170
// DEBUGGING
166171
//gdk_window_set_debug_updates(TRUE);
167-
gdk_window_invalidate_rect(window, NULL, TRUE);
172+
//gdk_window_invalidate_rect(window, NULL, TRUE);
173+
//gdk_window_process_all_updates();
168174

169175
gdk_display_sync(MCdpy);
170176
}
@@ -321,7 +327,6 @@ void MCStack::sethints()
321327

322328
chints.res_class = (char*)*t_class_name_cstr;
323329
x11::XSetClassHint(x11::gdk_x11_display_get_xdisplay(MCdpy), x11::gdk_x11_drawable_get_xid(window), &chints);
324-
MCMemoryDelete(chints.res_name);
325330

326331
// TODO: is this just another way of ensuring on-top-ness?
327332
//if (mode >= WM_PALETTE)
@@ -628,7 +633,10 @@ void MCStack::setopacity(unsigned char p_level)
628633
gdouble t_opacity;
629634
t_opacity = gdouble(p_level) / 255.0;
630635

631-
gdk_window_set_opacity(window, t_opacity);
636+
if (p_level == 255)
637+
gdk_window_set_opacity(window, 1.0);
638+
else
639+
gdk_window_set_opacity(window, t_opacity);
632640
}
633641

634642
void MCStack::updatemodifiedmark(void)
@@ -721,6 +729,8 @@ class MCLinuxStackSurface: public MCStackSurface
721729
if (MCU_empty_rect(t_actual_area))
722730
return false;
723731

732+
//fprintf(stderr, "MCLinuxStackSurface::lock(): %d,%d,%d,%d\n", t_actual_area.x, t_actual_area.y, t_actual_area.width, t_actual_area.height);
733+
724734
bool t_success = true;
725735

726736
if (t_success)
@@ -734,7 +744,7 @@ class MCLinuxStackSurface: public MCStackSurface
734744
m_raster . format = kMCGRasterFormat_ARGB;
735745
m_raster . width = t_actual_area . width;
736746
m_raster . height = t_actual_area . height;
737-
m_raster . stride = t_actual_area . width * sizeof(uint32_t);
747+
m_raster . stride = gdk_pixbuf_get_rowstride(m_bitmap);
738748
m_raster . pixels = gdk_pixbuf_get_pixels(m_bitmap);
739749

740750
m_area = t_actual_area;

engine/src/lnxtransfer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,8 @@ bool MCGdkTransferStore::GetExternalData(MCTransferType p_type, GdkAtom p_atom,
436436
return t_success && Convert_MIME_to_REV(*t_data, t_mime_type, r_data);
437437
}
438438
}
439+
440+
return false;
439441
}
440442

441443
/*

engine/src/syslnxregion.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ MCRectangle MCRegionGetBoundingBox(MCRegionRef p_region)
6363
bool MCRegionSetEmpty(MCRegionRef p_region)
6464
{
6565
gdk_region_subtract((GdkRegion*)p_region, (GdkRegion*)p_region);
66+
return true;
6667
}
6768

6869
bool MCRegionSetRect(MCRegionRef p_region, const MCRectangle& p_rect)

libcore/libcore.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@
136136
/* Begin PBXProject section */
137137
4DF42A350B04860B003F2D95 /* Project object */ = {
138138
isa = PBXProject;
139+
attributes = {
140+
};
139141
buildConfigurationList = 4DF42A360B04860B003F2D95 /* Build configuration list for PBXProject "libcore" */;
140142
compatibilityVersion = "Xcode 3.2";
141143
developmentRegion = English;

libexternal/libexternal.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@
116116
/* Begin PBXProject section */
117117
4DF42A350B04860B003F2D95 /* Project object */ = {
118118
isa = PBXProject;
119+
attributes = {
120+
};
119121
buildConfigurationList = 4DF42A360B04860B003F2D95 /* Build configuration list for PBXProject "libexternal" */;
120122
compatibilityVersion = "Xcode 3.2";
121123
developmentRegion = English;

libexternalv1/libexternalv1.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@
114114
/* Begin PBXProject section */
115115
4DF42A350B04860B003F2D95 /* Project object */ = {
116116
isa = PBXProject;
117+
attributes = {
118+
};
117119
buildConfigurationList = 4DF42A360B04860B003F2D95 /* Build configuration list for PBXProject "libexternalv1" */;
118120
compatibilityVersion = "Xcode 3.2";
119121
developmentRegion = English;

0 commit comments

Comments
 (0)